feat(flutter/player): albumCoverCacheProvider + pass cache through configure

Adds the Riverpod provider (constructed with dioFactory pulling from
the authenticated dioProvider) and extends PlayerActions.playTracks
to forward the cache to audio_handler.configure(). The handler
signature change lands in the next commit.

Intentional intermediate-broken state: audio_handler.configure
doesn't yet accept coverCache. Resolved by the next task in the same
push.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-09 12:54:05 -04:00
parent b6d6f22598
commit d70075c426
+11 -1
View File
@@ -2,13 +2,21 @@ import 'package:audio_service/audio_service.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../auth/auth_provider.dart';
import '../library/library_providers.dart' show dioProvider;
import '../models/track.dart';
import 'album_cover_cache.dart';
import 'audio_handler.dart';
final audioHandlerProvider = Provider<MinstrelAudioHandler>((ref) {
throw UnimplementedError('overridden in main()');
});
final albumCoverCacheProvider = Provider<AlbumCoverCache>((ref) {
return AlbumCoverCache(
dioFactory: () => ref.read(dioProvider.future),
);
});
final playbackStateProvider = StreamProvider<PlaybackState>(
(ref) => ref.watch(audioHandlerProvider).playbackState,
);
@@ -28,7 +36,9 @@ class PlayerActions {
Future<void> playTracks(List<TrackRef> tracks, {int initialIndex = 0}) async {
final url = await _ref.read(serverUrlProvider.future);
final token = await _ref.read(secureStorageProvider).read(key: 'session_token');
final h = _ref.read(audioHandlerProvider)..configure(baseUrl: url ?? '', token: token);
final cache = _ref.read(albumCoverCacheProvider);
final h = _ref.read(audioHandlerProvider)
..configure(baseUrl: url ?? '', token: token, coverCache: cache);
await h.setQueueFromTracks(tracks, initialIndex: initialIndex);
await h.play();
}