diff --git a/lib/components/LayoutSettingsScreen/CustomizationSettingsScreen/playback_speed_control_visibility_dropdown_list_tile.dart b/lib/components/LayoutSettingsScreen/CustomizationSettingsScreen/playback_speed_control_visibility_dropdown_list_tile.dart index c109a0ecc..10130d804 100644 --- a/lib/components/LayoutSettingsScreen/CustomizationSettingsScreen/playback_speed_control_visibility_dropdown_list_tile.dart +++ b/lib/components/LayoutSettingsScreen/CustomizationSettingsScreen/playback_speed_control_visibility_dropdown_list_tile.dart @@ -1,3 +1,4 @@ +import 'package:finamp/services/metadata_provider.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -43,7 +44,7 @@ class PlaybackSpeedControlVisibilityDropdownListTile extends StatelessWidget { title: Text(AppLocalizations.of(context)! .playbackSpeedControlSetting), content: Text(AppLocalizations.of(context)! - .playbackSpeedControlSettingDescription), + .playbackSpeedControlSettingDescription(MetadataProvider.speedControlLongTrackDuration.inMinutes, MetadataProvider.speedControlLongAlbumDuration.inHours, MetadataProvider.speedControlGenres.join(", "))), actions: [ TextButton( onPressed: () { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d0f9418a3..3088debc7 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -470,9 +470,23 @@ "@playbackSpeedControlSettingSubtitle": { "description": "Subtitle for the playback speed visibility setting" }, - "playbackSpeedControlSettingDescription": "Automatic: Finamp tries to identify whether the media you are playing is an audiobook (based on genre and album length). If Finamp thinks it is, it will show the playback speed controls.\n\nShown: The playback speed controls are available regardless of what kind of media you are playing.\n\nHidden: The playback speed controls in the song menu are hidden.", + "playbackSpeedControlSettingDescription": "Automatic:\nFinamp tries to identify whether the track you are playing is a podcast or (part of) an audiobook. This is considered to be the case if the track is longer than {trackDuration} minutes, if the track's album is longer than {albumDuration} hours, or if the track has at least one of these genres assigned: {genreList}\nPlayback speed controls will then be shown in the player screen menu.\n\nShown:\nThe playback speed controls will always be shown in the player screen menu.\n\nHidden:\nThe playback speed controls in the player screen menu are always hidden.", "@playbackSpeedControlSettingDescription": { - "description": "Description for the dropdown that selects the replay gain mode, shown in a dialog that opens when the user presses the info icon next to the dropdown" + "description": "Description for the dropdown that selects the replay gain mode, shown in a dialog that opens when the user presses the info icon next to the dropdown", + "placeholders": { + "trackDuration": { + "type": "int", + "example": "30" + }, + "albumDuration": { + "type": "int", + "example": "3" + }, + "genreList": { + "type": "String", + "example": "Podcast, Audiobook" + } + } }, "automatic": "Automatic", "@automatic": { @@ -1030,7 +1044,7 @@ "@volumeNormalizationModeSelectorSubtitle": { "description": "Subtitle for the dropdown that selects the replay gain mode" }, - "volumeNormalizationModeSelectorDescription": "Hybrid (Track + Album): Track gain is used for regular playback, but if an album is playing (either because it's the main playback queue source, or because it was added to the queue at some point), the album gain is used instead.\n\nTrack-based: Track gain is always used, regardless of whether an album is playing or not.\n\nAlbums Only: Volume Normalization is only applied while playing albums (using the album gain), but not for individual tracks.", + "volumeNormalizationModeSelectorDescription": "Hybrid (Track + Album):\nTrack gain is used for regular playback, but if an album is playing (either because it's the main playback queue source, or because it was added to the queue at some point), the album gain is used instead.\n\nTrack-based:\nTrack gain is always used, regardless of whether an album is playing or not.\n\nAlbums Only:\nVolume Normalization is only applied while playing albums (using the album gain), but not for individual tracks.", "@volumeNormalizationModeSelectorDescription": { "description": "Description for the dropdown that selects the replay gain mode, shown in a dialog that opens when the user presses the info icon next to the dropdown" }, diff --git a/lib/services/metadata_provider.dart b/lib/services/metadata_provider.dart index eb044dfbd..05e74fc49 100644 --- a/lib/services/metadata_provider.dart +++ b/lib/services/metadata_provider.dart @@ -41,6 +41,10 @@ class MetadataRequest { class MetadataProvider { + static const speedControlGenres = ["audiobook", "podcast", "speech"]; + static const speedControlLongTrackDuration = Duration(minutes: 15); + static const speedControlLongAlbumDuration = Duration(hours: 3); + final MediaSourceInfo mediaSourceInfo; LyricDto? lyrics; bool isDownloaded; @@ -144,19 +148,19 @@ final AutoDisposeFutureProviderFamily if (request.checkIfSpeedControlNeeded) { for (final genre in request.item.genres ?? []) { - if (["audiobook", "podcast", "speech"].contains(genre.toLowerCase())) { + if (MetadataProvider.speedControlGenres.contains(genre.toLowerCase())) { metadata.qualifiesForPlaybackSpeedControl = true; break; } } - if (!metadata.qualifiesForPlaybackSpeedControl && metadata.mediaSourceInfo.runTimeTicks! > const Duration(minutes: 15).inMicroseconds * 10) { + if (!metadata.qualifiesForPlaybackSpeedControl && metadata.mediaSourceInfo.runTimeTicks! > MetadataProvider.speedControlLongTrackDuration.inMicroseconds * 10) { // we might want playback speed control for long tracks (like podcasts or audiobook chapters) metadata.qualifiesForPlaybackSpeedControl = true; } else { // check if "album" is long enough to qualify for playback speed control try { final parent = await jellyfinApiHelper.getItemById(request.item.parentId!); - if (parent.runTimeTicks! > const Duration(hours: 3).inMicroseconds * 10) { + if (parent.runTimeTicks! > MetadataProvider.speedControlLongAlbumDuration.inMicroseconds * 10) { metadata.qualifiesForPlaybackSpeedControl = true; } } catch(e) {