Add an audio alert when the voice broadcast recording is automatically paused (#8382)
This commit is contained in:
parent
e37fe1f8f5
commit
8ca0381e9b
|
@ -0,0 +1 @@
|
|||
Add an audio alert when the voice broadcast recording is automatically paused
|
|
@ -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
|
||||
|
|
|
@ -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.
Loading…
Reference in New Issue