From 43b0fba75d4312230793f2747700371362204bb6 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Wed, 12 Apr 2023 20:19:58 +0200 Subject: Track Info: Show number of tracks being inspected Applies to the database and PictureFlow + fix red 6ca57ec Change-Id: If708851ebdfe075e9d6ea3f2e2dd790cc9deac94 --- apps/gui/wps.c | 2 +- apps/onplay.c | 2 +- apps/playlist_viewer.c | 2 +- apps/plugin.h | 2 +- apps/plugins/lib/mul_id3.c | 2 +- apps/plugins/pictureflow/pictureflow.c | 2 +- apps/plugins/properties.c | 8 +++++--- apps/screens.c | 26 ++++++++++++++++++-------- apps/screens.h | 2 +- 9 files changed, 30 insertions(+), 18 deletions(-) (limited to 'apps') diff --git a/apps/gui/wps.c b/apps/gui/wps.c index d87f78de2d..10c971fcc4 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -1035,7 +1035,7 @@ long gui_wps_show(void) gwps_leave_wps(true); if (browse_id3(audio_current_track(), playlist_get_display_index(), - playlist_amount(), NULL, false)) + playlist_amount(), NULL, 1)) return GO_TO_ROOT; restore = true; } diff --git a/apps/onplay.c b/apps/onplay.c index 4b6171746c..05046f6e00 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -1569,7 +1569,7 @@ static int browse_id3_wrapper(void) if (browse_id3(audio_current_track(), playlist_get_display_index(), - playlist_amount(), NULL, false)) + playlist_amount(), NULL, 1)) return GO_TO_ROOT; return GO_TO_PREVIOUS; } diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index d9bfee343f..e3a3b1bea7 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -526,7 +526,7 @@ static enum pv_onplay_result show_track_info(const struct playlist_entry *curren return id3_retrieval_successful && browse_id3(&id3, current_track->index + 1, - viewer.num_tracks, NULL, false) ? PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED; + viewer.num_tracks, NULL, 1) ? PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED; } diff --git a/apps/plugin.h b/apps/plugin.h index 835063e25f..9e94fe697e 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -500,7 +500,7 @@ struct plugin_api { void (*add_to_pl_cb)); bool (*browse_id3)(struct mp3entry *id3, int playlist_display_index, int playlist_amount, - struct tm *modified, bool multiple_tracks); + struct tm *modified, int track_ct); /* talking */ int (*talk_id)(int32_t id, bool enqueue); diff --git a/apps/plugins/lib/mul_id3.c b/apps/plugins/lib/mul_id3.c index c40a495ecd..edf44f7282 100644 --- a/apps/plugins/lib/mul_id3.c +++ b/apps/plugins/lib/mul_id3.c @@ -135,7 +135,7 @@ void collect_id3(struct mp3entry *id3, bool is_first_track) * - Unit for length will be s instead of ms * * Use result only as input for browse_id3, - * and set multiple_tracks parameter to true. + * with the track_ct parameter set to > 1. */ void finalize_id3(struct mp3entry *id3) { diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 52f87355b2..b884f3ae0f 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -4027,7 +4027,7 @@ static int show_id3_info(const char *selected_file) if (is_multiple_tracks) finalize_id3(&id3); - return rb->browse_id3(&id3, 0, 0, NULL, i > 1) ? PLUGIN_USB_CONNECTED : 0; + return rb->browse_id3(&id3, 0, 0, NULL, i) ? PLUGIN_USB_CONNECTED : 0; } diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 638d7380a5..53af4c5bab 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -446,9 +446,11 @@ enum plugin_status plugin_start(const void* parameter) FOR_NB_SCREENS(i) rb->viewportmanager_theme_enable(i, true, NULL); - bool usb = props_type == PROPS_ID3 ? rb->browse_id3(&id3, 0, 0, &tm, false) : - (props_type == PROPS_MUL_ID3 ? rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count > 1) : - browse_file_or_dir(&stats)); + bool usb = props_type == PROPS_ID3 ? rb->browse_id3(&id3, 0, 0, &tm, 1) : +#ifdef HAVE_TAGCACHE + props_type == PROPS_MUL_ID3 ? rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) : +#endif + browse_file_or_dir(&stats); FOR_NB_SCREENS(i) rb->viewportmanager_theme_undo(i, false); diff --git a/apps/screens.c b/apps/screens.c index c519da9353..d359267d8d 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -367,6 +367,7 @@ bool set_time_screen(const char* title, struct tm *tm, bool set_date) static const int id3_headers[]= { + LANG_TAGNAVI_ALL_TRACKS, LANG_ID3_TITLE, LANG_ID3_ARTIST, LANG_ID3_COMPOSER, @@ -394,7 +395,7 @@ static const int id3_headers[]= struct id3view_info { struct mp3entry* id3; struct tm *modified; - bool multiple_tracks; + int track_ct; int count; int playlist_display_index; int playlist_amount; @@ -502,7 +503,8 @@ static const char * id3_get_or_speak_info(int selected_item, void* data, if(say_it) talk_id(id3_headers[info->info_id[info_no]], false); snprintf(buffer, buffer_len, - "[%s]", str(id3_headers[info->info_id[info_no]])); + info->info_id[info_no] > 0 ? "[%s]" : "%s", + str(id3_headers[info->info_id[info_no]])); return buffer; } else @@ -511,6 +513,14 @@ static const char * id3_get_or_speak_info(int selected_item, void* data, char * val=NULL; switch(id3_headers[info->info_id[info_no]]) { + case LANG_TAGNAVI_ALL_TRACKS: + if (info->track_ct <= 1) + return NULL; + snprintf(buffer, buffer_len, "%d", info->track_ct); + val = buffer; + if(say_it) + talk_number(info->track_ct, true); + break; case LANG_ID3_TITLE: val=id3->title; if(say_it && val) @@ -597,7 +607,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data, } break; case LANG_ID3_LENGTH: - length = info->multiple_tracks ? id3->length : id3->length / 1000; + length = info->track_ct > 1 ? id3->length : id3->length / 1000; format_time_auto(buffer, buffer_len, length, UNIT_SEC | UNIT_TRIM_ZERO, true); @@ -674,7 +684,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data, case LANG_FILESIZE: /* not LANG_ID3_FILESIZE because the string is shared */ if (!id3->filesize) return NULL; - if (info->multiple_tracks) + if (info->track_ct > 1) { unit = kibyte_units; unit_ct = 3; @@ -737,11 +747,11 @@ static int id3_speak_item(int selected_item, void* data) return 0; } -/* Note: Setting multiple_tracks parameter to true causes filesize value - * to be treated as KiB (instead of Bytes), and length as s instead of ms. +/* Note: If track_ct > 1, filesize value will be treated as + * KiB (instead of Bytes), and length as s instead of ms. */ bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, - struct tm *modified, bool multiple_tracks) + struct tm *modified, int track_ct) { struct gui_synclist id3_lists; int key; @@ -750,7 +760,7 @@ bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_a info.count = 0; info.id3 = id3; info.modified = modified; - info.multiple_tracks = multiple_tracks; + info.track_ct = track_ct; info.playlist_display_index = playlist_display_index; info.playlist_amount = playlist_amount; bool ret = false; diff --git a/apps/screens.h b/apps/screens.h index 2dc0530f3a..bcd06655ad 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -40,7 +40,7 @@ bool set_time_screen(const char* title, struct tm *tm, bool set_date); #endif bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, - struct tm *modified, bool multiple_tracks); + struct tm *modified, int track_ct); int view_runtime(void); #ifdef HAVE_TOUCHSCREEN -- cgit v1.2.3