mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
fix(player): keep stored loopback covers out of the Android Auto browser
Android Auto lists kept every cover starting with http. Collection tracks loved from the player by older builds can hold a loopback URL of the app's cover proxy, which a car cannot load and which named a route of an earlier run. The browser now leaves those out like local files.
This commit is contained in:
1 parent
e33d2d7089
commit
e913f09d4a
2 files changed
+36
-2
No files matched your search
@@ -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<String, dynamic>? _group(String? title) =>
|
||||
title == null ? null : {_groupTitleKey: title};
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user