Index: trunk/extensions/OggHandler/OggPlayer.js |
— | — | @@ -151,7 +151,16 @@ |
152 | 152 | if(navigator.mimeTypes && navigator.mimeTypes.length > 0) { |
153 | 153 | for ( var i = 0; i < navigator.mimeTypes.length; i++) { |
154 | 154 | var type = navigator.mimeTypes[i].type; |
| 155 | + var semicolonPos = type.indexOf( ';' ); |
| 156 | + if ( semicolonPos > -1 ) { |
| 157 | + type = type.substr( 0, semicolonPos ); |
| 158 | + } |
| 159 | + |
155 | 160 | 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 | + } |
156 | 165 | if ( type == 'application/ogg' ) { |
157 | 166 | if ( pluginName.toLowerCase() == 'vlc multimedia plugin' ) { |
158 | 167 | this.clientSupports['vlc-mozilla'] = true; |
— | — | @@ -167,6 +176,10 @@ |
168 | 177 | this.clientSupports['cortado'] = true; |
169 | 178 | continue; |
170 | 179 | } |
| 180 | + // Hack for Opera |
| 181 | + if ( type == 'application/x-vlc-plugin' ) { |
| 182 | + this.clientSupports['vlc-mozilla'] = true; |
| 183 | + } |
171 | 184 | } |
172 | 185 | } |
173 | 186 | }, |
— | — | @@ -465,7 +478,7 @@ |
466 | 479 | // In Opera, document.createElement('applet') immediately creates |
467 | 480 | // a non-working applet with unchangeable parameters, similar to the |
468 | 481 | // problem with IE and ActiveX. |
469 | | - elt.innerHTML = '<div>' + |
| 482 | + var html = |
470 | 483 | '<applet code="com.fluendo.player.Cortado.class" ' + |
471 | 484 | ' width=' + this.hq( params.width ) + |
472 | 485 | ' height=' + this.hq( playerHeight ) + |
— | — | @@ -476,17 +489,35 @@ |
477 | 490 | ' <param name="autoPlay" value="true"/>' + |
478 | 491 | ' <param name="showStatus" value="show"/>' + |
479 | 492 | ' <param name="statusHeight" value="' + statusHeight + '"/>' + |
480 | | - '</applet>' + |
481 | | - '</div>'; |
| 493 | + '</applet>'; |
482 | 494 | |
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>'; |
489 | 507 | }, |
490 | 508 | |
| 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 | + |
491 | 522 | 'embedQuicktimePlugin': function ( elt, params ) { |
492 | 523 | var id = elt.id + "_obj"; |
493 | 524 | var controllerHeight = 16; // by observation |