Wednesday, 29 September 2021

WebView change audio output device

How can I change the audio output of WebView from loudspeaker to earpiece? I tried this code, but it is not working

    private fun setupAudio() {
        val am = getSystemService(AUDIO_SERVICE) as AudioManager
        am.mode = AudioManager.MODE_IN_COMMUNICATION
        am.stopBluetoothSco()
        am.isSpeakerphoneOn=false
        Log.e("Foo","Current mode is ${am.mode}")
    }

Have permission

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />


from WebView change audio output device

No comments:

Post a Comment