Skip to content

Commit

Permalink
updated description in settings "more info" dialog to include more de…
Browse files Browse the repository at this point in the history
…tails
  • Loading branch information
Chaphasilor committed May 3, 2024
1 parent da023c5 commit e84e953
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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: () {
Expand Down
20 changes: 17 additions & 3 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
},
Expand Down
10 changes: 7 additions & 3 deletions lib/services/metadata_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,19 +148,19 @@ final AutoDisposeFutureProviderFamily<MetadataProvider?, MetadataRequest>
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) {
Expand Down

0 comments on commit e84e953

Please sign in to comment.