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 {
|
kotlin.runCatching {
|
||||||
helperPlayer.setDataSource(unencryptedFilePath)
|
helperPlayer.setDataSource(unencryptedFilePath)
|
||||||
helperPlayer.prepare()
|
helperPlayer.prepare()
|
||||||
helperPlayer.start()
|
if (helperPlayer.duration <= 0) {
|
||||||
helperPlayer.stop()
|
Log.e(TAG, "Duration of audio is incorrect: ${helperPlayer.duration}")
|
||||||
|
} else {
|
||||||
res = helperPlayer.duration
|
res = helperPlayer.duration
|
||||||
|
}
|
||||||
helperPlayer.reset()
|
helperPlayer.reset()
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
@ -776,7 +776,11 @@ fun ComposeView(
|
|||||||
.collect {
|
.collect {
|
||||||
when(it) {
|
when(it) {
|
||||||
is RecordingState.Started -> onAudioAdded(it.filePath, it.progressMs, false)
|
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 -> {}
|
is RecordingState.NotStarted -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user