安卓6.0使用webview展示网页时,其他文本图片信息正常,但是无法展示网页中的视频。
并在视频播放的位置提示无法加载插件。(手机安装flash了呀- -)
看了网上一些解决webview解决视频播放问题的帖子。
比如在manifest中对应的activity中添加android:hardwareAccelerated="true"属性,
在java文件中,设置webSettings.setDomStorageEnabled(true);和webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);等属性均解决问题。。。。
使用webView .getSettings().setPluginsEnabled(true);时爆红。
咱们先看下源码里面怎么说的:
/**
* Sets whether the WebView should enable plugins. The default is false.
*
* @param flag true if plugins should be enabled
* @deprecated This method has been deprecated in favor of
* {@link #setPluginState}
* @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
*/
@SystemApi
@Deprecated
public abstract void setPluginsEnabled(boolean flag);
意思是说这个过期了,建议使用setPluginState这个方法。
然后接着看setPluginState方法:
/**
* Tells the WebView to enable, disable, or have plugins on demand. On
* demand mode means that if a plugin exists that can handle the embedded
* content, a placeholder icon will be shown instead of the plugin. When
* the placeholder is clicked, the plugin will be enabled. The default is
* {@link PluginState#OFF}.
*
* @param state a PluginState value
* @deprecated Plugins will not be supported in future, and should not be used.
*/
@Deprecated
public abstract void setPluginState(PluginState state);
意思是说这个也过期了,因为Plugins 将来就不支持了,所以最好不要用。
明白了吗?
建议使用腾讯x5 内核来做,因为qq和微信都是用的这个,虽然也有坑,但是在多媒体播放方面做得比较好,Android原生webview在这方面比较差