http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76862
Revision: 76862 Author: dale Date: 2010-11-17 00:02:08 +0000 (Wed, 17 Nov 2010) Log Message: ----------- refactored addPlayBtnLarge for android support added helper mobile device identifiers small css fix for player button outside of interface div Modified Paths: -------------- branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js branches/MwEmbedStandAlone/mwEmbed.js branches/MwEmbedStandAlone/skins/common/mw.style.mwCommon.css Modified: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js =================================================================== --- branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js 2010-11-16 23:59:24 UTC (rev 76861) +++ branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js 2010-11-17 00:02:08 UTC (rev 76862) @@ -2422,27 +2422,32 @@ // in the dom , and no auto-play ) // and only with 'native display' if( mw.isAndroid2() ){ - $j( '#' + _this.pid ).siblings('.play-btn-large').remove(); - $j( '#' + _this.pid ).after( - $j('<div />') - .css({ - 'position' : 'relative', - 'top' : -1 * ( .5 * _this.getPlayerHeight() ) - 52, - 'left' : ( .5 * _this.getPlayerWidth() ) - 75 - }) - .attr( { - 'title' : gM( 'mwe-embedplayer-play_clip' ), - 'class' : "ui-state-default play-btn-large" - } ) - .click( function() { - _this.play(); - // no need to hide the play button since android plays - // fullscreen - } ) - ) + this.addPlayBtnLarge(); } return ; }, + addPlayBtnLarge:function(){ + var _this = this; + $j( '#' + _this.pid ).siblings('.play-btn-large').remove(); + $j( '#' + _this.pid ).after( + $j('<div />') + .css({ + 'position' : 'relative', + 'top' : -1 * ( .5 * _this.getHeight() ) - 52, + 'left' : ( .5 * _this.getWidth() ) - 75 + }) + .attr( { + 'title' : gM( 'mwe-embedplayer-play_clip' ), + 'class' : "play-btn-large" + } ) + .click( function() { + $j( this ).hide(); + _this.play(); + // no need to hide the play button since android plays + // fullscreen + } ) + ) + }, /** * Should be set via native embed support */ @@ -2775,22 +2780,29 @@ this.pause(); } } - - // Rewrite the html to thumbnail disp - this.showThumbnail(); - this.bufferedPercent = 0; // reset buffer state - this.controlBuilder.setStatus( this.getTimeRange() ); - - // Reset the playhead - mw.log("EmbedPlayer::Stop:: Reset play head") - this.updatePlayHead( 0 ); - - // Bind play-btn-large play - this.$interface.find( '.play-btn-large' ) - .unbind( 'click' ) - .click( function() { - _this.play(); - } ); + // Native player controls: + if( this.useNativePlayerControls() ){ + this.getPlayerElement().currentTime = 0; + this.getPlayerElement().pause(); + // add play button on top + this.addPlayBtnLarge(); + } else { + // Rewrite the html to thumbnail disp + this.showThumbnail(); + this.bufferedPercent = 0; // reset buffer state + this.controlBuilder.setStatus( this.getTimeRange() ); + + // Reset the playhead + mw.log("EmbedPlayer::Stop:: Reset play head") + this.updatePlayHead( 0 ); + + // Bind play-btn-large play + this.$interface.find( '.play-btn-large' ) + .unbind( 'click' ) + .click( function() { + _this.play(); + } ); + } }, /** @@ -3080,6 +3092,7 @@ // Get the buffer target based for playlist vs clip $buffer = this.$interface.find( '.mw_buffer' ); + //mw.log(' set bufferd %:' + this.bufferedPercent ); // Update the buffer progress bar (if available ) if ( this.bufferedPercent != 0 ) { Modified: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js =================================================================== --- branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js 2010-11-16 23:59:24 UTC (rev 76861) +++ branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js 2010-11-17 00:02:08 UTC (rev 76862) @@ -564,8 +564,8 @@ * * Used to update the bufferedPercent * - * Note: this way of updating buffer was only supported in firefox 3.x and - * not supported in firefox 4.x + * Note: this way of updating buffer was only supported in Firefox 3.x and + * not supported in Firefox 4.x */ onprogress: function( event ) { var e = event.originalEvent; Modified: branches/MwEmbedStandAlone/mwEmbed.js =================================================================== --- branches/MwEmbedStandAlone/mwEmbed.js 2010-11-16 23:59:24 UTC (rev 76861) +++ branches/MwEmbedStandAlone/mwEmbed.js 2010-11-17 00:02:08 UTC (rev 76862) @@ -1168,10 +1168,10 @@ */ mw.isHTML5FallForwardNative = function(){ // Check for a mobile html5 user agent: - if ( (navigator.userAgent.indexOf('iPhone') != -1) || - (navigator.userAgent.indexOf('iPod') != -1) || - (navigator.userAgent.indexOf('iPad') != -1) || - (navigator.userAgent.indexOf('Android 2.') != -1) || + if ( ( mw.isIphone() ) || + ( mw.isIpod() ) || + ( mw.isIpad() ) || + ( mw.isAndroid2() ) || // to debug in chrome / desktop safari (document.URL.indexOf('forceMobileHTML5') != -1 ) ) { @@ -1191,9 +1191,14 @@ return false; } } +<<<<<<< .mine + } + // For IE: +======= } // For IE: +>>>>>>> .r76860 var hasObj = true; try { var obj = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash' ); @@ -1212,12 +1217,22 @@ // No video tag or flash, return false ( normal "install flash" user flow ) return false; } +<<<<<<< .mine + mw.isIphone = function(){ + return ( navigator.userAgent.indexOf('iPhone') != -1 ); + }; + mw.isIpod = function(){ + return ( navigator.userAgent.indexOf('iPod') != -1 ); + }; + mw.isIpad = function(){ + return ( navigator.userAgent.indexOf('iPad') != -1 ); + }; + // Android 2 has some restrictions vs other mobile platforms +======= // Android 2 has some restrictions vs other mobile platforms - mw.isAndroid2 = function(){ - if ( navigator.userAgent.indexOf('Android 2.') != -1) { - return true; - } - return false; +>>>>>>> .r76860 + mw.isAndroid2 = function(){ + return ( navigator.userAgent.indexOf( 'Android 2.') != -1 ); }; /** Modified: branches/MwEmbedStandAlone/skins/common/mw.style.mwCommon.css =================================================================== --- branches/MwEmbedStandAlone/skins/common/mw.style.mwCommon.css 2010-11-16 23:59:24 UTC (rev 76861) +++ branches/MwEmbedStandAlone/skins/common/mw.style.mwCommon.css 2010-11-17 00:02:08 UTC (rev 76862) @@ -185,7 +185,7 @@ * Lets us use root common style sheets with jquery based skins * ( without additional assets in the embedPlayer skins folder ) */ -.mv-player .play-btn-large { +.play-btn-large { width : 130px; height : 96px; background : url(images/player_big_play_button.png); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs