From 0cdb9a6c27aaec149e869cc7d56274c11240cb58 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Thu, 24 Mar 2022 10:59:57 +0100 Subject: [PATCH] Automatically play next music --- lib/ui/music_player.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ui/music_player.dart b/lib/ui/music_player.dart index 8d00b4a..f4a0fd8 100644 --- a/lib/ui/music_player.dart +++ b/lib/ui/music_player.dart @@ -50,8 +50,11 @@ class _MusicPlayerState extends State { _playNext(); }); - audioPlayer.onPlayerStateChanged - .listen((s) => setState(() => {_playerState = s})); + audioPlayer.onPlayerStateChanged.listen((s) => setState(() { + _playerState = s; + + if (_playerState == PlayerState.COMPLETED) _playNext(); + })); } Future _play() async {