mirror of
https://github.com/element-hq/element-android
synced 2024-09-06 17:05:20 +00:00
Add an audio alert when the voice broadcast recording is automatically paused (#8382)
This commit is contained in:
parent
e37fe1f8f5
commit
8ca0381e9b
1
changelog.d/8339.misc
Normal file
1
changelog.d/8339.misc
Normal file
|
@ -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].
|
* VoiceRecorder abstraction to be used on Android versions >= [Build.VERSION_CODES.Q].
|
||||||
*/
|
*/
|
||||||
@RequiresApi(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
|
var mediaRecorder: MediaRecorder? = null
|
||||||
protected var nextOutputFile: File? = null
|
protected var nextOutputFile: File? = null
|
||||||
|
|
|
@ -18,8 +18,11 @@ package im.vector.app.features.voicebroadcast.recording
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.media.MediaRecorder
|
import android.media.MediaRecorder
|
||||||
|
import android.media.RingtoneManager
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
import im.vector.app.R
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.features.session.coroutineScope
|
import im.vector.app.features.session.coroutineScope
|
||||||
import im.vector.app.features.voice.AbstractVoiceRecorderQ
|
import im.vector.app.features.voice.AbstractVoiceRecorderQ
|
||||||
|
@ -112,6 +115,7 @@ class VoiceBroadcastRecorderQ(
|
||||||
pauseRecorder()
|
pauseRecorder()
|
||||||
stopObservingConnectionState()
|
stopObservingConnectionState()
|
||||||
recordingState = VoiceBroadcastRecorder.State.Error
|
recordingState = VoiceBroadcastRecorder.State.Error
|
||||||
|
notifyError()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pauseRecord() {
|
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) {
|
private fun onElapsedTimeUpdated(elapsedTimeMillis: Long) {
|
||||||
currentRemainingTime = if (currentMaxLength > 0 && recordingState != VoiceBroadcastRecorder.State.Idle) {
|
currentRemainingTime = if (currentMaxLength > 0 && recordingState != VoiceBroadcastRecorder.State.Idle) {
|
||||||
val currentMaxLengthMillis = TimeUnit.SECONDS.toMillis(currentMaxLength.toLong())
|
val currentMaxLengthMillis = TimeUnit.SECONDS.toMillis(currentMaxLength.toLong())
|
||||||
|
|
BIN
vector/src/main/res/raw/vberror.ogg
Normal file
BIN
vector/src/main/res/raw/vberror.ogg
Normal file
Binary file not shown.
Loading…
Reference in a new issue