Search code examples
androidurlwebviewandroid-webviewmp3

Play mp3 from mp3 url automatically in Webview android


I have a mp3 url which works perfectly. It also plays the song automatically when opened in Chrome PC version. But when the same link is open in Webview android I need to provided gesture to play.(I have enabled Javascript)


Solution

  • This was done by the function of webview.

     webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
     webview.getSettings().setJavaScriptEnabled(true);
    

    Done by try and error. :)