我正在尝试在Web视图中加载一个包含视频的网页。我能够在Web视图上加载网页,但视频无法播放,只有音频可以听到。这是我正在加载到Web视图的链接:http://html5videoformatconverter.com/html5-video-tag-example.html。我所做的一切就是:
public class VideoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView mWebView = (WebView) findViewById(R.id.wvVideo);
mWebView.setWebChromeClient(chromeClient);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("http://html5videoformatconverter.com/html5-video-tag-example.html");
}
private WebChromeClient chromeClient = new 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();
}
}
}
};
请帮我修改我的代码。谢谢