r63198 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63197‎ | r63198 | r63199 >
Date:13:42, 3 March 2010
Author:dale
Status:deferred
Tags:
Comment:
* added IE html5 / mwEmbed elements ( less $j.browser.msie hacks )
* added an additional cortado release since the current release had issues with javascript bindings.
* some clean up of monitor call
* fixed center of media in full-screen
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/binPlayers/cortado/cortado-january.jar (added) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -103,7 +103,7 @@
104104 'position': 'absolute',
105105 'bottom' : '0px',
106106 'left' : '0px',
107 - 'right' : '0px'
 107+ 'right' : '0px'
108108 })
109109 .hide()
110110 // Make sure the interface is correct height:
@@ -113,7 +113,7 @@
114114 } else {
115115 // Add some space to interface for the control bar ( if not overlaying controls )
116116 embedPlayer.$interface.css( {
117 - 'height' : parseInt( embedPlayer.height ) + parseInt( this.height ) + 2
 117+ 'height' : parseInt( embedPlayer.height ) + parseInt( this.height ) +2
118118 } );
119119 // update the control bar display to "block"
120120 $controlBar.css( 'display', 'block' );
@@ -215,7 +215,8 @@
216216 return {
217217 'height': targetHeight,
218218 'width' : targetWidth,
219 - 'top' : offsetTop
 219+ 'top' : offsetTop,
 220+ 'left': offsetLeft
220221 }
221222 },
222223
@@ -314,7 +315,7 @@
315316 'left' : leftOffset,
316317 'width' : $j( window ).width(),
317318 'height' : $j( window ).height(),
318 - 'overlow' : 'hidden'
 319+ 'overlow' : 'hidden'
319320 } )
320321
321322 // Set the player height width:
@@ -325,7 +326,7 @@
326327 .animate( _this.getFullscreenPlayerCss() );
327328
328329 // Resize the timed text font size per window width
329 - $interface.find( '.itext' ).animate( _this.getFullscreenTextCss() );
 330+ $interface.find( '.itext' ).css( _this.getFullscreenTextCss() );
330331
331332 // Reposition play-btn-large ( this is unfortunatly not easy to position with 'margin': 'auto'
332333 $interface.find('.play-btn-large').animate( _this.getFullscreenPlayButtonCss() )
@@ -434,7 +435,7 @@
435436 } );
436437
437438 // Restore text size:
438 - $interface.find('.itext').animate({
 439+ $interface.find( '.itext' ).css({
439440 'font-size' : '100%'
440441 })
441442 },
@@ -783,7 +784,7 @@
784785 );
785786 }
786787 )
787 - },
 788+ },
