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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user