如何在一个web视图Android的播放HTML5视频 [英] how to play html5 video on a webview android

查看:117
本文介绍了如何在一个web视图Android的播放HTML5视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载网页上的Web视图,页面有一个视频在里面。我能够加载网页上的Web视图但视频是不是在玩和音频声。这是我为加载到Web视图的链接。

i am trying to load a webpage on a web view where the page has a video in it. i am able to load the web page on the web view but the video is not playing and the audio is heard. this is the link i m loading to a web view.

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();

            }
        }

    }

};

}

请帮我修改我的code。谢谢

pls help me modify my code. thanks

推荐答案

这工作对我来说,问题是如何处理在本地存储的视频文件的权限。希望它可以帮助!

This worked for me, problem was to do with file permissions on the locally stored video. Hope it helps!

<video width="365" height="200" src="/mnt/SDcard/media/video/abc.mp4" controls autobuffer></video>

这篇关于如何在一个web视图Android的播放HTML5视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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