mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 21:45:42 +03:00
Merge pull request #2771 from nextcloud/bugfix/noid/fixNpeVoiceMessagePlayback
avoid NPE for voice message playback
This commit is contained in:
commit
989e3fe211
1 changed files with 19 additions and 19 deletions
|
@ -975,25 +975,27 @@ class ChatController(args: Bundle) :
|
|||
|
||||
initMediaPlayer(message)
|
||||
|
||||
if (!mediaPlayer!!.isPlaying) {
|
||||
mediaPlayer!!.start()
|
||||
}
|
||||
|
||||
mediaPlayerHandler = Handler()
|
||||
activity?.runOnUiThread(object : Runnable {
|
||||
override fun run() {
|
||||
if (mediaPlayer != null) {
|
||||
val currentPosition: Int = mediaPlayer!!.currentPosition / VOICE_MESSAGE_SEEKBAR_BASE
|
||||
message.voiceMessagePlayedSeconds = currentPosition
|
||||
adapter?.update(message)
|
||||
}
|
||||
mediaPlayerHandler.postDelayed(this, SECOND)
|
||||
mediaPlayer?.let {
|
||||
if (!it.isPlaying) {
|
||||
it.start()
|
||||
}
|
||||
})
|
||||
|
||||
message.isDownloadingVoiceMessage = false
|
||||
message.isPlayingVoiceMessage = true
|
||||
adapter?.update(message)
|
||||
mediaPlayerHandler = Handler()
|
||||
activity?.runOnUiThread(object : Runnable {
|
||||
override fun run() {
|
||||
if (mediaPlayer != null) {
|
||||
val currentPosition: Int = mediaPlayer!!.currentPosition / VOICE_MESSAGE_SEEKBAR_BASE
|
||||
message.voiceMessagePlayedSeconds = currentPosition
|
||||
adapter?.update(message)
|
||||
}
|
||||
mediaPlayerHandler.postDelayed(this, SECOND)
|
||||
}
|
||||
})
|
||||
|
||||
message.isDownloadingVoiceMessage = false
|
||||
message.isPlayingVoiceMessage = true
|
||||
adapter?.update(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pausePlayback(message: ChatMessage) {
|
||||
|
@ -1031,8 +1033,6 @@ class ChatController(args: Bundle) :
|
|||
Log.e(TAG, "failed to initialize mediaPlayer", e)
|
||||
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "mediaPlayer was not null. This should not happen!")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue