From 8ca0381e9b1b1aec5ec44c13f66ea80c3d831382 Mon Sep 17 00:00:00 2001 From: Yoan Pintas Date: Tue, 2 May 2023 15:27:43 +0200 Subject: [PATCH] Add an audio alert when the voice broadcast recording is automatically paused (#8382) --- changelog.d/8339.misc | 1 + .../app/features/voice/AbstractVoiceRecorderQ.kt | 2 +- .../recording/VoiceBroadcastRecorderQ.kt | 10 ++++++++++ vector/src/main/res/raw/vberror.ogg | Bin 0 -> 8687 bytes 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelog.d/8339.misc create mode 100644 vector/src/main/res/raw/vberror.ogg diff --git a/changelog.d/8339.misc b/changelog.d/8339.misc new file mode 100644 index 0000000000..2fed9c438b --- /dev/null +++ b/changelog.d/8339.misc @@ -0,0 +1 @@ +Add an audio alert when the voice broadcast recording is automatically paused diff --git a/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt b/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt index 0d8373870f..dec99df6b7 100644 --- a/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt +++ b/vector/src/main/java/im/vector/app/features/voice/AbstractVoiceRecorderQ.kt @@ -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 diff --git a/vector/src/main/java/im/vector/app/features/voicebroadcast/recording/VoiceBroadcastRecorderQ.kt b/vector/src/main/java/im/vector/app/features/voicebroadcast/recording/VoiceBroadcastRecorderQ.kt index b400bb5871..bf800fb173 100644 --- a/vector/src/main/java/im/vector/app/features/voicebroadcast/recording/VoiceBroadcastRecorderQ.kt +++ b/vector/src/main/java/im/vector/app/features/voicebroadcast/recording/VoiceBroadcastRecorderQ.kt @@ -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()) diff --git a/vector/src/main/res/raw/vberror.ogg b/vector/src/main/res/raw/vberror.ogg new file mode 100644 index 0000000000000000000000000000000000000000..52f9fbaef126fdef92e1dea847ce4d4c9b448ca5 GIT binary patch literal 8687 zcmeHsc|4Ts`~N))#*&6)OPQI-4APKnsb=f7`Ge3WG4QI~eOg}W z`!baEpL7W)k)!|_oC0@jF{2x;G%}{srQ!7w_zR5+jt&WpTLb5U|C%F3ga=8UQvJaZ z;vckYjZ^g2@L-Z#Tr|mNKAZ^&?p&OenH#S~Qw?uD2Vc}6*{lmiJ`O$H^)~Lf< z{P4(7|G3aCp>c4n&^5-ZEX>X5koLp5gvjuaHT0e6B}&Gt%uFrV7N#b~c1$|m&c>Y1 zGBc&Gvaqu=w?pS`=xkHlmFUO}nn0&p&`s@(P0*2qR+_O)R++=w;#oS~9R6dQnE!a5 zMQ7UnU7jt|){JdqVT+NHm`i5acta#HKt0%#W_Of#hkHOHK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