mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-16 17:25:01 +01:00
avoid IllegalStateException for ChatController#stopMediaPlayer
didn't see this crash here, but it might have happened similar to b29fccac where it happened. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
bad8e2a705
commit
be5a60dc77
@ -1036,10 +1036,19 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
mediaPlayerHandler.removeCallbacksAndMessages(null)
|
mediaPlayerHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
||||||
mediaPlayer?.stop()
|
try {
|
||||||
|
mediaPlayer?.let {
|
||||||
|
if (it.isPlaying) {
|
||||||
|
it.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: IllegalStateException) {
|
||||||
|
Log.e(TAG, "mediaPlayer was not initialized", e)
|
||||||
|
} finally {
|
||||||
mediaPlayer?.release()
|
mediaPlayer?.release()
|
||||||
mediaPlayer = null
|
mediaPlayer = null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateMediaPlayerProgressBySlider(messageWithSlidedProgress: ChatMessage, progress: Int) {
|
override fun updateMediaPlayerProgressBySlider(messageWithSlidedProgress: ChatMessage, progress: Int) {
|
||||||
if (mediaPlayer != null) {
|
if (mediaPlayer != null) {
|
||||||
@ -3426,6 +3435,7 @@ class ChatController(args: Bundle) :
|
|||||||
private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50
|
private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50
|
||||||
private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}"
|
private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}"
|
||||||
private const val VOICE_MESSAGE_FILE_SUFFIX = ".mp3"
|
private const val VOICE_MESSAGE_FILE_SUFFIX = ".mp3"
|
||||||
|
|
||||||
// Samplingrate 22050 was chosen because somehow 44100 failed to playback on safari when recorded on android.
|
// Samplingrate 22050 was chosen because somehow 44100 failed to playback on safari when recorded on android.
|
||||||
// Please test with firefox, chrome, safari and mobile clients if changing anything regarding the sound.
|
// Please test with firefox, chrome, safari and mobile clients if changing anything regarding the sound.
|
||||||
private const val VOICE_MESSAGE_SAMPLING_RATE = 22050
|
private const val VOICE_MESSAGE_SAMPLING_RATE = 22050
|
||||||
|
Loading…
Reference in New Issue
Block a user