Skip to content

Commit

Permalink
feat: enhance audio playback controls with repeat mode functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Dec 25, 2024
1 parent 4b18c31 commit 22cbe97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/screens/now_playing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
);
},
Expand Down
1 change: 1 addition & 0 deletions lib/services/audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ class MusifyAudioHandler extends BaseAudioHandler {

@override
Future<void> 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,
);
Expand Down

0 comments on commit 22cbe97

Please sign in to comment.