Prevent divx web plugin fron replacing html5 video element?

后端 未结 4 602
傲寒
傲寒 2020-12-31 09:02

For some reason I\'m sure the folks at DivX think is important, there is no straightforward way to prevent their plugin from replacing all video elements on your page with t

相关标签:
4条回答
  • 2020-12-31 09:32

    It seems, that the plugin is only replacing the video when there are src elements within the video tag. For me it worked by first adding the video tag, and then - in a second thread - add the src tags. However, this doesn´t work in IE but IE had no problem with an insertion of the complete video tag at once.

    So following code worked for me in all browsers (of course, jQuery required):

    var $container = $('video_container');
    var video = 'my-movie';
    var videoSrc = '<source src="video/'+video+'.mp4" type="video/mp4"></source>' +
        '<source src="video/'+video+'.webm" type="video/webm"></source>' +
        '<source src="video/'+video+'.ogv" type="video/ogg"></source>';
    
    if(!$.browser.msie) {
        $container.html('<video autoplay loop></video>');
        // this timeout avoids divx player to be triggered
        setTimeout(function() {
            $container.find('video').html(videoSrc);
        }, 50);
    }
    else {
        // IE has no problem with divx player, so we add the src in the same thread
        $container.html('<video autoplay loop>' + videoSrc + '</video>');
    }
    
    0 讨论(0)
  • 2020-12-31 09:35

    At this time, there is no API or means to block the divx plugin from replacing video elements with their placeholder. :-(

    0 讨论(0)
  • 2020-12-31 09:36

    i started reverse-engineering the divx-plugin to find out what can be done to hack a way into disabling it. An example, including the complete sourcecode of the divx-plugin, can be found here: http://jsfiddle.net/z4JPB/1/

    It currently appears to me that a possible solution could work like this:

    • create a "clean" backup of the methods appendChild, replaceChild and insertBefore - this has to happen before the content-script from the chrome-extension is executed.
    • the content-script will execute, overrides the methods mentioned above and adds event-listeners to the DOMNodeInsertedIntoDocument and DOMNodeInserted events
    • after that, the event-listeners can be removed and the original DOM-Methods restored. You should now be able to replace the embed-elements created by the plugin with the video-elements
    0 讨论(0)
  • 2020-12-31 09:37

    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.

    e.g. This would give the DivX player:

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

    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>
    
    0 讨论(0)
提交回复
热议问题