background playback works on iphone!
This commit is contained in:
@@ -40,8 +40,13 @@ class _PlayControlsState extends State<PlayControls>
|
|||||||
print("Listen init");
|
print("Listen init");
|
||||||
|
|
||||||
_listenHandler.playbackState.listen((PlaybackState event) {
|
_listenHandler.playbackState.listen((PlaybackState event) {
|
||||||
|
if (isPlaying == event.playing) {
|
||||||
|
print("State unchanged, skipping setState()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
isPlaying = event.playing;
|
isPlaying = event.playing;
|
||||||
|
print("Updated playing state to $isPlaying");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,13 +73,20 @@ class _PlayControlsState extends State<PlayControls>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
|
|
||||||
|
print("Running build - Listen");
|
||||||
|
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
//player.resume();
|
//player.resume();
|
||||||
_listenHandler.play();
|
_listenHandler.play();
|
||||||
_listenHandler.playbackState.add(PlaybackState(
|
_listenHandler.playbackState.add(PlaybackState(
|
||||||
controls: [
|
controls: [
|
||||||
MediaControl.stop,
|
MediaControl.stop,
|
||||||
|
MediaControl.pause,
|
||||||
],
|
],
|
||||||
|
systemActions: {
|
||||||
|
MediaAction.stop,
|
||||||
|
MediaAction.pause,
|
||||||
|
},
|
||||||
playing: true,
|
playing: true,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
@@ -82,6 +94,7 @@ class _PlayControlsState extends State<PlayControls>
|
|||||||
_listenHandler.stop();
|
_listenHandler.stop();
|
||||||
_listenHandler.playbackState.add(PlaybackState(
|
_listenHandler.playbackState.add(PlaybackState(
|
||||||
controls: [],
|
controls: [],
|
||||||
|
systemActions: {},
|
||||||
playing: false,
|
playing: false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user