Add an audio alert when the voice broadcast recording is automatically paused (#8382)

This commit is contained in:
Yoan Pintas 2023-05-02 15:27:43 +02:00 committed by GitHub
parent e37fe1f8f5
commit 8ca0381e9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

1
changelog.d/8339.misc Normal file
View File

@ -0,0 +1 @@
Add an audio alert when the voice broadcast recording is automatically paused

View File

@ -28,7 +28,7 @@ import java.io.File
* VoiceRecorder abstraction to be used on Android versions >= [Build.VERSION_CODES.Q].
*/
@RequiresApi(Build.VERSION_CODES.Q)
abstract class AbstractVoiceRecorderQ(private val context: Context) : AbstractVoiceRecorder(context) {
abstract class AbstractVoiceRecorderQ(protected val context: Context) : AbstractVoiceRecorder(context) {
var mediaRecorder: MediaRecorder? = null
protected var nextOutputFile: File? = null

View File

@ -18,8 +18,11 @@ package im.vector.app.features.voicebroadcast.recording
import android.content.Context
import android.media.MediaRecorder
import android.media.RingtoneManager
import android.net.Uri
import android.os.Build
import androidx.annotation.RequiresApi
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.features.session.coroutineScope
import im.vector.app.features.voice.AbstractVoiceRecorderQ
@ -112,6 +115,7 @@ class VoiceBroadcastRecorderQ(
pauseRecorder()
stopObservingConnectionState()
recordingState = VoiceBroadcastRecorder.State.Error
notifyError()
}
override fun pauseRecord() {
@ -209,6 +213,12 @@ class VoiceBroadcastRecorderQ(
}
}
private fun notifyError() {
val ringtoneUri = Uri.parse("android.resource://${context.packageName}/${R.raw.vberror}")
val ringtone = RingtoneManager.getRingtone(context, ringtoneUri)
ringtone?.play()
}
private fun onElapsedTimeUpdated(elapsedTimeMillis: Long) {
currentRemainingTime = if (currentMaxLength > 0 && recordingState != VoiceBroadcastRecorder.State.Idle) {
val currentMaxLengthMillis = TimeUnit.SECONDS.toMillis(currentMaxLength.toLong())

Binary file not shown.