Android Question HTML5 audio in a webview

yo3ggx

Active Member
Licensed User
Longtime User
Hello.
I have an application that connects to a web page using a hidden webview and then send different javascript commands. That web page, when connected, automatically starts streaming audio.
On some Android devices (different Android versions from 5 to and including 13), audio is played, on others (ex, a Pixel 5A with Android 13) don't.

I try to force audio start using the following javascript function, that works on a Windows computer with Chrome:
B4X:
    Dim js As String = $"function audio_start()
     {
      if (!document.ct) document.ct= new webkitAudioContext();
      var s = document.ct.createBufferSource();
      s.connect(document.ct.destination);
      document.ct.resume();
      try { s.start(0); } catch(e) { s.noteOn(0);}
       i}
"$
   
    WebView1Extras.executeJavascript(WebView1, js)

Unfortunately in the Webview does not have any effect .
Any suggestions on how can I start the sound in the WebView?
 
Top