我在 Html5 中有 Video 标签,它需要从 android webview 的 assets 文件夹中播放本地视频,但是单击播放按钮时我无法播放视频,我使用的是 android 3.1 版本,并且在清单中添加了硬件加速,我肯定错过了一些东西,请提供一些想法。下面是代码
webPage.setWebChromeClient(chromeClient);
WebViewClient webViewClient = new WebViewClient();
webPage.setWebViewClient(webViewClient);
webPage.getSettings().setAllowFileAccess(true);
webPage.getSettings().setDomStorageEnabled(true);
webPage.getSettings().setJavaScriptEnabled(true);
webPage.getSettings().setPluginState(WebSettings.PluginState.ON);
webPage.getSettings().setPluginsEnabled(true);
webPage.getSettings().setLoadWithOverviewMode(true);
webPage.getSettings().setUseWideViewPort(true);
webPage.getSettings().setPluginState(PluginState.ON);
webPage.loadUrl("file:///android_asset/layout/form.html");
public class chromeClient extends WebChromeClient {
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
// TODO Auto-generated method stub
super.onShowCustomView(view, callback);
if (view instanceof FrameLayout) {
FrameLayout frame = (FrameLayout) view;
if (frame.getFocusedChild() instanceof VideoView) {
VideoView video = (VideoView) frame.getFocusedChild();
// frame.removeView(video);
video.start();
}
}
}
}
提前致谢。