Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent divx web plugin fron replacing html5 video element?

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 they fancy logo.

What I need is a workaround for this, telling the plugin to skip some videos, i.e. not replace them with their playable content.

like image 418
Horia Dragomir Avatar asked Jan 20 '11 09:01

Horia Dragomir


4 Answers

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>
like image 67
George Avatar answered Nov 19 '22 19:11

George


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

like image 27
Horia Dragomir Avatar answered Nov 19 '22 18:11

Horia Dragomir


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
like image 2
Martin Schuhfuß Avatar answered Nov 19 '22 17:11

Martin Schuhfuß


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>');
}
like image 1
tomraithel Avatar answered Nov 19 '22 18:11

tomraithel