Skip to content

Commit 6bf46fe

Browse files
committed
Fix audioRecorder initialization exception in changeFilePath function call
1 parent e4e80d4 commit 6bf46fe

File tree

1 file changed

+2
-2
lines changed
  • android-wave-recorder/src/main/java/com/github/squti/androidwaverecorder

1 file changed

+2
-2
lines changed

android-wave-recorder/src/main/java/com/github/squti/androidwaverecorder/WaveRecorder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class WaveRecorder {
389389
* Calling this method while still recording throws an IllegalStateException
390390
*/
391391
fun changeFilePath(newFilePath: String) {
392-
if (audioRecorder.recordingState == AudioRecord.RECORDSTATE_RECORDING)
392+
if (isAudioRecorderInitialized() && audioRecorder.recordingState == AudioRecord.RECORDSTATE_RECORDING)
393393
throw IllegalStateException("Cannot change filePath when still recording.")
394394
else
395395
filePath = newFilePath
@@ -399,7 +399,7 @@ class WaveRecorder {
399399
* Calling this method while still recording throws an IllegalStateException
400400
*/
401401
fun changeFilePath(newFileUri: Uri) {
402-
if (audioRecorder.recordingState == AudioRecord.RECORDSTATE_RECORDING)
402+
if (isAudioRecorderInitialized() && audioRecorder.recordingState == AudioRecord.RECORDSTATE_RECORDING)
403403
throw IllegalStateException("Cannot change filePath when still recording.")
404404
else
405405
fileUri = newFileUri

0 commit comments

Comments
 (0)