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(); _playNext();
}); });
audioPlayer.onPlayerStateChanged audioPlayer.onPlayerStateChanged.listen((s) => setState(() {
.listen((s) => setState(() => {_playerState = s})); _playerState = s;
if (_playerState == PlayerState.COMPLETED) _playNext();
}));
} }
Future<void> _play() async { Future<void> _play() async {