fix(library): sync track playback controls

This commit is contained in:
zarzet
2026-08-30 00:43:13 +07:00
parent d5465e9768
commit 7141ca980f
7 changed files with 150 additions and 38 deletions
+20
View File
@@ -38,6 +38,26 @@ final playbackLoadingProvider = Provider<bool>((ref) {
);
});
/// Transport state for one media item. Non-current Library cells only watch
/// the current media ID; the active cell additionally follows play/loading so
/// a transport toggle does not rebuild the entire Library grid.
final mediaItemPlaybackUiProvider =
Provider.family<({bool isCurrent, bool isPlaying, bool isLoading}), String>(
(ref, mediaId) {
final currentId = ref.watch(
currentMediaItemProvider.select((state) => state.value?.id),
);
if (mediaId.isEmpty || currentId != mediaId) {
return (isCurrent: false, isPlaying: false, isLoading: false);
}
return (
isCurrent: true,
isPlaying: ref.watch(playbackPlayingProvider),
isLoading: ref.watch(playbackLoadingProvider),
);
},
);
final playQueueProvider = StreamProvider<List<MediaItem>>((ref) {
return musicPlayerQueueEvents();
});