Automatically play next music

This commit is contained in:
Pierre HUBERT 2022-03-24 10:59:57 +01:00
parent fb573cfc7c
commit 0cdb9a6c27

View File

@ -50,8 +50,11 @@ class _MusicPlayerState extends State<MusicPlayer> {
_playNext();
});
audioPlayer.onPlayerStateChanged
.listen((s) => setState(() => {_playerState = s}));
audioPlayer.onPlayerStateChanged.listen((s) => setState(() {
_playerState = s;
if (_playerState == PlayerState.COMPLETED) _playNext();
}));
}
Future<void> _play() async {