android: fix crash when playing recorded voice message (#3325)
* android: fix crash when playing recorded voice message * better
This commit is contained in:
parent
8d891005d9
commit
e7d6ed66da
@ -284,9 +284,11 @@ actual object AudioPlayer: AudioPlayerInterface {
|
||||
kotlin.runCatching {
|
||||
helperPlayer.setDataSource(unencryptedFilePath)
|
||||
helperPlayer.prepare()
|
||||
helperPlayer.start()
|
||||
helperPlayer.stop()
|
||||
if (helperPlayer.duration <= 0) {
|
||||
Log.e(TAG, "Duration of audio is incorrect: ${helperPlayer.duration}")
|
||||
} else {
|
||||
res = helperPlayer.duration
|
||||
}
|
||||
helperPlayer.reset()
|
||||
}
|
||||
return res
|
||||
|
@ -776,7 +776,11 @@ fun ComposeView(
|
||||
.collect {
|
||||
when(it) {
|
||||
is RecordingState.Started -> onAudioAdded(it.filePath, it.progressMs, false)
|
||||
is RecordingState.Finished -> onAudioAdded(it.filePath, it.durationMs, true)
|
||||
is RecordingState.Finished -> if (it.durationMs > 300) {
|
||||
onAudioAdded(it.filePath, it.durationMs, true)
|
||||
} else {
|
||||
cancelVoice()
|
||||
}
|
||||
is RecordingState.NotStarted -> {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user