html视频在浏览器上播放很棒,在webview中的灰色屏幕上播放

时间:2015-10-08 14:09:20

标签: android html android-studio flowplayer

这是html。

<div class="flowplayer">
        <video id="sourceVideo">
            <source type="video/mp4" src="http://view.vzaar.com/5275507/download" />
        </video>
    </div>

在chrome和其他浏览器中运行完美,当在Android模拟器中放置webview时这是输出

enter image description here

1 个答案:

答案 0 :(得分:0)

使用WebChromeClient(),这是一个基本示例:

    WebView videoView = (WebView)findViewById(R.id.webView);
    videoView.getSettings().setJavaScriptEnabled(true); //Enable Js execution! 
    videoView.setWebChromeClient(new WebChromeClient());
    videoView.loadUrl("http://www.jorgesys.com/myVideoDemo.html");

myVideoDemo.html的HTML代码:

<html>
    <head>
        <meta content="width=device-width; height=device-height;" name="viewport">
        <title>Jorgesys Video Demo</title>
        <link href="resource://gre/res/TopLevelVideoDocument.css" rel="stylesheet">
        <link href="chrome://global/skin/media/TopLevelVideoDocument.css" rel="stylesheet">
    </head>
    <body>
        <video id="video" autobuffer  controls="controls" autoplay="true" width="300" height="250">
            <source src="http://broken-links.com/tests/media/BigBuck.m4v">

        </video>
    </body>     
    <script>
            var video = document.getElementById('video');
            video.addEventListener('click',function(){
              video.play();
                },false);
    </script>
</html>