r67578 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67577‎ | r67578 | r67579 >
Date:01:07, 8 June 2010
Author:dale
Status:deferred
Tags:
Comment:
* fixed layout of play button in gallery
* added autoplay attribute for gallery plays
* removed dialog once closed ( video won't continue to play after completed )
* tested in latest chrome, firefox, safari. ( added a bit of space to dialog for close-captions when using the cortado player ( no text overlays ) )

per IRC bug reports by the thedj
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -160,7 +160,7 @@
161161
162162 // If the player controls should be overlayed
163163 //( Global default via config overlayControls in module loader.js)
164 - "overlayControls" : mw.getConfig( 'overlayControls' ),
 164+ "overlayControls" : true,
165165
166166 // ROE url ( for xml based metadata )
167167 // also see: http://wiki.xiph.org/ROE
@@ -407,6 +407,7 @@
408408 mw.log("runPlayerSwap::" + $j( playerElement ).attr('id') );
409409 ranPlayerSwapFlag = true;
410410 var playerInterface = new mw.EmbedPlayer( playerElement , attributes);
 411+
411412 _this.swapEmbedPlayerElement( playerElement, playerInterface );
412413
413414
@@ -1311,9 +1312,10 @@
13121313 }
13131314
13141315 var playerAttributes = mw.getConfig( 'embedPlayerAttributes' );
 1316+
