Просмотр исходного кода

MusicBeeper: Adapt ofw music player changes

Willy-JL 2 лет назад
Родитель
Сommit
eb9e72b2c6

+ 5 - 4
music_beeper/application.fam

@@ -3,15 +3,16 @@ App(
     name="Music Beeper",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="music_beeper_app",
-    cdefines=["APP_MUSIC_BEEPER"],
     requires=[
         "gui",
         "dialogs",
     ],
-    provides=["music_beeper_start"],
     stack_size=2 * 1024,
-    order=45,
+    targets=["f7"],
+    fap_version="1.1",
     fap_icon="music_10px.png",
-    fap_icon_assets="icons",
     fap_category="Media",
+    fap_description="An app to play RTTL music files",
+    fap_icon_assets="icons",
+    fap_file_assets="files",
 )

+ 6 - 0
music_beeper/files/Marble_Machine.fmf

@@ -0,0 +1,6 @@
+Filetype: Flipper Music Format
+Version: 0
+BPM: 130
+Duration: 8
+Octave: 5
+Notes: E6, P, E, B, 4P, E, A, G, A, E, B, P, G, A, D6, 4P, D, B, 4P, D, A, G, A, D, F#, P, G, A, D6, 4P, F#, B, 4P, F#, D6, C6, B, F#, A, P, G, F#, E, P, C, E, B, B4, C, D, D6, C6, B, F#, A, P, G, A, E6, 4P, E, B, 4P, E, A, G, A, E, B, P, G, A, D6, 4P, D, B, 4P, D, A, G, A, D, F#, P, G, A, D6, 4P, F#, B, 4P, F#, D6, C6, B, F#, A, P, G, F#, E, P, C, E, B, B4, C, D, D6, C6, B, F#, A, P, G, A, E6

BIN
music_beeper/icons/music_10px.png


+ 21 - 4
music_beeper/music_beeper.c

@@ -8,10 +8,13 @@
 #include <dialogs/dialogs.h>
 #include <storage/storage.h>
 
+#include <assets_icons.h>
+
 #define TAG "MusicBeeper"
 
-#define MUSIC_BEEPER_APP_PATH_FOLDER ANY_PATH("music_player")
+#define MUSIC_BEEPER_APP_PATH EXT_PATH("apps_data/music_player")
 #define MUSIC_BEEPER_APP_EXTENSION "*"
+#define MUSIC_BEEPER_EXAMPLE_FILE "Marble_Machine.fmf"
 
 #define MUSIC_BEEPER_SEMITONE_HISTORY_SIZE 4
 
@@ -180,7 +183,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
 
     // note stack view_port
     x_pos = 73;
-    y_pos = 0;
+    y_pos = 0; //-V1048
     canvas_set_color(canvas, ColorBlack);
     canvas_set_font(canvas, FontPrimary);
     canvas_draw_frame(canvas, x_pos, y_pos, 49, 64);
@@ -258,7 +261,7 @@ MusicBeeper* music_beeper_alloc() {
     MusicBeeper* instance = malloc(sizeof(MusicBeeper));
 
     instance->model = malloc(sizeof(MusicBeeperModel));
-    instance->model->volume = 4;
+    instance->model->volume = 3;
 
     instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
 
@@ -307,17 +310,31 @@ int32_t music_beeper_app(void* p) {
         if(p && strlen(p)) {
             furi_string_set(file_path, (const char*)p);
         } else {
-            furi_string_set(file_path, MUSIC_BEEPER_APP_PATH_FOLDER);
+            Storage* storage = furi_record_open(RECORD_STORAGE);
+            storage_common_migrate(
+                storage, EXT_PATH("music_player"), MUSIC_BEEPER_APP_PATH);
+
+            if(!storage_common_exists(storage, MUSIC_BEEPER_APP_PATH "/" MUSIC_BEEPER_EXAMPLE_FILE)) {
+                storage_common_copy(
+                    storage,
+                    APP_ASSETS_PATH(MUSIC_BEEPER_EXAMPLE_FILE),
+                    MUSIC_BEEPER_APP_PATH "/" MUSIC_BEEPER_EXAMPLE_FILE);
+            }
+            furi_record_close(RECORD_STORAGE);
+
+            furi_string_set(file_path, MUSIC_BEEPER_APP_PATH);
 
             DialogsFileBrowserOptions browser_options;
             dialog_file_browser_set_basic_options(
                 &browser_options, MUSIC_BEEPER_APP_EXTENSION, &I_music_10px);
             browser_options.hide_ext = false;
+            browser_options.base_path = MUSIC_BEEPER_APP_PATH;
 
             DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
             bool res = dialog_file_browser_show(dialogs, file_path, file_path, &browser_options);
 
             furi_record_close(RECORD_DIALOGS);
+
             if(!res) {
                 FURI_LOG_E(TAG, "No file selected");
                 break;