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
You can do it using the method onPause() of your Activity :
onPause()
Activity
@override public void onPause() { super.onPause(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webview.onPause(); } }
adding a validation for use in API >= 11 (Honeycomb)