Element Call: add delay before selecting the default audio device (#4854)
This commit is contained in:
parent
b1c33063b4
commit
bd22b58c7b
1 changed files with 6 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
|
|
@ -26,6 +27,7 @@ import kotlinx.serialization.json.Json
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manages the audio devices for a WebView.
|
* This class manages the audio devices for a WebView.
|
||||||
|
|
@ -221,6 +223,10 @@ class WebViewAudioManager(
|
||||||
},
|
},
|
||||||
onAudioPlaybackStarted = {
|
onAudioPlaybackStarted = {
|
||||||
coroutineScope.launch(Dispatchers.Main) {
|
coroutineScope.launch(Dispatchers.Main) {
|
||||||
|
// Even with the callback, it seems like starting the audio takes a bit on the webview side,
|
||||||
|
// so we add an extra delay here to make sure it's ready
|
||||||
|
delay(500.milliseconds)
|
||||||
|
|
||||||
// Calling this ahead of time makes the default audio device to not use the right audio stream
|
// Calling this ahead of time makes the default audio device to not use the right audio stream
|
||||||
setAvailableAudioDevices()
|
setAvailableAudioDevices()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue