如何在一个web视图Android的播放HTML5视频视图、如何在、视频、web

2023-09-06 04:27:56 作者:那年夏天

我试图加载网页上的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>