mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
Merge pull request #5060 from nextcloud/backport/5053/stable-21.1
[stable-21.1] Better null and error handling when playing voice messages
This commit is contained in:
commit
d1b3e7cb4d
@ -183,19 +183,26 @@ class MediaPlayerManager : LifecycleAwareManager {
|
||||
continue
|
||||
}
|
||||
|
||||
if (mediaPlayer != null && mediaPlayer?.isPlaying == true) {
|
||||
val pos = mediaPlayer!!.currentPosition
|
||||
mediaPlayer?.let { player ->
|
||||
try {
|
||||
if (!player.isPlaying) return@let
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.e(TAG, "Seekbar updated during an improper state: $e")
|
||||
return@let
|
||||
}
|
||||
|
||||
val pos = player.currentPosition
|
||||
mediaPlayerPosition = pos
|
||||
val progress = (pos.toFloat() / mediaPlayerDuration) * DIVIDER
|
||||
val progressI = ceil(progress).toInt()
|
||||
val seconds = (pos / ONE_SEC)
|
||||
_mediaPlayerSeekBarPosition.emit(progressI)
|
||||
currentCycledMessage?.let {
|
||||
it.isPlayingVoiceMessage = true
|
||||
it.voiceMessageSeekbarProgress = progressI
|
||||
it.voiceMessagePlayedSeconds = seconds
|
||||
if (progressI >= IS_PLAYED_CUTOFF) it.wasPlayedVoiceMessage = true
|
||||
_mediaPlayerSeekBarPositionMsg.emit(it)
|
||||
currentCycledMessage?.let { msg ->
|
||||
msg.isPlayingVoiceMessage = true
|
||||
msg.voiceMessageSeekbarProgress = progressI
|
||||
msg.voiceMessagePlayedSeconds = seconds
|
||||
if (progressI >= IS_PLAYED_CUTOFF) msg.wasPlayedVoiceMessage = true
|
||||
_mediaPlayerSeekBarPositionMsg.emit(msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 10 errors and 99 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 10 errors and 100 warnings</span>
|
||||
|
Loading…
Reference in New Issue
Block a user