onAudioReplacedAt method

void onAudioReplacedAt(
  1. int index,
  2. bool keepPlayingPositionIfCurrent
)

Implementation

void onAudioReplacedAt(int index, bool keepPlayingPositionIfCurrent) {
  assetsAudioPlayer._updatePlaylistIndexes();
  if (assetsAudioPlayer._playlist!.playlistIndex == index) {
    final currentPosition = assetsAudioPlayer.currentPosition.valueOrNull;
    final isPlaying = assetsAudioPlayer.isPlaying.valueOrNull ?? false;
    //print('onAudioReplacedAt/ currentPosition : $currentPosition');
    if (keepPlayingPositionIfCurrent && currentPosition != null) {
      assetsAudioPlayer._openPlaylistCurrent(
          seek: currentPosition, autoStart: isPlaying);
    } else {
      assetsAudioPlayer._openPlaylistCurrent(autoStart: isPlaying);
    }
  }
}