File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -589,11 +589,7 @@ class PlayerControlButtons extends StatelessWidget {
589589 color: audioHandler.hasPrevious ? primaryColor : secondaryColor,
590590 ),
591591 iconSize: iconSize / 1.7 ,
592- onPressed:
593- () =>
594- repeatNotifier.value == AudioServiceRepeatMode .one
595- ? audioHandler.playAgain ()
596- : audioHandler.skipToPrevious (),
592+ onPressed: () => audioHandler.skipToPrevious (),
597593 splashColor: Colors .transparent,
598594 );
599595 },
Original file line number Diff line number Diff line change @@ -937,6 +937,16 @@ class MusifyAudioHandler extends BaseAudioHandler {
937937 @override
938938 Future <void > skipToPrevious () async {
939939 try {
940+ // Get current playback position
941+ final currentPosition = audioPlayer.position;
942+
943+ // If the song has been playing for more than 3 seconds, restart it
944+ if (currentPosition.inSeconds > 3 ) {
945+ await audioPlayer.seek (Duration .zero);
946+ return ;
947+ }
948+
949+ // Otherwise, go to previous song
940950 if (_currentQueueIndex > 0 ) {
941951 await _playFromQueue (_currentQueueIndex - 1 );
942952 } else if (_historyList.isNotEmpty) {
You can’t perform that action at this time.
0 commit comments