WebView功能的嵌入式视频播放的背景 [英] WebView with embedded video plays in background

查看:388
本文介绍了WebView功能的嵌入式视频播放的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有承载嵌入式视频一个web视图。当我降低web视图视频的声音不断播放。我怎样才能停止?我曾尝试 webview.destroy(); 但力关闭应用程序,当我试图再次打开的WebView

I have a WebView that hosts embedded videos. when I degrade the Webview the sound of the video keeps on playing. How can I stop this? I did try webview.destroy(); but that force closes the application when I try to open the WebView again.

推荐答案

您必须调用web视图的<一个href="http://developer.android.com/reference/android/webkit/WebView.html#onPause%28%29"><$c$c>onPause()和<一href="http://developer.android.com/reference/android/webkit/WebView.html#onResume%28%29"><$c$c>onResume()方法用于这一目的。你通常做你的活动的的onPause() onResume(),但你也可以做到这一点,只要你是隐藏web视图以某种方式,其内容也768,16停止做什么他们都在做,比如运行Javascript或播放HTML5视频。

You must call the WebView's onPause() and onResume() methods for that purpose. You typically do it on your Activity's onPause() and onResume() but you can also do it whenever you are hiding the WebView in some way and its contents shoud also stop doing whatever they are doing, such as running Javascript or playing an HTML5 video.

如果您之前的11需要API等级这些方法,你可以使用反射像这样: WebView.class.getMethod(的onPause)调用(myWebView);

If you need these methods in API levels prior to 11, you can use reflection like this: WebView.class.getMethod("onPause").invoke(myWebView);

这篇关于WebView功能的嵌入式视频播放的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