Skip to content

Commit

Permalink
removed stopMediaPlayer method call in onStop(),
Browse files Browse the repository at this point in the history
so that audio continues playing when activity in background.
if backpressed, stops mediaplayer
Signed-off-by: Giacomo Pacini <[email protected]>
  • Loading branch information
Ruggero1912 committed Mar 10, 2024
1 parent 342aaba commit fc06f5f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit fc06f5f

Please sign in to comment.