From b11eb6063cf34656a6ace9d0fa6e43d56c639985 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Thu, 24 Mar 2022 11:47:27 +0100 Subject: [PATCH] Attempt to automatically play next music --- lib/ui/music_player.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ui/music_player.dart b/lib/ui/music_player.dart index 1ae8fc8..0240357 100644 --- a/lib/ui/music_player.dart +++ b/lib/ui/music_player.dart @@ -59,7 +59,15 @@ class _MusicPlayerState extends State { 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(); + } + } + })); } }