Add player skeleton and playback service

This introduces a dependency on audio_service and implements the
playback service using that package. The UI was adapted to the new
interface.
This commit is contained in:
Elias Projahn 2020-04-18 13:50:38 +02:00
parent e0fc60f9eb
commit 3471fcf78b
31 changed files with 321 additions and 44 deletions

View file

@ -30,13 +30,13 @@ class _PlayPauseButtonState extends State<PlayPauseButton>
super.didChangeDependencies();
backend = Backend.of(context);
playPauseAnimation.value = backend.playing.value ? 1.0 : 0.0;
playPauseAnimation.value = backend.player.playing.value ? 1.0 : 0.0;
if (playingSubscription != null) {
playingSubscription.cancel();
}
playingSubscription = backend.playing.listen((playing) =>
playingSubscription = backend.player.playing.listen((playing) =>
playing ? playPauseAnimation.forward() : playPauseAnimation.reverse());
}
@ -47,7 +47,7 @@ class _PlayPauseButtonState extends State<PlayPauseButton>
icon: AnimatedIcons.play_pause,
progress: playPauseAnimation,
),
onPressed: backend.playPause,
onPressed: backend.player.playPause,
);
}

View file

@ -16,7 +16,7 @@ class PlayerBar extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
StreamBuilder(
stream: backend.position,
stream: backend.player.normalizedPosition,
builder: (context, snapshot) => LinearProgressIndicator(
value: snapshot.data,
),