Issue
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" />
Solution
I got it working, the trick is to call setupAudio()
function after the playback starts.
Answered By - Sujith Manjavana
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.