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
@@ -62,7 +62,11 @@ class _NowPlayingScreenState extends ConsumerState<NowPlayingScreen> {
return const Scaffold(body: Center(child: Text('Nothing playing.')));
}
final pos = playback?.updatePosition ?? Duration.zero;
// Use positionProvider (just_audio's positionStream, ~200ms) for
// the seek bar so it scrubs live; PlaybackState.updatePosition
// only fires on state transitions and would leave the bar frozen
// between them.
final pos = ref.watch(positionProvider).value ?? Duration.zero;
final dur = media.duration ?? Duration.zero;
final isPlaying = playback?.playing == true;
final shuffleOn = playback?.shuffleMode == AudioServiceShuffleMode.all;
@@ -109,22 +113,22 @@ class _NowPlayingScreenState extends ConsumerState<NowPlayingScreen> {
overflow: TextOverflow.ellipsis,
),
],
const SizedBox(height: 20),
const SizedBox(height: 32),
_SeekRow(position: pos, duration: dur, fs: fs, ref: ref),
const SizedBox(height: 8),
const SizedBox(height: 24),
_PrimaryControls(
fs: fs,
ref: ref,
isPlaying: isPlaying,
),
const SizedBox(height: 16),
const SizedBox(height: 24),
_SecondaryControls(
fs: fs,
actions: actions,
shuffleOn: shuffleOn,
repeatMode: repeatMode,
),
const Spacer(),
const SizedBox(height: 24),
],
),
),