r63381 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63380‎ | r63381 | r63382 >
Date:06:46, 8 March 2010
Author:dale
Status:deferred
Tags:
Comment:
* improved IE support for flash kplayer fallback
* other general IE fixes for add-media-wizard uploading ( appears IE8 does not like iframe proxy so sendMsg will probably have to be used )
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/ReceiveMessage.html (deleted) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.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
@@ -610,28 +610,22 @@
611611 }
612612
613613 // See if we have native support for ogg:
614 - var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( 'video/ogg' );
615 - for ( var i = 0; i < supporting_players.length; i++ ) {
616 - if ( supporting_players[i].id == 'oggNative' ) {
 614+ var supportingPlayers = mw.EmbedTypes.players.getMIMETypePlayers( 'video/ogg' );
 615+ for ( var i = 0; i < supportingPlayers.length; i++ ) {
 616+ if ( supportingPlayers[i].id == 'oggNative' ) {
617617 return false;
618618 }
619619 }
620620
621 - // See if we are using mwEmbed without a ogg source in which case no point in promoting firefox :P
622 - if ( this.embedPlayer.mediaElement && this.embedPlayer.mediaElement.sources ) {
623 - var foundOgg = false;
624 - var playable_sources = this.embedPlayer.mediaElement.getPlayableSources();
625 - for ( var sInx = 0; sInx < playable_sources.length; sInx++ ) {
626 - var mime_type = playable_sources[sInx].mime_type;
627 - if ( mime_type == 'video/ogg' ) {
628 - foundOgg = true;
629 - }
630 - }
631 - // No ogg src... no point in download firefox link
632 - if ( !foundOgg ){
633 - return false;
634 - }
 621+ // Check for h264 source and playback support
 622+ var supportingPlayers = mw.EmbedTypes.players.getMIMETypePlayers( 'video/h264' );
 623+ var h264streams = this.embedPlayer.mediaElement.getSources( 'video/h264' );
 624+ if( supportingPlayers.length && h264streams.length ){
 625+ // No firefox link if a h.264 stream is present
 626+ return false;
635627 }
 628+
 629+ // Should issue the native warning
636630 return true;
637631 },
638632
@@ -1050,16 +1044,16 @@
10511045 if ( playable ) {
10521046 $playerList = $j('<ul />');
10531047 // output the player select code:
1054 - var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( source.getMIMEType() );
 1048+ var supportingPlayers = mw.EmbedTypes.players.getMIMETypePlayers( source.getMIMEType() );
10551049
1056 - for ( var i = 0; i < supporting_players.length ; i++ ) {
 1050+ for ( var i = 0; i < supportingPlayers.length ; i++ ) {
10571051
10581052 // Add link to select the player if not already selected )
1059 - if( embedPlayer.selected_player.id == supporting_players[i].id && is_selected ) {
 1053+ if( embedPlayer.selected_player.id == supportingPlayers[i].id && is_selected ) {
10601054 // Active player ( no link )
10611055 $playerLine = $j( '<span />' )
10621056 .text(
1063 - supporting_players[i].getName()
 1057+ supportingPlayers[i].getName()
10641058 )
10651059 .addClass( 'ui-state-highlight ui-corner-all' );
10661060 } else {
@@ -1068,10 +1062,10 @@
10691063 .attr({
10701064 'href' : '#',
10711065 'rel' : 'sel_source',
1072 - 'id' : 'sc_' + source_id + '_' + supporting_players[i].id
 1066+ 'id' : 'sc_' + source_id + '_' + supportingPlayers[i].id
10731067 })
10741068 .addClass( 'ui-corner-all')
1075 - .text( supporting_players[i].getName() )
 1069+ .text( supportingPlayers[i].getName() )
10761070 .click( function() {
10771071 var iparts = $j( this ).attr( 'id' ).replace(/sc_/ , '' ).split( '_' );
10781072 var source_id = iparts[0];
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -887,7 +887,7 @@
888888 $j( _this.selector ).after(
889889 $j('<div />')
890890 .attr({
891 - 'id' : "mw-spinner-wpDestFile",
 891+ 'id' : "mw-spinner-wpDestFile"
892892 })
893893 .loadingSpinner()
894894 );
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js
@@ -363,7 +363,7 @@
364364 .css({
365365 'position' : 'relative',
366366 'top' : '-' + resource.crop.y,
367 - 'left': '-' + resource.crop.x,
 367+ 'left': '-' + resource.crop.x
368368 })
369369 .append( $img )
370370 )
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js
@@ -17,7 +17,7 @@
1818 "mwe-upload-in-progress" : "Upload in progress (do not close this window)",
1919 "mwe-uploaded-status" : "Uploaded",
2020 "mwe-uploaded-time-remaining" : "Time remaining: $1",
21 - "mwe-upload-done" : "Your upload <i>should be<\/i> accessible.",
 21+ "mwe-upload-done" : "Your upload <i>should be<\/i> accessible."
2222 } );
2323
2424 /**
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js
@@ -22,38 +22,11 @@
2323 */
2424 doEmbedHTML : function () {
2525 var _this = this;
26 - var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player';
 26+ var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player';
2727
28 -
29 - /*$j( this ).html(
30 - '<object width="' + this.getWidth() + '" height="' + this.getHeight() + '" ' +
31 - 'data="' + playerPath + '/wrapper.swf" allowfullscreen="true" ' +
32 - 'allownetworking="all" allowscriptaccess="always" ' +
33 - 'type="application/x-shockwave-flash" ' +
34 - 'flashVars="kdpUrl=' + playerPath + '/kdp.swf' +
35 - '&ks=dummy&partner_id=0&subp_id=0' +
36 - '&uid=0&emptyF=onKdpEmpty&readyF=onKdpReady' +
37 - '" '+
38 - 'wmode="opaque" ' +
39 - 'id="' + this.pid + '" name="' + this.pid + '">' +
40 - '<param value="always" name="allowScriptAccess"/>' +
41 - '<param value="all" name="allowNetworking"/>' +
42 - '<param value="true" name="allowFullScreen"/>' +
43 - '<param value="#000000" name="bgcolor"/>' +
44 - '<param value="wrapper.swf" name="movie"/>' +
45 - '<param value="' +
46 - 'kdpUrl=' + playerPath + '/kdp.swf' +
47 - '&ks=dummy&partner_id=0&subp_id=0' +
48 - '&uid=0&emptyF=onKdpEmpty&readyF=onKdpReady' +
49 - '" ' +
50 - 'name="flashVars"/>' +
51 - '<param value="opaque" name="wmode"/>' +
52 - '</object>'
53 - )*/
54 -
5528 var flashvars = {};
5629 flashvars.autoPlay = "true";
57 - flashvars.entryId = _this.getSrc();
 30+ flashvars.entryId = mw.absoluteUrl( _this.getSrc() );
5831 flashvars.debugMode = "true";
5932 flashvars.fileSystemMode = "true";
6033 flashvars.widgetId = "_7463";
@@ -62,7 +35,7 @@
6336 flashvars.kml = "local";
6437 flashvars.kmlPath = playerPath + '/config.xml';
6538 flashvars.sourceType = "url";
66 - flashvars.host = "www.kaltura.com";
 39+ //flashvars.host = "www.kaltura.com";
6740 flashvars.externalInterfaceDisabled = 'false';
6841
6942 var params = {};
@@ -72,16 +45,32 @@
7346 params.allowscriptaccess = "sameDomain";
7447
7548 var attributes = {};
76 - attributes.id = 'vid1';
77 - attributes.name = "kdp3";
78 - attributes.styleclass = "player";
79 - debugger;
80 - swfobject.embedSWF( playerPath + "/kdp3.swf", "kdp3", "790", "466", "10.0.0", playerPath +"/expressInstall.swf", flashvars, params, attributes);
 49+ attributes.id = this.pid;
 50+ attributes.name = this.pid;
 51+ attributes.styleclass = "player";
8152
82 -
 53+ $j( this ).html(
 54+ $j('<div />')
 55+ .attr( 'id', this.pid + '_container' )
 56+ );
 57+
 58+ // Do the flash embeding with embedSWF
 59+ swfobject.embedSWF(
 60+ playerPath + "/kdp3.swf",
 61+ this.pid + '_container',
 62+ this.getWidth(),
 63+ this.getHeight(),
 64+ "10.0.0",
 65+ playerPath + "/expressInstall.swf",
 66+ flashvars,
 67+ params,
 68+ attributes
 69+ );
 70+
8371 setTimeout(function() {
8472 _this.postEmbedJS();
85 - }, 50);
 73+ }, 250 );
 74+
8675 },
8776
8877 /**
@@ -90,34 +79,22 @@
9180 postEmbedJS:function() {
9281 var _this = this;
9382 this.getPlayerElement();
94 - //alert( this.playerElement );
95 - if( this.playerElement && this.playerElement.insertMedia) {
96 - // Add KDP listeners
97 -
98 - //this.playerElement.addJsListener("doPlay","kdpDoOnPlay");
99 - //this.playerElement.addJsListener("doStop","kdpDoOnStop");
100 - //myKdp.addJsListener("fastForward","kdpDoOnFF");
10183
 84+ //alert( this.playerElement );
 85+ if( this.playerElement ) {
 86+ // Add KDP listeners
10287 _this.bindPlayerFunction( 'doPause', 'onPause' );
10388 _this.bindPlayerFunction( 'doPlay', 'play' );
10489 _this.bindPlayerFunction( 'playerPlayEnd', 'onClipDone' );
105 -
106 - // KDP player likes an absolute url for the src:
107 - var src = mw.absoluteUrl( _this.getSrc() );
108 - mw.log('play src: ' + src);
109 -
110 - // Insert the src:
111 - this.playerElement.insertMedia( "-1", src, 'true' );
112 - this.playerElement.dispatchKdpEvent( 'doPlay' );
113 -
 90+ _this.bindPlayerFunction( 'playerUpdatePlayhead', 'onUpdatePlayhead' );
11491 // Start the monitor
11592 this.monitor();
11693 }else{
117 - // Keep trying to get the html:
 94+ // Keep trying to get the player element
11895 //mw.log('insert media: not defiend:' + typeof this.playerElement.insertMedia );
11996 setTimeout( function() {
12097 _this.postEmbedJS();
121 - }, 25);
 98+ }, 250);
12299 }
123100 },
124101
@@ -131,7 +108,7 @@
132109 */
133110 bindPlayerFunction:function( bName, fName ) {
134111 var cbid = fName + '_cb_' + this.id.replace(' ', '_');
135 - eval( 'window[ \'' + cbid +'\' ] = function() {$j(\'#' + this.id + '\').get(0).'+ fName +'();}' );
 112+ eval( 'window[ \'' + cbid +'\' ] = function( data ) {$j(\'#' + this.id + '\').get(0).'+ fName +'( data );}' );
136113 this.playerElement.addJsListener( bName , cbid);
137114 },
138115
@@ -148,8 +125,8 @@
149126 * calls parent_play to update the interface
150127 */
151128 play:function() {
152 - if( this.playerElement && this.playerElement.dispatchKdpEvent )
153 - this.playerElement.dispatchKdpEvent('doPlay');
 129+ if( this.playerElement && this.playerElement.sendNotification )
 130+ this.playerElement.sendNotification( 'doPlay' );
154131 this.parent_play();
155132 },
156133
@@ -158,7 +135,7 @@
159136 * calls parent_pause to update the interface
160137 */
161138 pause:function() {
162 - this.playerElement.dispatchKdpEvent('doPause');
 139+ this.playerElement.sendNotification('doPause');
163140 this.parent_pause();
164141 },
165142
@@ -169,7 +146,7 @@
170147 var _this = this;
171148 if( this.playerElement ) {
172149 var seek_time = prec * this.getDuration();
173 - this.playerElement.dispatchKdpEvent('doSeek', seek_time);
 150+ this.playerElement.sendNotification('doSeek', seek_time);
174151 // Kdp is missing seek done callback
175152 setTimeout(function() {
176153 _this.seeking= false;
@@ -182,21 +159,24 @@
183160 * Issues a volume update to the playerElement
184161 */
185162 updateVolumen:function( percentage ) {
186 - if( this.playerElement && this.playerElement.dispatchKdpEvent )
187 - this.playerElement.dispatchKdpEvent('volumeChange', percentage);
 163+ if( this.playerElement && this.playerElement.sendNotification )
 164+ this.playerElement.sendNotification('volumeChange', percentage);
188165 },
189166
190167 /**
191 - * Monitors playback updating the current Time
192 - */
193 - monitor:function() {
194 - if( this.playerElement && this.playerElement.getMediaSeekTime ) {
195 - this.currentTime = this.playerElement.getMediaSeekTime();
196 - }
197 - this.parent_monitor();
 168+ * function called by flash at set interval to update the playhead.
 169+ */
 170+ onUpdatePlayhead : function ( playheadValue ){
 171+ this.currentTime = playheadValue;
198172 },
199173
200174 /**
 175+ * We just use the parent monitor since currentTime is updated by push binding.
 176+ * monitor: function(){
 177+ * }
 178+ */
 179+
 180+ /**
201181 * Get the embed fla object player Element
202182 */
203183 getPlayerElement: function () {
@@ -214,8 +194,12 @@
215195
216196
217197
 198+
218199 /*! SWFObject v2.2 <http://code.google.com/p/swfobject/>
219200 is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
 201+*
 202+* NOTE: we should seperate this out into a seperate file. It requires some minor
 203+* refactoring in how embedPlayer[s] are loaded.
220204 */
221205
222206 var swfobject = function() {
@@ -991,3 +975,4 @@
992976 }
993977 };
994978 }();
 979+
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/ReceiveMessage.html
@@ -1,12 +0,0 @@
2 -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 -<html>
4 -<head>
5 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 -<title>iFrame message receiver</title>
7 -<script type="text/javascript">
8 -</script>
9 -</head>
10 -<body>
11 -iFrame message receiver. ( no javascript just a valid html file to get hash url updates )
12 -</body>
13 -</html>
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js
@@ -755,7 +755,7 @@
756756 .attr({
757757 'type' : 'hidden',
758758 'id' : "wpEditToken",
759 - 'name' : 'token',
 759+ 'name' : 'token'
760760 })
761761 .val( clientRequest.token )
762762 )
@@ -960,9 +960,9 @@
961961 if( ! options[ 'target' ] ){
962962 options[ 'target' ] = 'body';
963963 }
964 - var nameTarget = ( typeof options[ 'target' ] == 'string') ? options[ 'target' ] : $j( options[ 'target' ]).length ;
965 - mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + nameTarget + " \n WITH REQUEST: " + JSON.stringify( options.request ) );
 964+ var targetName = ( typeof options[ 'target' ] == 'string') ? options[ 'target' ] : $j( options[ 'target' ]).length ;
966965
 966+ mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + targetName + " \n WITH REQUEST: " + JSON.stringify( options.request ) );
967967 // Append to target
968968 $j( options[ 'target' ] ).append( s );
969969
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js
@@ -5,7 +5,7 @@
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
88 var mwRemoteVersion = 'r104';
9 -var mwUseScriptLoader = true;
 9+var mwUseScriptLoader = false;
1010
1111 // Log the mwRemote version ( will determine what version of js we get )
1212 if( window.console ){
@@ -117,12 +117,16 @@
118118 // Special api proxy page
119119 if ( wgPageName == 'MediaWiki:ApiProxy' ) {
120120 var wgEnableIframeApiProxy = true;
 121+ alert( " MediaWiki:ApiProxy rewrite " );
121122 loadMwEmbed( [ 'mw.ApiProxy' ], function() {
122123 mw.load( mwEmbedHostPath + '/apiProxyPage.js?' + mwGetReqArgs() );
123124 } );
124125 }
 126+
 127+ // Special api proxy page for nested callback of hash url
 128+ // Can be replaced with:
125129 if ( wgPageName == 'MediaWiki:ApiProxyNestedCb' ) {
126 - // Note top.mw.ApiProxy.nested frame needs to be on the same domain of course
 130+ // Note top.mw.ApiProxy.nested frame needs to be on the same domain
127131 top.mw.ApiProxy.nested( window.location.href.split("#")[1] || false );
128132 }
129133

Status & tagging log