Attempt to automatically play next music

This commit is contained in:
Pierre HUBERT 2022-03-24 11:47:27 +01:00
parent aa3f743eee
commit b11eb6063c

View File

@ -59,7 +59,15 @@ class _MusicPlayerState extends State<MusicPlayer> {
autoPlay: true,
showControls: false);
_videoPlayerController!.addListener(() => setState(() {}));
_videoPlayerController!.addListener(() => setState(() {
// Automatically play next music if required
if (_videoPlayerController != null && _duration == _position) {
if (_duration?.inSeconds == _position?.inSeconds &&
(_duration?.inSeconds ?? 0) > 0) {
_playNext();
}
}
}));
}
}