From b44641c0c7f758a36b7ca71e3aec6bd67e78398f Mon Sep 17 00:00:00 2001 From: Giacomo Pacini Date: Sun, 10 Mar 2024 11:23:52 +0100 Subject: [PATCH] removed stopMediaPlayer method call in onStop(), so that audio continues playing when activity in background. if backpressed, stops mediaplayer Signed-off-by: Giacomo Pacini --- .../main/java/com/nextcloud/talk/chat/ChatActivity.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 77ec8f886..bde34e21a 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -405,6 +405,9 @@ class ChatActivity : private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { + if (currentlyPlayedVoiceMessage != null) { + stopMediaPlayer(currentlyPlayedVoiceMessage!!) + } val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java) intent.putExtras(Bundle()) startActivity(intent) @@ -558,9 +561,10 @@ class ChatActivity : if (mediaRecorderState == MediaRecorderState.RECORDING) { stopAudioRecording() } - if (currentlyPlayedVoiceMessage != null) { - stopMediaPlayer(currentlyPlayedVoiceMessage!!) - } + //if (currentlyPlayedVoiceMessage != null) { + // stopMediaPlayer(currentlyPlayedVoiceMessage!!) + //} this is done also in onDestroy, + // it is better to continue audio playback when the activity is not visible but still open val text = binding.messageInputView.messageInput.text.toString() val cursor = binding.messageInputView.messageInput.selectionStart val previous = context.getSharedPreferences(localClassName, MODE_PRIVATE).getString(roomToken, "null")