简体   繁体   中英

How to enable sounds for Web View in Android App Development?

I developed an Android Web App completely in a WebView.
This app opens my website and is working very perfectly.

But the only problem is: My website is integrated with Tawk.to Widget, which enables visitors to chat live with our customer care.
This widget plays sound when someone joins the conversation & replies something.

But this Android app is not playing any sound.
But the same is working well when I open my website in Mobile Browser.

Can anyone help me enable sounds for a Web App like this?

private WebView mywebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mywebView = (WebView)findViewById(R.id.webView);
    WebSettings webSettings = mywebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mywebView.loadUrl("http://getmore.tech/user/Default.aspx");
    mywebView.setWebViewClient(new WebViewClient());


}

@Override
public void onBackPressed() {
    if(mywebView.canGoBack()){
        mywebView.goBack();
    } else {
        super.onBackPressed();
    }

}

You might need to enable media playback without requiring a user gesture: webSettings.setMediaPlaybackRequiresUserGesture(false); .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM