r25652 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25651‎ | r25652 | r25653 >
Date:00:27, 8 September 2007
Author:tstarling
Status:old
Tags:
Comment:
* Misc. fixes for opera
* Wrap an iframe around the applet tag in non-IE, to work around Firefox 2.0 bug. Tested on FF and Opera, needs testing on some other browsers, because it uses some non-standard JS.
Modified paths:
  • /trunk/extensions/OggHandler/OggPlayer.js (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggPlayer.js
@@ -151,7 +151,16 @@
152152 if(navigator.mimeTypes && navigator.mimeTypes.length > 0) {
153153 for ( var i = 0; i < navigator.mimeTypes.length; i++) {
154154 var type = navigator.mimeTypes[i].type;
 155+ var semicolonPos = type.indexOf( ';' );
 156+ if ( semicolonPos > -1 ) {
 157+ type = type.substr( 0, semicolonPos );
 158+ }
 159+
155160 var pluginName = navigator.mimeTypes[i].enabledPlugin ? navigator.mimeTypes[i].enabledPlugin.name : '';
 161+ if ( !pluginName ) {
 162+ // In case it is null or undefined
 163+ pluginName = '';
 164+ }
156165 if ( type == 'application/ogg' ) {
157166 if ( pluginName.toLowerCase() == 'vlc multimedia plugin' ) {
158167 this.clientSupports['vlc-mozilla'] = true;
@@ -167,6 +176,10 @@
168177 this.clientSupports['cortado'] = true;
169178 continue;
170179 }
 180+ // Hack for Opera
 181+ if ( type == 'application/x-vlc-plugin' ) {
 182+ this.clientSupports['vlc-mozilla'] = true;
 183+ }
171184 }
172185 }
173186 },
@@ -465,7 +478,7 @@
466479 // In Opera, document.createElement('applet') immediately creates
467480 // a non-working applet with unchangeable parameters, similar to the
468481 // problem with IE and ActiveX.
469 - elt.innerHTML = '<div>' +
 482+ var html =
470483 '<applet code="com.fluendo.player.Cortado.class" ' +
471484 ' width=' + this.hq( params.width ) +
472485 ' height=' + this.hq( playerHeight ) +
@@ -476,17 +489,35 @@
477490 ' <param name="autoPlay" value="true"/>' +
478491 ' <param name="showStatus" value="show"/>' +
479492 ' <param name="statusHeight" value="' + statusHeight + '"/>' +
480 - '</applet>' +
481 - '</div>';
 493+ '</applet>';
482494
483 - // Disable autoPlay in the DOM right now, to prevent Mozilla from
484 - // restarting an arbitrary number of applet instances on a back button click.
485 - // Unfortunately this means that some clients (e.g. Opera) won't autoplay at all
486 - var videoElt = elt.getElementsByTagName( 'div' ) [0] .
487 - getElementsByTagName( 'applet' )[0];
488 - this.setParam( videoElt, 'autoPlay', '' );
 495+ // Wrap it in an iframe to avoid hanging the rendering thread in FF 2.0 and similar
 496+ if ( navigator.appName != "Microsoft Internet Explorer" ) {
 497+ var iframeHtml = '<html><body>' + html + '</body></html>';
 498+ var iframeJs = 'parent.wgOggPlayer.writeApplet(self, "' + iframeHtml.replace( /"/g, '\\"' ) + '");';
 499+ var iframeUrl = 'javascript:' + encodeURIComponent( iframeJs );
 500+ 'document.write("' + iframeHtml.replace( /"/g, '\\"' ) + '");';
 501+ html = '<iframe width=' + this.hq( params.width ) +
 502+ ' height=' + this.hq( playerHeight ) +
 503+ ' scrolling="no" frameborder="0" marginwidth="0" marginheight="0"' +
 504+ ' src=' + this.hq( iframeUrl ) + '/>';
 505+ }
 506+ elt.innerHTML = '<div>' + html + '</div>';
489507 },
490508
 509+ 'writeApplet' : function ( win, html ) {
 510+ win.document.write( html );
 511+ win.stop();
 512+ // Disable autoplay on back button
 513+ this_ = this;
 514+ win.setTimeout(
 515+ function () {
 516+ this_.setParam( win.document.applets[0], 'autoPlay', '' );
 517+ },
 518+ 1
 519+ );
 520+ },
 521+
491522 'embedQuicktimePlugin': function ( elt, params ) {
492523 var id = elt.id + "_obj";
493524 var controllerHeight = 16; // by observation

Status & tagging log