previous method

Future<bool> previous({
  1. bool keepLoopMode = true,
})

keepLoopMode: if true : the loopMode is .single => execute previous() will keep it .single if false : the loopMode is .single => execute previous() will set it as .playlist

Implementation

Future<bool> previous({bool keepLoopMode = true}) async {
  if (_playlist != null) {
    // more than 5 sec played, go back to the start of audio
    /*if (_currentPosition.valueOrNull != null &&
        _currentPosition.valueOrNull!.inSeconds >= 5) {
      await seek(Duration.zero, force: true);
    } else*/
    if (_playlist!.hasPrev()) {
      if (!keepLoopMode) {
        if (loopMode.value == LoopMode.single) {
          await setLoopMode(LoopMode.playlist);
        }
      }
      _playlist!.selectPrev();
      await _openPlaylistCurrent();
      return true;
    } else if (_playlist!.playlistIndex == 0) {
      await seek(Duration.zero);
      return true;
    }
  }

  return false;
}