Separate buffering from playbackState. Improve Android buffering detection.

This commit is contained in:
Ryan Heise 2020-02-05 12:26:21 +11:00
parent 280f1a8208
commit eee50d712e
5 changed files with 84 additions and 104 deletions

View file

@ -43,27 +43,29 @@ class _MyAppState extends State<MyApp> {
children: [
Text("Science Friday"),
Text("Science Friday and WNYC Studios"),
StreamBuilder<AudioPlaybackState>(
stream: _player.playbackStateStream,
StreamBuilder<FullAudioPlaybackState>(
stream: _player.fullPlaybackStateStream,
builder: (context, snapshot) {
final state = snapshot.data;
final fullState = snapshot.data;
final state = fullState?.state;
final buffering = fullState?.buffering;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (state == AudioPlaybackState.playing)
IconButton(
icon: Icon(Icons.pause),
iconSize: 64.0,
onPressed: _player.pause,
)
else if (state == AudioPlaybackState.buffering ||
state == AudioPlaybackState.connecting)
if (state == AudioPlaybackState.connecting ||
buffering == true)
Container(
margin: EdgeInsets.all(8.0),
width: 64.0,
height: 64.0,
child: CircularProgressIndicator(),
)
else if (state == AudioPlaybackState.playing)
IconButton(
icon: Icon(Icons.pause),
iconSize: 64.0,
onPressed: _player.pause,
)
else
IconButton(
icon: Icon(Icons.play_arrow),