Skip to content

Commit

Permalink
feat: prioritize embedded lyrics option
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Oct 25, 2023
1 parent 800965c commit b3e1ee1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/controller/lyrics_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ class Lyrics {

final embedded = track.lyrics;

if (settings.prioritizeEmbeddedLyrics.value && embedded != '') {
try {
final lrc = embedded.toLrc();
currentLyricsLRC.value = lrc;
} catch (e) {
currentLyricsText.value = embedded;
}
return;
}

/// 1. device lrc
/// 2. cached lrc
/// 3. track embedded lrc
Expand Down
7 changes: 7 additions & 0 deletions lib/controller/settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class SettingsController {
final RxBool groupArtworksByAlbum = false.obs;
final RxBool enableM3USync = false.obs;
final RxBool canAskForBatteryOptimizations = true.obs;
final RxBool prioritizeEmbeddedLyrics = true.obs;
final RxList<TagField> tagFieldsToEdit = <TagField>[
TagField.trackNumber,
TagField.year,
Expand Down Expand Up @@ -390,6 +391,7 @@ class SettingsController {
groupArtworksByAlbum.value = json['groupArtworksByAlbum'] ?? groupArtworksByAlbum.value;
enableM3USync.value = json['enableM3USync'] ?? enableM3USync.value;
canAskForBatteryOptimizations.value = json['canAskForBatteryOptimizations'] ?? canAskForBatteryOptimizations.value;
prioritizeEmbeddedLyrics.value = json['prioritizeEmbeddedLyrics'] ?? prioritizeEmbeddedLyrics.value;

final listFromStorage = List<String>.from(json['tagFieldsToEdit'] ?? []);
tagFieldsToEdit.value = listFromStorage.isNotEmpty ? List<TagField>.from(listFromStorage.map((e) => TagField.values.getEnum(e))) : tagFieldsToEdit;
Expand Down Expand Up @@ -586,6 +588,7 @@ class SettingsController {
'groupArtworksByAlbum': groupArtworksByAlbum.value,
'enableM3USync': enableM3USync.value,
'canAskForBatteryOptimizations': canAskForBatteryOptimizations.value,
'prioritizeEmbeddedLyrics': prioritizeEmbeddedLyrics.value,
'tagFieldsToEdit': tagFieldsToEdit.mapped((element) => element.convertToString),
'wakelockMode': wakelockMode.value.convertToString,
'localVideoMatchingType': localVideoMatchingType.value.convertToString,
Expand Down Expand Up @@ -753,6 +756,7 @@ class SettingsController {
bool? groupArtworksByAlbum,
bool? enableM3USync,
bool? canAskForBatteryOptimizations,
bool? prioritizeEmbeddedLyrics,
List<TagField>? tagFieldsToEdit,
WakelockMode? wakelockMode,
LocalVideoMatchingType? localVideoMatchingType,
Expand Down Expand Up @@ -1176,6 +1180,9 @@ class SettingsController {
if (canAskForBatteryOptimizations != null) {
this.canAskForBatteryOptimizations.value = canAskForBatteryOptimizations;
}
if (prioritizeEmbeddedLyrics != null) {
this.prioritizeEmbeddedLyrics.value = prioritizeEmbeddedLyrics;
}
if (tagFieldsToEdit != null) {
tagFieldsToEdit.loop((d, index) {
if (!this.tagFieldsToEdit.contains(d)) {
Expand Down
1 change: 1 addition & 0 deletions lib/core/translations/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class LanguageKeys {
late String PREVENT_DUPLICATED_TRACKS_SUBTITLE;
late String PREVENT_DUPLICATED_TRACKS;
late String PREVIEW;
late String PRIORITIZE_EMBEDDED_LYRICS;
late String PROGRESS;
late String PROMPT_INDEXING_REFRESH;
late String PROMPT_TO_CHANGE_TRACK_PATH;
Expand Down
3 changes: 3 additions & 0 deletions lib/core/translations/language.dart
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ class Language extends LanguageKeys {
PREVENT_DUPLICATED_TRACKS_SUBTITLE = getKey("PREVENT_DUPLICATED_TRACKS_SUBTITLE");
PREVENT_DUPLICATED_TRACKS = getKey("PREVENT_DUPLICATED_TRACKS");
PREVIEW = getKey("PREVIEW");
PRIORITIZE_EMBEDDED_LYRICS = getKey("PRIORITIZE_EMBEDDED_LYRICS");
PROGRESS = getKey("PROGRESS");
PROMPT_INDEXING_REFRESH = getKey("PROMPT_INDEXING_REFRESH");
PROMPT_TO_CHANGE_TRACK_PATH = getKey("PROMPT_TO_CHANGE_TRACK_PATH");
Expand Down Expand Up @@ -755,6 +756,8 @@ class Language extends LanguageKeys {








8 changes: 8 additions & 0 deletions lib/ui/widgets/settings/extra_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ class ExtrasSettings extends StatelessWidget {
onChanged: (p0) => settings.save(enableSearchCleanup: !p0),
),
),
Obx(
() => CustomSwitchListTile(
icon: Broken.mobile_programming,
title: lang.PRIORITIZE_EMBEDDED_LYRICS,
value: settings.prioritizeEmbeddedLyrics.value,
onChanged: (p0) => settings.save(prioritizeEmbeddedLyrics: !p0),
),
),
CustomListTile(
icon: Broken.colorfilter,
title: lang.EXTRACT_ALL_COLOR_PALETTES,
Expand Down

0 comments on commit b3e1ee1

Please sign in to comment.