diff --git a/lib/services/media_library_browser.dart b/lib/services/media_library_browser.dart index 65864d16f..58a515096 100644 --- a/lib/services/media_library_browser.dart +++ b/lib/services/media_library_browser.dart @@ -5,6 +5,7 @@ import 'package:mornye/l10n/app_localizations.dart'; import 'package:mornye/models/album_track_order.dart'; import 'package:mornye/models/download_history.dart'; import 'package:mornye/models/track.dart'; +import 'package:mornye/services/cover_store.dart'; import 'package:mornye/services/history_database.dart'; import 'package:mornye/services/library_collections_database.dart'; import 'package:mornye/services/library_database.dart'; @@ -134,9 +135,14 @@ class MediaLibraryBrowser { MediaItem(id: shuffleId, title: strings().nowPlayingShuffleLibrary); /// Artwork a car can load. It cannot open the app's own files, so local - /// covers are left out of lists; the playing song keeps its artwork. + /// covers are left out of lists; the playing song keeps its artwork. Nor + /// can it load the loopback URLs older builds stored in collections. static Uri? _browserArt(String? art) => - art != null && art.startsWith('http') ? Uri.tryParse(art) : null; + art != null && + art.startsWith('http') && + durableCoverReference(art) != null + ? Uri.tryParse(art) + : null; static Map? _group(String? title) => title == null ? null : {_groupTitleKey: title}; diff --git a/test/media_library_browser_test.dart b/test/media_library_browser_test.dart index f93b002ac..1444e2969 100644 --- a/test/media_library_browser_test.dart +++ b/test/media_library_browser_test.dart @@ -357,6 +357,34 @@ void main() { }, ); + test('Loved shows no loopback cover an older build stored', () async { + final directory = await Directory.systemTemp.createTemp('browser'); + addTearDown(() => directory.delete(recursive: true)); + final file = (await File('${directory.path}/loved.flac').create()).path; + Track loved(String name, String cover) => Track( + id: 'catalog-$name', + name: name, + artistName: 'Artist', + albumName: 'Album', + coverUrl: cover, + duration: 200, + ); + final browser = _browser( + library: _Library(filesByTitle: {'Old': file, 'Web': file}), + collections: _Collections( + loved: [ + loved('Old', 'http://127.0.0.1:41234/7f3a'), + loved('Web', 'https://covers.example/web.jpg'), + ], + ), + ); + + final songs = await browser.children(MediaLibraryBrowser.lovedId); + expect(_titles(songs), ['Old', 'Web']); + expect(songs.first.artUri, isNull); + expect(songs.last.artUri.toString(), 'https://covers.example/web.jpg'); + }); + test('with Local Library off, Loved plays no scanned files', () async { final directory = await Directory.systemTemp.createTemp('browser'); addTearDown(() => directory.delete(recursive: true));