play method

void play()

Implementation

void play() async {
  audioPlayer ??= AudioPlayer();
  _decideSource();
  listenOnDurationChanged();
  if (playerState == PlayerState.playing) {
    await audioPlayer?.pause();
  } else if (playerState == PlayerState.paused) {
    await audioPlayer?.resume();
  } else if (_reachedEnd && repeat || !_reachedEnd && !isPlaying) {
    await audioPlayer?.play(source!);
  }
  togglePlay();
  if (_reachedEnd && !repeat) isPlaying = false;
  _reachedEnd = false;
  notifyListeners();
}