android: fix crash when playing recorded voice message (#3325)

* android: fix crash when playing recorded voice message

* better
This commit is contained in:
Stanislav Dmitrenko
2023-11-11 00:09:19 +08:00
committed by GitHub
parent 8d891005d9
commit e7d6ed66da
2 changed files with 10 additions and 4 deletions
@@ -284,9 +284,11 @@ actual object AudioPlayer: AudioPlayerInterface {
kotlin.runCatching {
helperPlayer.setDataSource(unencryptedFilePath)
helperPlayer.prepare()
helperPlayer.start()
helperPlayer.stop()
res = helperPlayer.duration
if (helperPlayer.duration <= 0) {
Log.e(TAG, "Duration of audio is incorrect: ${helperPlayer.duration}")
} else {
res = helperPlayer.duration
}
helperPlayer.reset()
}
return res