finish recording gracefully when audio focus is lost
if something else grabs focus mid-recording (phone call, etc), stop the recording and keep the partial result in preview state instead of silently recording garbage Signed-off-by: vmfunc <celeste@linux.com>
This commit is contained in:
parent
1412dd789e
commit
0cbe326db9
2 changed files with 30 additions and 1 deletions
|
|
@ -249,7 +249,11 @@ class DefaultVoiceMessageComposerPresenter(
|
|||
|
||||
private fun CoroutineScope.startRecording() = launch {
|
||||
try {
|
||||
audioFocus.requestAudioFocus(AudioFocusRequester.RecordVoiceMessage) {}
|
||||
audioFocus.requestAudioFocus(AudioFocusRequester.RecordVoiceMessage) {
|
||||
// something else grabbed focus (phone call, etc) - finish gracefully
|
||||
// so the user keeps their partial recording
|
||||
sessionCoroutineScope.finishRecording()
|
||||
}
|
||||
voiceRecorder.startRecord()
|
||||
} catch (e: SecurityException) {
|
||||
audioFocus.releaseAudioFocus()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue