stopPlayAudio method

dynamic stopPlayAudio()

function for stop playing audio

Implementation

stopPlayAudio() async {
  try {
    if (player?.state == PlayerState.playing) {
      console(logs: "audio stop, messageID: ${_audioPlayInfo?.msgID}");
      await player?.stop();
      updateCurrentAudioPlayInfo(isCompleted: false, progress: _currentPlayAudioInfo?.progress ?? 0, isPaused: true);
      player!.seek(Duration.zero);
      _audioPlayInfo = null;
      _currentPlayAudioInfo = null;
    } else {
      console(logs: "current state is ${player?.state.name}, no need to stop");
    }
  } catch (e) {
    if (kDebugMode) {
      print(e.toString());
    }
  }
}