<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  <binding id="video4all">
    <implementation>
      <constructor><![CDATA[
                var videoElement = this;
                var div = document.createElement('div');
                var sources = videoElement.getElementsByTagName('source');
                var src = "";
                for (var i = 0; i < sources.length; i++) {
                        if (sources[i].getAttribute('type') == 'video/mp4') {
                                src = sources[i].getAttribute('src');
                                break;
                        }
                }

                var autoplay = new Boolean(videoElement.getAttribute('autoplay'));
                var autobuffer = new Boolean(videoElement.getAttribute('autobuffer'));

                var flashvars = "config={'playerId':'player','clip':{'autoPlay':" + autoplay + ", 'autoBuffering':" + autobuffer + ",'url':'" + src + "'},'playlist':[{'url':'" + src + "'}]}";
                var player = "flowplayer-3.1.1.swf";
                html = '<object data=' + player + ' type="application/x-shockwave-flash" width="100%" height="100%">'
                        + ' <param name="flashvars" value="' + flashvars + '" />'
                        + ' <param name="movie" value="' + player + '" />'
                        + '</object>';
                div.innerHTML = html;
                videoElement.appendChild(div);

                div.style.cssText = videoElement.style.cssText;
        ]]>
      </constructor>
    </implementation>
  </binding>
</bindings>