Reputation: 37579
I have a webview that it is showing a video. I want that when the activity onpauses the video stop playing audio and when the activity resumes the video must resume playing audio.
tryed with webView.onPause()
but does not work. audio is still playing even with the device locked or with the app closed.... (lol)
exists a real way to pause audio playback of a video inside a webview?
thanks
Upvotes: 2
Views: 2069
Reputation: 4497
To me, I have to interject to HTML code to pause the video element in HTML file.
Link util to interject java to HTML: https://github.com/mttdat/utils/blob/master/utils/src/main/java/mttdat/utils/WebViewUtils.java
How to use in the activity (Java):
How the HTML looks like:
Upvotes: 1
Reputation: 126445
You can do it by using the method onPause()
of the of WebView
when is executed the method onPause()
of your Activity
@override
public void onPause() {
super.onPause();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
webview.onPause();
}
}
it works for API >= 11 (Honeycomb
)
Upvotes: -1