mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
added a boolean backgroundPlayAllowed, so that startPlayback continues only when that parameter is true. It is set to true only when it is called to play a consecutive voice message.
Signed-off-by: Giacomo Pacini <giacomopacini98@gmail.com>
This commit is contained in:
parent
7542b310e0
commit
09925699b7
@ -1205,7 +1205,7 @@ class ChatActivity :
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpWaveform(message: ChatMessage, thenPlay: Boolean = true) {
|
||||
private fun setUpWaveform(message: ChatMessage, thenPlay: Boolean = true, backgroundPlayAllowed : Boolean = false) {
|
||||
val filename = message.selectedIndividualHashMap!!["name"]
|
||||
val file = File(context.cacheDir, filename!!)
|
||||
if (file.exists() && message.voiceMessageFloatArray == null) {
|
||||
@ -1216,11 +1216,11 @@ class ChatActivity :
|
||||
appPreferences.saveWaveFormForFile(filename, r.toTypedArray())
|
||||
message.voiceMessageFloatArray = r
|
||||
withContext(Dispatchers.Main) {
|
||||
startPlayback(message, thenPlay)
|
||||
startPlayback(message, thenPlay, backgroundPlayAllowed)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
startPlayback(message, thenPlay)
|
||||
startPlayback(message, thenPlay, backgroundPlayAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1614,14 +1614,14 @@ class ChatActivity :
|
||||
}
|
||||
}
|
||||
|
||||
private fun startPlayback(message: ChatMessage, doPlay: Boolean = true) {
|
||||
//if (!active) {
|
||||
private fun startPlayback(message: ChatMessage, doPlay: Boolean = true, backgroundPlayAllowed : Boolean = false) {
|
||||
if (!active && !backgroundPlayAllowed) {
|
||||
// don't begin to play voice message if screen is not visible anymore.
|
||||
// this situation might happen if file is downloading but user already left the chatview.
|
||||
// If user returns to chatview, the old chatview instance is not attached anymore
|
||||
// and he has to click the play button again (which is considered to be okay)
|
||||
// return
|
||||
//}
|
||||
return
|
||||
}
|
||||
|
||||
initMediaPlayer(message)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user