788789
789790 // Download the file menu
790791 'download': function( ctrlObj ) {
@@ -1499,8 +1500,6 @@
15001501 if ( embedPlayer.userSlide ) {
15011502 embedPlayer.userSlide = false;
15021503 embedPlayer.seeking = true;
1503 - // Stop the monitor timer (if we can)
1504 - embedPlayer.stopMonitor();
15051504
15061505 var perc = ui.value / 1000;
15071506 // set seek time (in case we have to do a url seek)
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -64,6 +64,8 @@
6565 *
6666 * NOTE: this function can be part of setup can run prior to jQuery being ready
6767 */
 68+
 69+
6870 mw.documentHasPlayerTags = function() {
6971 var rewriteTags = mw.getConfig( 'rewritePlayerTags' );
7072 if( rewriteTags ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -258,35 +258,16 @@
259259 if( ! mw.playerManager )
260260 mw.playerManager = new EmbedPlayerManager();
261261
262 - //Add the current callback
263 - if( typeof callback == 'function' )
 262+ //Add the embedPlayer ready callback
 263+ if( typeof callback == 'function' ){
264264 mw.playerManager.addCallback( callback );
265 -
266 - // IE not working well with jQuery selector on "VIDEO", "AUDIO" etc.
267 - var ie_safe_selector = coma = '';
268 - if( $j.browser.msie ) {
269 - var selectors = player_select.split(',');
270 - for( var i=0; i < selectors.length; i++ ) {
271 - if( selectors[i] == 'video' ||
272 - selectors[i] == 'playlist' ||
273 - selectors[i] == 'audio'
274 - ) {
275 - $j( document.getElementsByTagName( selectors[ i ] )).each( function( ) {
276 - mw.playerManager.addElement( this, attributes );
277 - } );
278 - }else{
279 - ie_safe_selector += coma + selectors[i];
280 - coma = ',';
281 - }
282 - }
283 - player_select = ie_safe_selector;
284265 }
285 - if( player_select != '') {
286 - // Add each selected element to the player manager:
287 - $j( player_select ).each( function(na, playerElement) {
288 - mw.playerManager.addElement( playerElement, attributes);
289 - } );
290 - }
 266+
 267+ // Add each selected element to the player manager:
 268+ $j( player_select ).each( function(na, playerElement) {
 269+ mw.playerManager.addElement( playerElement, attributes);
 270+ } );
 271+
291272 // Once we are done adding new players start to check if players are ready:
292273 mw.playerManager.waitPlayersReadyCallback();
293274 }
@@ -882,30 +863,10 @@
883864 if ( $j( video_element ).attr( "src" ) ) {
884865 this.tryAddSource( video_element );
885866 }
886 -
887 - if( ! $j.browser.msie ){
888 - // Most browsers are oky with inner unknown element selectors:
889 - $j( video_element ).find( 'source,itext' ).each( function( ) {
890 - _this.tryAddSource( this );
891 - } );
892 - } else {
893 - // IE on the other hand is not.
894867
895 - // IE apperntly has the source tags floating in DOM space but not
896 - // as child of the unknown video tag element rather as its "sibling"
897 -
898 - // Add the video element with an identifiable div
899 -
900 - // NOTE this fails for multiple video tags in a given div
901 - // but if we $j( video_element ).wrap ( $j('<div />' ) ) it fails all together
902 - $j( $j( video_element ).parent().get(0).getElementsByTagName('source') ).each( function(){
903 - _this.tryAddSource( this );
904 - });
905 -
906 - $j( $j( video_element ).parent().get(0).getElementsByTagName( 'itext' ) ).each( function(){
907 - _this.tryAddSource( this );
908 - });
909 - }
 868+ $j( video_element ).find( 'source,itext' ).each( function( ) {
 869+ _this.tryAddSource( this );
 870+ } );
910871 },
911872
912873 /**
@@ -2148,8 +2109,7 @@
21492110 mw.log( "embedPlayer:showPlayer::AddControls" );
21502111 this.ctrlBuilder.addControls();
21512112 }
2152 -
2153 -
 2113+
21542114 if ( this.autoplay ) {
21552115 mw.log( 'showPlayer::activating autoplay' );
21562116 this.play();
@@ -2518,9 +2478,9 @@
25192479 mw.log( 'no selected_player' );
25202480 this.showPluginMissingHTML();
25212481 } else {
2522 - this.doEmbedPlayer();
2523 - this.paused = false;
25242482 this.thumbnail_disp = false;
 2483+ this.paused = false;
 2484+ this.doEmbedPlayer();
25252485 }
25262486 } else {
25272487 // the plugin is already being displayed
@@ -2600,16 +2560,17 @@
26012561 // no longer seeking:
26022562 this.didSeekJump = false;
26032563
2604 - // first issue pause to update interface (only call the parent)
 2564+ // first issue pause to update interface (only call this parent)
26052565 if ( this['parent_pause'] ) {
26062566 this.parent_pause();
26072567 } else {
26082568 this.pause();
26092569 }
26102570
2611 - // reset the currentTime:
 2571+ // Reset the currentTime:
26122572 this.currentTime = 0;
2613 - // check if thumbnail is being displayed in which case do nothing
 2573+
 2574+ // Check if thumbnail is being displayed in which case do nothing
26142575 if ( this.thumbnail_disp ) {
26152576 // already in stooped state
26162577 mw.log( 'already in stopped state' );
@@ -2734,7 +2695,7 @@
27352696 * underling plugin objects are responsible for updating currentTime
27362697 */
27372698 monitor: function() {
2738 - var _this = this;
 2699+ var _this = this;
27392700 //mw.log(' ct: ' + this.currentTime + ' dur: ' + ( parseInt( this.duration ) + 1 ) + ' is seek: ' + this.seeking );
27402701 if ( this.currentTime && this.currentTime > 0 && this.duration ) {
27412702 if ( !this.userSlide && !this.seeking ) {
@@ -2774,33 +2735,17 @@
27752736
27762737 // Update buffer information
27772738 this.updateBufferStatus();
 2739+ // Call monitor at 250ms interval.
 2740+ if( ! this.isStoped() ) {
 2741+ setTimeout( function(){
 2742+ _this.monitor();
 2743+ }, 250 )
 2744+ }
27782745
2779 - // Update monitorTimerId to call child monitor
2780 - if ( ! this.monitorTimerId ) {
2781 - // Make sure an instance of this.id exists:
2782 - if ( document.getElementById( this.id ) ) {
2783 - this.monitorTimerId = setInterval( function() {
2784 - if ( _this.id && $j( '#' + _this.id ).length != 0 ) {
2785 - _this.monitor();
2786 - //$j( '#' + _this.id ).get( 0 ).monitor();
2787 - }
2788 - }, 250 );
2789 - }
2790 - }
27912746 this.runHook( 'monitor' );
2792 - },
 2747+ },
27932748
27942749 /**
2795 - * Stop the playback monitor
2796 - */
2797 - stopMonitor:function() {
2798 - if ( this.monitorTimerId != 0 ) {
2799 - clearInterval( this.monitorTimerId );
2800 - this.monitorTimerId = 0;
2801 - }
2802 - },
2803 -
2804 - /**
28052750 * Update the buffer status based on the local bufferedPercent var
28062751 */
28072752 updateBufferStatus: function() {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/binPlayers/cortado/cortado-january.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/binPlayers/cortado/cortado-january.jar
___________________________________________________________________
Name: svn:executable
28082753 + *
Name: svn:mime-type
28092754 + application/octet-stream
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js
@@ -73,9 +73,10 @@
7474 newDoc.write( '<html><body>' + appletCode + '</body></html>' );
7575 // spurious error in some versions of FF, no workaround known
7676 newDoc.close();
77 - } else {*/
 77+ } else {
7878 $j( this ).html( appletCode );
7979 //}
 80+ */
8081
8182 // Start the monitor:
8283 this.monitor();
@@ -86,15 +87,15 @@
8788 */
8889 getAppletLocation: function() {
8990 var mediaSrc = this.getSrc()
90 - if ( mediaSrc.indexOf( '://' ) != -1 & !mw.isLocalDomain( mediaSrc ) ) {
 91+ if ( !mw.isLocalDomain( mediaSrc ) ) {
9192 if ( window.cortadoDomainLocations[ mw.parseUri( mediaSrc ).host ] ) {
92 - applet_loc = window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host];
 93+ applet_loc = window.cortadoDomainLocations[ mw.parseUri( mediaSrc ).host ];
9394 } else {
9495 applet_loc = 'http://theora.org/cortado.jar';
9596 }
9697 } else {
9798 // should be identical to cortado.jar
98 - applet_loc = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
 99+ applet_loc = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/cortado/cortado-january.jar';
99100 }
100101 return applet_loc;
101102 },
@@ -107,10 +108,10 @@
108109 if ( this.playerElement ) {
109110 try {
110111 // java reads ogg media time.. so no need to add the start or seek offset:
111 - mw.log(' ct: ' + this.playerElement.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
112 - this.currentTime = this.playerElement.getPlayPosition();
113 - if ( this.playerElement.getPlayPosition() < 0 ) {
114 - mw.log( 'pp:' + this.playerElement.getPlayPosition() );
 112+ //mw.log(' ct: ' + this.playerElement.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
 113+ this.currentTime = this.playerElement.currentTime;
 114+ if ( this.currentTime < 0 ) {
 115+ mw.log( 'pp:' + this.currentTime );
115116 // Probably reached clip end
116117 this.onClipDone();
117118 }
@@ -120,7 +121,7 @@
121122 }else{
122123 mw.log(" could not find playerElement " );
123124 }
124 - // Once currentTime is updated call parent_monitor
 125+ // Once currentTime is updated call parent_monitor
125126 this.parent_monitor();
126127 },
127128
@@ -137,8 +138,8 @@
138139 this.parent_doSeek( percentage );
139140 } else if ( this.playerElement ) {
140141 // do a (generally broken) local seek:
141 - mw.log( "cortado javascript seems to always fail ... but here we go... doSeek(" + ( percentage * parseFloat( this.getDuration() ) ) );
142 - this.playerElement.doSeek( percentage * parseFloat( this.getDuration() ) );
 142+ mw.log( "Cortado seek is not very accurate :: doSeek(" + ( percentage * parseFloat( this.getDuration() ) ) );
 143+ this.playerElement.currentTime = ( percentage * parseFloat( this.getDuration() ) );
143144 } else {
144145 this.doPlayThenSeek( percentage );
145146 }
@@ -175,10 +176,13 @@
176177 * Update the playerElement instance with a pointer to the embed object
177178 */
178179 getPlayerElement:function() {
 180+ //this.playerElement = $j( '#' + this.pid ).get( 0 );
 181+ this.playerElement = document.applets[ 0 ];
 182+ // NOTE we are currently not using the iframe embed method:
179183 //if ( $j.browser.mozilla ) {
180184 // this.playerElement = $j('#cframe_' + this.id).contents().find( '#' + this.pid );
181185 //} else {
182 - this.playerElement = $j( '#' + this.pid ).get( 0 );
 186+ // this.playerElement = $j( '#' + this.pid ).get( 0 );
183187 //}
184188 },
185189
@@ -189,7 +193,7 @@
190194 play: function() {
191195 this.getPlayerElement();
192196 this.parent_play();
193 - if ( this.playerElement && this.playerElement.play ) {
 197+ if ( this.playerElement ) {
194198 this.playerElement.play();
195199 }
196200 },
@@ -203,7 +207,7 @@
204208 // Update the interface
205209 this.parent_pause();
206210 // Call the pause function if it exists:
207 - if ( this.playerElement && this.playerElement.pause ) {
 211+ if ( this.playerElement ) {
208212 this.playerElement.pause();
209213 }
210214 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -217,11 +217,10 @@
218218 /**
219219 * Monitor the video playback & update the currentTime
220220 */
221 - monitor: function() {
 221+ monitor: function() {
222222 this.getPlayerElement(); // make sure we have .vid obj
223223 if ( !this.playerElement ) {
224224 mw.log( 'could not find video embed: ' + this.id + ' stop monitor' );
225 - this.stopMonitor();
226225 return false;
227226 }
228227
@@ -235,6 +234,7 @@
236235
237236 /**
238237 * Get video src URI
 238+ * appends this.urlAppend for unique urls for re-requesting src urls on broken playback
239239 */
240240 getSrc: function() {
241241 var src = this.parent_getSrc();
@@ -253,8 +253,6 @@
254254 if ( this.playerElement ) {
255255 this.playerElement.pause();
256256 }
257 - // stop updates:
258 - this.stopMonitor();
259257 },
260258
261259 /**
@@ -346,6 +344,7 @@
347345 */
348346 getPlayerElement : function () {
349347 this.playerElement = $j( '#' + this.pid ).get( 0 );
 348+ return this.playerElement;
350349 },
351350
352351 /**
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -1,3 +1,7 @@
 2+// Add support for html5 / mwEmbed elements to IE ( must come before js code )
 3+// For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
 4+/*@cc_on'video source itext playlist'.replace(/\w+/g,function(n){document.createElement(n)})@*/
 5+
26 /**
37 * ~mwEmbed ~
48 * For details see: http://www.mediawiki.org/wiki/MwEmbed

Status & tagging log