13151317 // Setup the player Interface from supported attributes:
13161318 for ( var attr in playerAttributes ) {
1317 - if ( customAttributes[ attr ] ) {
 1319+ if ( customAttributes[ attr ] || customAttributes[ attr ] === false ) {
13181320 this[ attr ] = customAttributes[ attr ];
13191321 } else if ( element.getAttribute( attr ) ) {
13201322 this[ attr ] = element.getAttribute( attr );
@@ -1370,7 +1372,8 @@
13711373 // Set the source duration ( if provided in the element metaData or durationHint )
13721374 if ( $j( element ).attr( 'duration' ) ) {
13731375 _this.duration = $j( element ).attr( 'duration' );
1374 - }
 1376+ }
 1377+
13751378 if ( !_this.duration && $j( element ).attr( 'durationHint' ) ) {
13761379 _this.durationHint = $j( element ).attr( 'durationHint' );
13771380 // Convert duration hint if needed:
@@ -2008,7 +2011,7 @@
20092012
20102013 // If the native video is already displayed hide it:
20112014 if( $j( '#' + this.pid ).length != 0 ){
2012 - $j('#loadSpiner_' + this.id ).remove();
 2015+ $j('#loadingSpinner_' + this.id ).remove();
20132016 $j( '#' + this.pid ).hide()
20142017 }
20152018 if( this.mediaElement.sources.length == 0 ){
@@ -2286,13 +2289,14 @@
22872290 $j(this).empty();
22882291
22892292 // Remove the player loader spiner if it exists
2290 - $j('#loadSpiner_' + this.id ).remove();
 2293+ $j('#loadingSpinner_' + this.id ).remove();
22912294
22922295 // Check if we need to refresh mobile safari
22932296 /*var mobileSafairNeedsRefresh = false;
22942297 if( $j( '#' + this.pid ).attr('controls') === false ){
22952298 mobileSafairNeedsRefresh = true;
22962299 }*/
 2300+
22972301 // For now always refersh ( buggy display control behavior in iPad )
22982302 mobileSafairNeedsRefresh = true;
22992303
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -638,6 +638,7 @@
639639 if( mw.getConfig( 'overlayControls' ) === false){
640640 return false;
641641 }
 642+
642643 // If disabled via the player
643644 if( this.embedPlayer.overlayControls === false ){
644645 return false;
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -183,7 +183,7 @@
184184 var vid = _this.getPlayerElement();
185185
186186 // Update the bufferedPercent
187 - if( vid.buffered && vid.buffered.end && vid.duration ) {
 187+ if( vid && vid.buffered && vid.buffered.end && vid.duration ) {
188188 this.bufferedPercent = (vid.buffered.end(0) / vid.duration);
189189 }
190190 _this.parent_monitor();
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -4,7 +4,7 @@
55 */
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
8 -var mwRemoteVersion = 'r128';
 8+var mwRemoteVersion = 'r129';
99 var mwUseScriptLoader = true;
1010
1111 // Log the mwRemote version makes it easy to debug cache issues
@@ -27,7 +27,6 @@
2828 if( mwReqParam['debug'] ) {
2929 mwUseScriptLoader = false;
3030 }
31 -mwUseScriptLoader = true;
3231
3332 // Setup up some globals to wrap mwEmbed mw.ready and mw.setConfig functions
3433
@@ -318,6 +317,7 @@
319318 // Check if file is from commons and therefore should explicitly set apiProvider to commons:
320319 var apiProviderAttr = ( src.indexOf( 'wikipedia\/commons' ) != -1 )?'apiProvider="commons" ': '';
321320
 321+ var autoPlayAttr = '';
322322 // If in a gallery box we will be displaying the video larger in a lightbox
323323 if( $j( '#' + vidId ).parents( '.gallerybox' ).length ){
324324 // Update the width to 400 and keep scale
@@ -325,18 +325,20 @@
326326 if( pheight != 0 ) {
327327 pheight = pwidth * ( $j( '#' + vidId ).height() / $j( '#' + vidId ).width() );
328328 }
 329+ autoPlayAttr = ' autoplay="true" ';
329330 }
330 -
 331+
331332 if ( src ) {
332333 var html_out = '';
333334
334335 var common_attr = ' id="mwe_' + vidId + '" ' +
335 - 'apiTitleKey="' + apiTitleKey + '" ' +
336 - 'src="' + src + '" ' +
337 - apiProviderAttr +
338 - duration_attr +
339 - offset_attr + ' ' +
340 - 'class="kskin" ';
 336+ 'apiTitleKey="' + apiTitleKey + '" ' +
 337+ 'src="' + src + '" ' +
 338+ autoPlayAttr +
 339+ apiProviderAttr +
 340+ duration_attr +
 341+ offset_attr + ' ' +
 342+ 'class="kskin" ';
341343
342344 if ( tag_type == 'audio' ) {
343345 if( pwidth < 250 ){
@@ -376,17 +378,31 @@
377379 .css( {
378380 'position' : 'absolute',
379381 'top' : ( parseInt( $pimg.attr( 'height' ) ) /2 ) -25,
380 - 'left' : ( parseInt( $pimg.attr( 'height' ) ) /2 ) - 45
 382+ 'maring-left' : 'auto',
 383+ 'maring-right' : 'auto'
381384 })
 385+
382386 .addClass( 'play-btn-large' )
383387 .buttonHover()
384 - .click( function(){
 388+ .click( function(){
 389+ var _this = this;
 390+
385391 var dialogHeight = ( $j( this ).data( 'playerHeight') == 0 )? 175 :
386 - ( $j( this ).data( 'playerHeight') - 75 );
 392+ ( $j( this ).data( 'playerHeight') - 25 );
 393+ var buttons = {};
 394+ buttons[ gM( 'mwe-ok' ) ] = function(){
 395+ var embedPlayer = $j( '#mwe_' + $j( _this ).data( 'playerId' ) ).get(0);
 396+ // stop the player ( more healthy way to remove the video from the dom )
 397+ if( embedPlayer ) {
 398+ embedPlayer.stop();
 399+ }
 400+ // close the dialog
 401+ $j(this).dialog( 'close' ).remove();
 402+ };
387403 mw.addDialog(
388404 decodeURIComponent( $j( this ).data( 'title' ).replace(/_/g, ' ') ),
389405 $j( this ).data( 'embedCode' ),
390 - gM( 'mwe-ok' )
 406+ buttons
391407 )
392408 // Dialog size setup is a bit strange:
393409 .css( {
@@ -396,9 +412,20 @@
397413 // we hard code the default resolution to 400 above
398414 'width' : '435px',
399415 } )
400 - // Update the embed code to use the mwEmbed player:
401 - $j.embedPlayers();
 416+
 417+ alert( $j('#mwTempLoaderDialog').html() );
 418+
 419+ // Update the embed code to use the mwEmbed player:
 420+ $j.embedPlayers( function(){
 421+ var embedPlayer = $j( '#mwe_' + $j( _this ).data( 'playerId' ) ).get(0);
 422+ // Show the control bar for two seconds (auto play is confusing without it )
 423+ embedPlayer.controlBuilder.showControlBar();
 424+ setTimeout( function(){
 425+ embedPlayer.controlBuilder.hideControlBar();
 426+ }, 4000 );
 427+ });
402428 })
 429+ .data( 'playerId', vidId )
403430 .data( 'embedCode', html_out )
404431 .data( 'title' , apiTitleKey )
405432 .data( 'playerHeight', pheight )
@@ -508,8 +535,17 @@
509536 rurl += '&' + mwGetReqArgs();
510537 importScriptURI( rurl );
511538 } else {
512 - // Ignore classSet (will be loaded onDemand )
 539+ // load mwEmbed js
513540 importScriptURI( mwEmbedHostPath + '/mwEmbed.js?' + mwGetReqArgs() );
 541+
 542+ // Load the class set as part of mwReady callback
 543+ var instanceCallback = callback;
 544+ var callback = function(){
 545+ mw.load( classSet, function(){
 546+ instanceCallback();
 547+ })
 548+ }
 549+
514550 }
515551 }
516552 waitMwEmbedReady( callback );

Status & tagging log