@@ -332,7 +332,9 @@ class MusifyAudioHandler extends BaseAudioHandler {
332332 Future <void > skipToNext () async {
333333 if (repeatNotifier.value == AudioServiceRepeatMode .one) {
334334 // If repeat mode is set to repeat the current song, play the current song again
335- await skipToSong (activeSongId);
335+ if (audioPlayer.playing) {
336+ await audioPlayer.seek (Duration .zero);
337+ }
336338 } else if (! hasNext && repeatNotifier.value == AudioServiceRepeatMode .all) {
337339 // If repeat mode is set to repeat the playlist, start from the beginning
338340 await skipToSong (0 );
@@ -344,15 +346,24 @@ class MusifyAudioHandler extends BaseAudioHandler {
344346 } else if (hasNext) {
345347 // If there is a next song, skip to the next song
346348 await skipToSong (activeSongId + 1 );
347- } else {
348- // Handle end of playlist without repeat
349- await audioPlayer.stop ();
350349 }
351350 }
352351
353352 @override
354353 Future <void > skipToPrevious () async {
355- await skipToSong (activeSongId - 1 );
354+ if (repeatNotifier.value == AudioServiceRepeatMode .one) {
355+ // If repeat mode is set to repeat the current song, play the current song again
356+ if (audioPlayer.playing) {
357+ await audioPlayer.seek (Duration .zero);
358+ }
359+ } else if (! hasPrevious &&
360+ repeatNotifier.value == AudioServiceRepeatMode .all) {
361+ // If repeat mode is set to repeat the playlist, start from the end
362+ await skipToSong (activePlaylist['list' ].length - 1 );
363+ } else if (hasPrevious) {
364+ // If there is a previous song, skip to the previous song
365+ await skipToSong (activeSongId - 1 );
366+ }
356367 }
357368
358369 @override
@@ -362,6 +373,13 @@ class MusifyAudioHandler extends BaseAudioHandler {
362373 await audioPlayer.setShuffleModeEnabled (shuffleEnabled);
363374 }
364375
376+ @override
377+ Future <void > setRepeatMode (AudioServiceRepeatMode repeatMode) async {
378+ await audioPlayer.setLoopMode (
379+ repeatMode == AudioServiceRepeatMode .all ? LoopMode .one : LoopMode .off,
380+ );
381+ }
382+
365383 void changeSponsorBlockStatus () {
366384 sponsorBlockSupport.value = ! sponsorBlockSupport.value;
367385 addOrUpdateData (
0 commit comments