Skip to content

Commit

Permalink
fix: IllegalStateException in audio player
Browse files Browse the repository at this point in the history
  • Loading branch information
criticalAY committed Aug 17, 2024
1 parent f0e5c32 commit 35d75af
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,14 @@ class AudioRecordingController(

fun toggleToRecorder() {
Timber.i("recorder requested")
if (audioPlayer!!.isPlaying) {
audioPlayer?.stop()
try {
audioPlayer?.let { player ->
if (player.isPlaying) {
player.stop()
}
}
} catch (e: IllegalStateException) {
Timber.w(e, "MediaPlayer is not in a valid state to check if it's playing")
}
controlAudioRecorder()
}
Expand Down

0 comments on commit 35d75af

Please sign in to comment.