fix(flutter): player updates on track change + kebab artist nav + Start radio
Three issues, all related to the player surface: 1. Player UI didn't update on track change. audio_handler's _onCurrentIndexChanged only kicked off the cover load — it never pushed the new MediaItem onto the mediaItem stream. Title/artist/ cover stayed pinned to whatever setQueueFromTracks(initialIndex:) set on first play. Now the listener pushes queue[idx] when the index changes. 2. Player kebab "Go to artist" 404'd while the same item from MostPlayed worked. Same TrackActionsSheet for both, but the player's _trackRefFromMediaItem was hardcoding artistId: '' because audio_handler's _toMediaItem never stashed it in extras. Stash artist_id alongside album_id; player_bar + now_playing_screen read it back. Both kebabs now navigate. 3. "Start radio" didn't exist on Flutter even though the server has /api/radio?seed_track=<id>. New RadioApi (lib/api/endpoints/ radio.dart) wraps the endpoint; PlayerActions.startRadio(trackId) fetches + plays the result via the existing playTracks path. New menu item between "Add to playlist" and the divider above "Go to album", calls startRadio with a snackbar error fallback.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../api/endpoints/radio.dart';
|
||||
import '../auth/auth_provider.dart';
|
||||
import '../cache/audio_cache_manager.dart';
|
||||
import '../library/library_providers.dart' show dioProvider;
|
||||
@@ -102,6 +103,15 @@ class PlayerActions {
|
||||
Future<void> setVolume(double v) async {
|
||||
await _ref.read(audioHandlerProvider).setVolume(v);
|
||||
}
|
||||
|
||||
/// Fetches /api/radio?seed_track=<id> and starts playing the
|
||||
/// returned track list (seed at index 0 + recommended picks).
|
||||
Future<void> startRadio(String trackId) async {
|
||||
final dio = await _ref.read(dioProvider.future);
|
||||
final tracks = await RadioApi(dio).seedTrack(trackId);
|
||||
if (tracks.isEmpty) return;
|
||||
await playTracks(tracks);
|
||||
}
|
||||
}
|
||||
|
||||
final playerActionsProvider = Provider<PlayerActions>((ref) => PlayerActions(ref));
|
||||
|
||||
Reference in New Issue
Block a user