Android WebView not stopping after user presses back

后端 未结 6 1791
傲寒
傲寒 2021-01-31 03:18

I am playing a YouTube video inside a WebView. I am able to play it, but when the person leaves the screen, I am not able to stop the audio from playing.

I tried various

6条回答
  •  不要未来只要你来
    2021-01-31 03:42

    Nothing worked for me in some or all devices. This is the exact solution I guess. Worked for me well.

    How to stop youtube video playing in Android webview?

    alternatively for API >= 11 you can use _webview.onPause(); on the activity's / fragment's onPause

    public void onPause() {
            // TODO Auto-generated method stub
            super.onPause();
            _webview.onPause();
    }
    

提交回复
热议问题