且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

防止divx web插件替换html5视频元素?

更新时间:2023-12-02 23:44:58

我通过放置一个空的HTML 5视频标签,然后在body onload事件中的JavaScript函数中放入视频源标签来解决这个问题。然后该视频出现在普通的HTML 5播放器而不是DivX网络播放器中。

I got around this by putting an empty HTML 5 video tag, then putting in the video source tags in a JavaScript function in the body onload event. The video then comes up in the normal HTML 5 player and not the DivX web player.

例如。
这将给DivX播放器:

e.g. This would give the DivX player:

<video width="320" height="240" controls="controls">
  <source src="movie.mp4" type="video/mp4" />
</video>

但这会给普通的html 5玩家:

But this would give the normal html 5 player:

    <head>
    <script type="text/javascript">
    function changevid() {
       document.getElementById('vid').innerHTML = '<source src="inc/videos/sample1.mp4" type="video/mp4" />';
       document.getElementById('vid').load();
    }
    </script>
    </head>
    <body onload="changevid()">

       <video id="vid" width="800" height="450" controls="controls">    
       </video>

    </body>