fix(flutter): live seek bar (~200ms) + breathing room above controls

Why the seek bar appeared frozen: it was reading
PlaybackState.updatePosition, which audio_service only updates on
event transitions (play/pause/buffer/seek). Between events it sits
unchanged, so the bar only jumped at intervals.

Expose just_audio's positionStream (~200ms cadence) from the audio
handler, wrap as positionProvider, and read that in both the mini bar
and the full player. Now the bar advances continuously while playing.

While we're here: spread the full player's vertical layout per
operator — gap to seek 20→32, seek-to-primary 8→24, primary-to-
secondary 16→24, plus 24 below to match. The full player had visible
slack above the controls; this redistributes it.
This commit is contained in:
2026-05-11 08:15:58 -04:00
parent 2a5b6970e9
commit b6b73fdd0c
4 changed files with 30 additions and 6 deletions
+4 -1
View File
@@ -36,7 +36,10 @@ class PlayerBar extends ConsumerWidget {
final playback = ref.watch(playbackStateProvider).value;
if (media == null) return const SizedBox.shrink();
final pos = playback?.updatePosition ?? Duration.zero;
// positionProvider is just_audio's positionStream (~200ms cadence)
// so the mini bar's seek crawls forward smoothly. PlaybackState
// only updates on event transitions and would leave it frozen.
final pos = ref.watch(positionProvider).value ?? Duration.zero;
final dur = media.duration ?? Duration.zero;
return Material(