From 22cbe974448ff0dfb7ce20e92bfd2cee31086ec3 Mon Sep 17 00:00:00 2001 From: Valeri Gokadze Date: Wed, 25 Dec 2024 11:22:18 +0400 Subject: [PATCH] feat: enhance audio playback controls with repeat mode functionality --- lib/screens/now_playing_page.dart | 9 ++++++++- lib/services/audio_service.dart | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/screens/now_playing_page.dart b/lib/screens/now_playing_page.dart index c67c028e..6ed8d1d0 100644 --- a/lib/screens/now_playing_page.dart +++ b/lib/screens/now_playing_page.dart @@ -408,7 +408,14 @@ class NowPlayingPage extends StatelessWidget { ), iconSize: iconSize, onPressed: () { - repeatNotifier.value = AudioServiceRepeatMode.all; + final _isSingleSongPlaying = + activePlaylist['list'].isEmpty; + repeatNotifier.value = _isSingleSongPlaying + ? AudioServiceRepeatMode.one + : AudioServiceRepeatMode.all; + + if (repeatNotifier.value == AudioServiceRepeatMode.one) + audioHandler.setRepeatMode(repeatNotifier.value); }, ); }, diff --git a/lib/services/audio_service.dart b/lib/services/audio_service.dart index 00777f1e..6c6dc8e2 100644 --- a/lib/services/audio_service.dart +++ b/lib/services/audio_service.dart @@ -375,6 +375,7 @@ class MusifyAudioHandler extends BaseAudioHandler { @override Future setRepeatMode(AudioServiceRepeatMode repeatMode) async { + // we use this only when we want to loop single song await audioPlayer.setLoopMode( repeatMode == AudioServiceRepeatMode.all ? LoopMode.one : LoopMode.off, );