Merge pull request #2771 from nextcloud/bugfix/noid/fixNpeVoiceMessagePlayback

avoid NPE for voice message playback
This commit is contained in:
Marcel Hibbe 2023-02-16 15:20:10 +01:00 committed by GitHub
commit 989e3fe211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -975,8 +975,9 @@ class ChatController(args: Bundle) :
initMediaPlayer(message)
if (!mediaPlayer!!.isPlaying) {
mediaPlayer!!.start()
mediaPlayer?.let {
if (!it.isPlaying) {
it.start()
}
mediaPlayerHandler = Handler()
@ -995,6 +996,7 @@ class ChatController(args: Bundle) :
message.isPlayingVoiceMessage = true
adapter?.update(message)
}
}
private fun pausePlayback(message: ChatMessage) {
if (mediaPlayer!!.isPlaying) {
@ -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!")
}
}