Skip to content

Commit ad92592

Browse files
committed
fix: notification artwork not falling back to folder cover
1 parent 6eb266e commit ad92592

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

lib/base/audio_handler.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,9 @@ extension TrackToAudioSourceMediaItem on Selectable {
20012001
MediaItem toMediaItem(int currentIndex, int queueLength, Duration? duration) {
20022002
final tr = track.toTrackExt();
20032003
final artist = tr.originalArtist == '' ? UnknownTags.ARTIST : tr.originalArtist;
2004-
final imagePage = tr.pathToImage;
2004+
final imagePath = tr.pathToImage;
2005+
String? imagePathToUse = File(imagePath).existsSync() ? imagePath : null;
2006+
imagePathToUse ??= Indexer.inst.getFallbackFolderArtworkPath(folderPath: tr.folderPath);
20052007
return MediaItem(
20062008
id: tr.path,
20072009
title: tr.title,
@@ -2012,7 +2014,7 @@ extension TrackToAudioSourceMediaItem on Selectable {
20122014
album: tr.hasUnknownAlbum ? '' : tr.album,
20132015
genre: tr.originalGenre,
20142016
duration: duration ?? Duration(milliseconds: tr.durationMS),
2015-
artUri: Uri.file(File(imagePage).existsSync() ? imagePage : AppPaths.NAMIDA_LOGO_MONET),
2017+
artUri: Uri.file(imagePathToUse ?? AppPaths.NAMIDA_LOGO_MONET),
20162018
);
20172019
}
20182020
}

lib/controller/indexer_controller.dart

+11
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ class Indexer<T extends Track> {
105105

106106
bool imageObtainedBefore(String imagePath) => _artworksMap[imagePath] != null || _artworksMapFullRes[imagePath] != null;
107107

108+
String? getFallbackFolderArtworkPath({required String folderPath}) {
109+
String? cover = this.allFolderCovers[folderPath];
110+
if (cover == null && folderPath.endsWith(Platform.pathSeparator)) {
111+
try {
112+
folderPath = folderPath.substring(0, folderPath.length - 1);
113+
cover = this.allFolderCovers[folderPath];
114+
} catch (_) {}
115+
}
116+
return cover;
117+
}
118+
108119
/// {imagePath: (TrackExtended, id)};
109120
final _backupMediaStoreIDS = <String, (Track, int)>{};
110121
final artworksMap = <String, Uint8List?>{};

lib/ui/widgets/artwork.dart

+1-8
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,7 @@ class _ArtworkWidgetState extends State<ArtworkWidget> with LoadingItemsDelayMix
153153
}
154154

155155
if (_imagePath == null && widget.track != null && widget.fallbackToFolderCover) {
156-
String folderPath = widget.track!.folderPath;
157-
String? cover = Indexer.inst.allFolderCovers[folderPath];
158-
if (cover == null && folderPath.endsWith(Platform.pathSeparator)) {
159-
try {
160-
folderPath = folderPath.substring(0, folderPath.length - 1);
161-
cover = Indexer.inst.allFolderCovers[folderPath];
162-
} catch (_) {}
163-
}
156+
final cover = Indexer.inst.getFallbackFolderArtworkPath(folderPath: widget.track!.folderPath);
164157
if (cover != null && mounted) setState(() => _imagePath = cover);
165158
}
166159
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: namida
22
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
33
publish_to: "none"
4-
version: 4.9.2-beta+250118221
4+
version: 4.9.2-beta+250118223
55

66
environment:
77
sdk: ">=3.6.0 <4.0.0"

0 commit comments

Comments
 (0)