r76862 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76861‎ | r76862 | r76863 >
Date:00:02, 17 November 2010
Author:dale
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)
  • /branches/MwEmbedStandAlone/skins/common/mw.style.mwCommon.css (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/skins/common/mw.style.mwCommon.css
@@ -185,7 +185,7 @@
186186 * Lets us use root common style sheets with jquery based skins
187187 * ( without additional assets in the embedPlayer skins folder )
188188 */
189 -.mv-player .play-btn-large {
 189+.play-btn-large {
190190 width : 130px;
191191 height : 96px;
192192 background : url(images/player_big_play_button.png);
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -1168,10 +1168,10 @@
11691169 */
11701170 mw.isHTML5FallForwardNative = function(){
11711171 // Check for a mobile html5 user agent:
1172 - if ( (navigator.userAgent.indexOf('iPhone') != -1) ||
1173 - (navigator.userAgent.indexOf('iPod') != -1) ||
1174 - (navigator.userAgent.indexOf('iPad') != -1) ||
1175 - (navigator.userAgent.indexOf('Android 2.') != -1) ||
 1172+ if ( ( mw.isIphone() ) ||
 1173+ ( mw.isIpod() ) ||
 1174+ ( mw.isIpad() ) ||
 1175+ ( mw.isAndroid2() ) ||
11761176 // to debug in chrome / desktop safari
11771177 (document.URL.indexOf('forceMobileHTML5') != -1 )
11781178 ) {
@@ -1191,9 +1191,14 @@
11921192 return false;
11931193 }
11941194 }
 1195+<<<<<<< .mine
 1196+ }
 1197+ // For IE:
 1198+=======
11951199 }
11961200
11971201 // For IE:
 1202+>>>>>>> .r76860
11981203 var hasObj = true;
11991204 try {
12001205 var obj = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash' );
@@ -1212,12 +1217,22 @@
12131218 // No video tag or flash, return false ( normal "install flash" user flow )
12141219 return false;
12151220 }
 1221+<<<<<<< .mine
 1222+ mw.isIphone = function(){
 1223+ return ( navigator.userAgent.indexOf('iPhone') != -1 );
 1224+ };
 1225+ mw.isIpod = function(){
 1226+ return ( navigator.userAgent.indexOf('iPod') != -1 );
 1227+ };
 1228+ mw.isIpad = function(){
 1229+ return ( navigator.userAgent.indexOf('iPad') != -1 );
 1230+ };
 1231+ // Android 2 has some restrictions vs other mobile platforms
 1232+=======
12161233 // Android 2 has some restrictions vs other mobile platforms
1217 - mw.isAndroid2 = function(){
1218 - if ( navigator.userAgent.indexOf('Android 2.') != -1) {
1219 - return true;
1220 - }
1221 - return false;
 1234+>>>>>>> .r76860
 1235+ mw.isAndroid2 = function(){
 1236+ return ( navigator.userAgent.indexOf( 'Android 2.') != -1 );
12221237 };
12231238
12241239 /**
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -2422,27 +2422,32 @@
24232423 // in the dom , and no auto-play )
24242424 // and only with 'native display'
24252425 if( mw.isAndroid2() ){
2426 - $j( '#' + _this.pid ).siblings('.play-btn-large').remove();
2427 - $j( '#' + _this.pid ).after(
2428 - $j('<div />')
2429 - .css({
2430 - 'position' : 'relative',
2431 - 'top' : -1 * ( .5 * _this.getPlayerHeight() ) - 52,
2432 - 'left' : ( .5 * _this.getPlayerWidth() ) - 75
2433 - })
2434 - .attr( {
2435 - 'title' : gM( 'mwe-embedplayer-play_clip' ),
2436 - 'class' : "ui-state-default play-btn-large"
2437 - } )
2438 - .click( function() {
2439 - _this.play();
2440 - // no need to hide the play button since android plays
2441 - // fullscreen
2442 - } )
2443 - )
 2426+ this.addPlayBtnLarge();
24442427 }
24452428 return ;
24462429 },
 2430+ addPlayBtnLarge:function(){
 2431+ var _this = this;
 2432+ $j( '#' + _this.pid ).siblings('.play-btn-large').remove();
 2433+ $j( '#' + _this.pid ).after(
 2434+ $j('<div />')
 2435+ .css({
 2436+ 'position' : 'relative',
 2437+ 'top' : -1 * ( .5 * _this.getHeight() ) - 52,
 2438+ 'left' : ( .5 * _this.getWidth() ) - 75
 2439+ })
 2440+ .attr( {
 2441+ 'title' : gM( 'mwe-embedplayer-play_clip' ),
 2442+ 'class' : "play-btn-large"
 2443+ } )
 2444+ .click( function() {
 2445+ $j( this ).hide();
 2446+ _this.play();
 2447+ // no need to hide the play button since android plays
 2448+ // fullscreen
 2449+ } )
 2450+ )
 2451+ },
24472452 /**
24482453 * Should be set via native embed support
24492454 */
@@ -2775,22 +2780,29 @@
27762781 this.pause();
27772782 }
27782783 }
2779 -
2780 - // Rewrite the html to thumbnail disp
2781 - this.showThumbnail();
2782 - this.bufferedPercent = 0; // reset buffer state
2783 - this.controlBuilder.setStatus( this.getTimeRange() );
2784 -
2785 - // Reset the playhead
2786 - mw.log("EmbedPlayer::Stop:: Reset play head")
2787 - this.updatePlayHead( 0 );
2788 -
2789 - // Bind play-btn-large play
2790 - this.$interface.find( '.play-btn-large' )
2791 - .unbind( 'click' )
2792 - .click( function() {
2793 - _this.play();
2794 - } );
 2784+ // Native player controls:
 2785+ if( this.useNativePlayerControls() ){
 2786+ this.getPlayerElement().currentTime = 0;
 2787+ this.getPlayerElement().pause();
 2788+ // add play button on top
 2789+ this.addPlayBtnLarge();
 2790+ } else {
 2791+ // Rewrite the html to thumbnail disp
 2792+ this.showThumbnail();
 2793+ this.bufferedPercent = 0; // reset buffer state
 2794+ this.controlBuilder.setStatus( this.getTimeRange() );
 2795+
 2796+ // Reset the playhead
 2797+ mw.log("EmbedPlayer::Stop:: Reset play head")
 2798+ this.updatePlayHead( 0 );
 2799+
 2800+ // Bind play-btn-large play
 2801+ this.$interface.find( '.play-btn-large' )
 2802+ .unbind( 'click' )
 2803+ .click( function() {
 2804+ _this.play();
 2805+ } );
 2806+ }
27952807 },
27962808
27972809 /**
@@ -3080,6 +3092,7 @@
30813093
30823094 // Get the buffer target based for playlist vs clip
30833095 $buffer = this.$interface.find( '.mw_buffer' );
 3096+
30843097 //mw.log(' set bufferd %:' + this.bufferedPercent );
30853098 // Update the buffer progress bar (if available )
30863099 if ( this.bufferedPercent != 0 ) {
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -564,8 +564,8 @@
565565 *
566566 * Used to update the bufferedPercent
567567 *
568 - * Note: this way of updating buffer was only supported in firefox 3.x and
569 - * not supported in firefox 4.x
 568+ * Note: this way of updating buffer was only supported in Firefox 3.x and
 569+ * not supported in Firefox 4.x
570570 */
571571 onprogress: function( event ) {
572572 var e = event.originalEvent;

Status & tagging log