r74011 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74010‎ | r74011 | r74012 >
Date:02:30, 30 September 2010
Author:dale
Status:deferred
Tags:
Comment:
minor fixes to add media wizard, temp stopped ui binding, sync with kaltura svn updates.
Modified paths:
  • /branches/MwEmbedStandAlone/ResourceLoader.php (modified) (history)
  • /branches/MwEmbedStandAlone/includes/noMediaWikiConfig.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerHtml.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerJava.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/mw.PlaylistHandlerMediaRss.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerMenu.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SwarmTransport/tests/SwarmTransprot_Url.html (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
@@ -188,7 +188,7 @@
189189 .mv-player .play-btn-large {
190190 width : 130px;
191191 height : 96px;
192 - background : url(images/player_big_play_button.png) !important;
 192+ background : url(images/player_big_play_button.png);
193193 position : absolute;
194194 cursor : pointer;
195195 border : none !important;
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -107,11 +107,20 @@
108108 }
109109 return ;
110110 }
111 - // Only update the controls if undefined ( ie don't override false
112 - // properties )
113 - if( typeof mwConfig[ name ] == 'undefined') {
114 - mwConfig[ name ] = value;
 111+ // Only update the controls if undefined
 112+
 113+ if( typeof mwConfig[ name ] == 'undefined' ) {
 114+ mwConfig[ name ] = value;
 115+ return ;
115116 }
 117+ // Check if we should "merge" the config
 118+ if( typeof value == 'object' && typeof mwConfig[ name ] == 'object' ) {
 119+ for( var i in value ){
 120+ if( typeof mwConfig[ name ][ i ] == 'undefined' ){
 121+ mwConfig[ name ][ i ] = value[ i ];
 122+ }
 123+ }
 124+ }
116125 };
117126
118127 /**
Index: branches/MwEmbedStandAlone/ResourceLoader.php
@@ -16,14 +16,19 @@
1717
1818 // Check if we are an entry point or being used as part of MEDIAWIKI:
1919 if ( !defined( 'MEDIAWIKI' ) && !defined( 'SCRIPTLOADER_MEDIAWIKI') ) {
 20+ // Load stand alone Resource Loader config
 21+ // ( if running as a remote, mediaWiki variables / functions are already included as part of mediaWiki )
 22+ require_once( realpath( dirname( __FILE__ ) ) . '/includes/noMediaWikiConfig.php' );
 23+
 24+ // Allow an installation an optional PHP customization/overrides file
 25+ if ( is_file ( dirname( __FILE__ ) .'/../localSettings.php' ) ) {
 26+ require_once dirname( __FILE__ ) .'/../localSettings.php';
 27+ }
 28+
2029 $myResourceLoader = new ResourceLoader();
2130 if( $myResourceLoader->outputFromCache() ) {
2231 exit();
2332 }
24 - // No cache hit, load stand alone Resource Loader config
25 -
26 - // ( if running as a remote, mediaWiki variables / functions are already included as part of mediaWiki )
27 - require_once( realpath( dirname( __FILE__ ) ) . '/includes/noMediaWikiConfig.php' );
2833 $myResourceLoader->doResourceLoader();
2934 }
3035
Index: branches/MwEmbedStandAlone/includes/noMediaWikiConfig.php
@@ -82,10 +82,12 @@
8383 return false;
8484 }
8585
86 -function wfTempDir(){
87 - return realpath( dirname( __FILE__ ) ) . '/includes/cache';
 86+if (!function_exists('wfTempDir'))
 87+{
 88+ function wfTempDir(){
 89+ return realpath( dirname( __FILE__ ) ) . '/includes/cache';
 90+ }
8891 }
89 -
9092 /**
9193 * Make directory, and make all parent directories if they don't exist
9294 *
Index: branches/MwEmbedStandAlone/modules/Playlist/mw.PlaylistHandlerMediaRss.js
@@ -72,7 +72,7 @@
7373 callback( clipSources );
7474 },
7575
76 - getCustomClipAttributes: function( clipIndex ){
 76+ applyCustomClipData: function( embedPlayer, clipIndex ){
7777 return {};
7878 },
7979
Index: branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js
@@ -129,10 +129,10 @@
130130 );
131131 $j( _this.target ).append( $plListContainer );
132132
133 - var $plListSet = $j( _this.target ).find( '.playlistSet-list' );
 133+ var $plListSet = $j( _this.target ).find( '.playlistSet-list' );
134134
135135 $j.each( playlistSet, function( inx, playlist){
136 - // add a divider
 136+ // Add a divider
137137 if( inx != 0 ){
138138 $plListSet.append( $j('<span />').text( ' | ') )
139139 }
@@ -264,7 +264,7 @@
265265 var myScroll = iScroll( _this.id + '_videolist' );
266266 setTimeout(function () { myScroll.refresh(); }, 0);
267267 */
268 - // add space for scroll buttons:
 268+ // Add space for scroll buttons:
269269 var curTop = $j( _this.target + ' .media-rss-video-list' ).css('top');
270270 if(!curTop) curTop = '0px';
271271 $j( _this.target + ' .media-rss-video-list' ).css( {
@@ -276,7 +276,7 @@
277277 })
278278 if( _this.layout == 'vertical' ){
279279 $j( _this.target + ' .media-rss-video-list' ).css({
280 - 'top' : $j( _this.target + ' .media-rss-video-player' ).height()
 280+ 'top' : $j( _this.target + ' .media-rss-video-player' ).height() + 8
281281 })
282282 }
283283 // Add scroll buttons:
@@ -404,17 +404,19 @@
405405
406406 // Build the video tag object:
407407 var $video = $j( '<video />' )
408 - .attr({
409 - 'id' : 'mrss_' + this.id + '_' + clipIndex,
410 - 'poster' : _this.sourceHandler.getClipPoster( clipIndex )
411 - })
412 - .addClass( 'mwPlaylist' )
413 - .css(
414 - playerSize
415 - )
416 - // Add custom attributes:
417 - .attr( _this.sourceHandler.getCustomClipAttributes( clipIndex ) );
 408+ .attr({
 409+ 'id' : _this.getVideoPlayerId( clipIndex ),
 410+ 'poster' : _this.sourceHandler.getClipPoster( clipIndex )
 411+ })
 412+ .addClass( 'mwPlaylist' )
 413+ .css(
 414+ playerSize
 415+ )
418416
 417+ // Add custom attributes:
 418+ _this.sourceHandler.applyCustomClipData( $video, clipIndex );
 419+
 420+
419421 // lookup the sources from the playlist provider:
420422 this.sourceHandler.getClipSources( clipIndex, function( clipSources ){
421423 if( clipSources ){
@@ -424,39 +426,61 @@
425427 $video.append( $source );
426428 }
427429 }
428 - _this.addVideoPlayer( $video , callback);
 430+ _this.updateVideoPlayer( $video , callback);
429431 });
430432 },
431433
432 - addVideoPlayer: function( $video , callback){
433 - var _this = this;
 434+ getVideoPlayerId: function( clipIndex ){
 435+ if( ! clipIndex ) {
 436+ clipIndex = this.clipIndex;
 437+ }
 438+ return 'mrss_' + this.id + '_' + clipIndex;
 439+ },
 440+
 441+ updateVideoPlayer: function( $video , callback){
 442+ var _this = this;
434443 // If on mobile safari just swap the sources ( don't replace the video )
435444 // ( mobile safari can't javascript start the video )
436445 // see: http://developer.apple.com/iphone/search/search.php?simp=1&num=10&Search=html5+autoplay
437 - var addVideoPlayerToDom = true;
438 - if( mw.isMobileHTML5() ){
 446+ var updateVideoPlayerToDom = true;
 447+
 448+ if( mw.isMobileHTML5() ){
439449 // Check for a current video:
440450 var $inDomVideo = $j( _this.target + ' .media-rss-video-player video' );
441451 if( $inDomVideo.length == 0 ){
442 - addVideoPlayerToDom= true;
 452+ updateVideoPlayerToDom = true;
443453 } else {
444 - addVideoPlayerToDom = false;
 454+ updateVideoPlayerToDom = false;
445455 // Update the inDomVideo object:
446 - // NOTE: this hits a lot of internal stuff should !
 456+ // NOTE: this hits a lot of internal stuff
447457 // XXX Should refactor to use embedPlayer interfaces!
448458 var vidInterface = $j( _this.target + ' .media-rss-video-player' ).find('.mwplayer_interface div').get(0)
449 - vidInterface.id = $video.attr('id');
 459+ // Copy over the video attributes to the the videoInterface
 460+ $j( $video[0].attributes ).each( function(attrName, attrValue){
 461+ vidInterface[ attrName ] = attrValue;
 462+ })
450463 vidInterface.pid = 'pid_' + $video.attr('id');
451 - vidInterface.duration = null;
452 - if( $video.attr('kentryid') ){
453 - vidInterface.kentryid = $video.attr('kentryid');
 464+ // Update the interface restore source ( xxx this is a pretty ugly hack )
 465+ vidInterface.mediaElement.sources = [];
 466+ $video.find('source').each(function(inx, source){
 467+ vidInterface.mediaElement.tryAddSource( source ) ;
 468+ });
 469+
 470+ // Update the video interface id:
 471+ $j( vidInterface ).attr('id', $video.attr('id'));
 472+
 473+
 474+ if( $video.data('kuiconf') ){
 475+ $j( vidInterface ).data( 'kuiconf', $video.data('kuiconf') )
454476 }
 477+
455478 // Update the current video target source
456479 $inDomVideo.attr({
457480 'id' : 'pid_' + $video.attr('id'),
458481 'src': $video.find( 'source').attr('src')
459482 });
460 -
 483+ // issue the load request
 484+ $inDomVideo.get(0).load();
461485 }
462486 } else {
463487 // Remove the old video player ( non-mobile safari )
@@ -464,16 +488,18 @@
465489 $j( _this.target + ' .media-rss-video-player' ).remove( 'video' );
466490 }
467491
468 - if( addVideoPlayerToDom ) {
 492+ if( updateVideoPlayerToDom ) {
469493 // replace the video:
470494 $j( _this.target + ' .media-rss-video-player' ).append( $video );
471495 }
472496
473497 // Update the video tag with the embedPlayer
474 - $j.embedPlayers( function(){
 498+ $j.embedPlayers( function(){
 499+ var embedPlayer = $j('#' +_this.getVideoPlayerId( _this.clipIndex ) ).get(0);
 500+
475501 // Setup ondone playing binding to play next clip (if autoContinue is true )
476502 if( _this.sourceHandler.autoContinue == true ){
477 - $j( '#mrss_' + _this.id + '_' + _this.clipIndex ).unbind('ended').bind( 'ended', function(event, onDoneActionObject ){
 503+ $j( embedPlayer ).unbind('ended').bind( 'ended', function(event, onDoneActionObject ){
478504 // Play next clip
479505 if( _this.clipIndex + 1 < _this.sourceHandler.getClipCount() ){
480506 // Update the onDone action object to not run the base control done:
@@ -492,6 +518,7 @@
493519 }
494520 })
495521 }
 522+ mw.log("player should be readY: " + _this.clipIndex + ' ' + $j('#' +_this.getVideoPlayerId() ) );
496523 // Run the callback if its set
497524 if( callback ){
498525 callback();
@@ -561,11 +588,19 @@
562589 } )
563590 .click( function(){
564591 mw.log( 'clicked on: ' + $j( this ).data( 'clipIndex') );
 592+ // Make sure the existing player is "playing " (safari can't play async with javascript )
 593+ /*if( mw.isMobileHTML5() ){
 594+ var embedPlayer = $j('#' + _this.getVideoPlayerId() ).get(0);
 595+ //embedPlayer.playerElement.play();
 596+ }*/
 597+
565598 // Update _this.clipIndex
566599 _this.clipIndex = $j( this ).data( 'clipIndex' );
 600+
567601 _this.updatePlayer( _this.clipIndex, function(){
568602 _this.play();
569603 } );
 604+
570605 }) //close $itemBlock
571606
572607 // Add the itemBlock to the targetItem list
@@ -574,22 +609,17 @@
575610 )
576611 mw.log("added item block : " + $targetItemList.children().length );
577612 });
578 - },
 613+ },
579614
580 - /**
581 - * Start playback for current clip
582 - */
583615 play: function(){
584 - // Get the player and play:
585 - var vid = $j('#mrss_' + this.id + '_' + this.clipIndex ).get(0);
586 - //alert( 'play: '+ )
587 - if( vid && vid.play ){
588 - vid.load();
589 - vid.play();
 616+ var embedPlayer = $j('#' + this.getVideoPlayerId() ).get(0);
 617+ if( mw.isMobileHTML5() ){
 618+ embedPlayer.playerElement.play();
 619+ } else{
 620+ embedPlayer.play();
590621 }
591622 },
592623
593 -
594624 /**
595625 * Load the playlist driver from a source
596626 */
Index: branches/MwEmbedStandAlone/modules/SwarmTransport/tests/SwarmTransprot_Url.html
@@ -25,7 +25,7 @@
2626 <table border="1" cellpadding="6" width="950">
2727
2828 <tr>
29 - <td id="apiExample" valign="top" width="410">
 29+ <td valign="top" width="410">
3030 <video
3131 poster="http://footage.stealthisfilm.com/video/5/frame/0:03:56.640.jpg"
3232 src="http://footage.stealthisfilm.com/stream/Yochai%20Benkler%20-%20On%20Autonomy%2C%20Control%20and%20Cultureal%20Experience.ogg"
@@ -35,13 +35,13 @@
3636 <td valign="top">
3737 Simple Video Tag usage<br>
3838
39 - <textarea id="apiExampleTextArea" style="width:600px;height:180px">
 39+ <textarea style="width:600px;height:180px">
4040 <video
4141 poster="http://footage.stealthisfilm.com/video/5/frame/0:03:56.640.jpg"
4242 src="http://footage.stealthisfilm.com/stream/Yochai%20Benkler%20-%20On%20Autonomy%2C%20Control%20and%20Cultureal%20Experience.ogg"
4343 class="kskin">
4444 <track srclang="en" src="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultural_Experience.srt" />
45 -</video>
 45+</video>s
4646 </textarea>
4747 </td>
4848 </tr>
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -280,7 +280,7 @@
281281 'apiUrl': ( wgServer && wgScriptPath ) ?
282282 wgServer + wgScriptPath + '/api.php' : null,
283283
284 - 'detailsUrl' : wgServer + wgArticlePath,
 284+ 'detailsUrl' : ( wgServer && wgArticlePath )? wgServer + wgArticlePath : null,
285285
286286 'lib': 'mediaWiki',
287287 'homepage' : ( wgServer && wgScript ) ?
@@ -866,8 +866,8 @@
867867 bgiframe: true,
868868 autoOpen: true,
869869 modal: true,
870 - width: $j(window).width()-10,
871 - height: $j(window).height()-10,
 870+ width: $j(window).width()-50,
 871+ height: $j(window).height()-50,
872872 position : 'center',
873873 draggable: false,
874874 resizable: false,
@@ -2029,7 +2029,7 @@
20302030 'position' : 'absolute',
20312031 'top' : '0px',
20322032 'left' : '0px',
2033 - 'bottom' : '0px',
 2033+ 'bottom' : '30px',
20342034 'right' : '4px',
20352035 'background-color' : '#FFF'
20362036 } )
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js
@@ -177,10 +177,10 @@
178178 // Add JSON lib if browsers does not define "JSON" natively
179179 'JSON',
180180 '$j.ui',
181 - '$j.widget',
182 - '$j.ui.mouse'
 181+ '$j.widget'
183182 ],
184 - [
 183+ [
 184+ '$j.ui.mouse',
185185 '$j.fn.menu',
186186 'mw.style.jquerymenu',
187187 '$j.ui.slider'
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -12,11 +12,10 @@
1313 */
1414
1515 mw.includeAllModuleMessages();
16 -
1716 /*
1817 * The default video attributes supported by embedPlayer
1918 */
20 -mw.setConfig( 'EmbedPlayer.Attributes', {
 19+mw.setDefaultConfig( 'EmbedPlayer.Attributes', {
2120 /*
2221 * Base html element attributes:
2322 */
@@ -231,10 +230,14 @@
232231 attributes = {};
233232 }
234233
235 -
236 - // If we are dynamically embedding on a "div" check if we can
237 - // add a poster image behind the loader:
238234 $j( playerSelect ).each( function( index, playerElement) {
 235+ // make sure the playerElement has an id:
 236+ if( $j( playerElement ).attr('id') =='' ){
 237+ $j( playerElement ).attr( "id", 'mwe_v' + ( index ) );
 238+ }
 239+
 240+ // If we are dynamically embedding on a "div" check if we can
 241+ // add a poster image behind the loader:
239242 if( playerElement.nodeName.toLowerCase() == 'div'
240243 && ( attributes.poster || $j(playerElement).attr( 'poster' ) ) ){
241244 var posterSrc = ( attributes.poster ) ? attributes.poster : $j(playerElement).attr( 'poster' );
@@ -402,7 +405,7 @@
403406 // Let extensions determine if its worthwhile to wait for metadata:
404407 // We pass an object to the trigger to preserve reference values
405408 var eventObject = {
406 - 'playerElement':playerElement,
 409+ 'playerElement' : playerElement,
407410 'waitForMeta' : waitForMeta
408411 };
409412 $j( mw ).trigger( 'addElementWaitForMetaEvent', eventObject );
@@ -426,13 +429,21 @@
427430 ranPlayerSwapFlag = true;
428431 mw.log("EmbedPlayer::runPlayerSwap::" + $j( playerElement ).attr('id') );
429432
430 - var playerInterface = new mw.EmbedPlayer( playerElement , attributes);
 433+ var playerInterface = new mw.EmbedPlayer( playerElement , attributes);
 434+ var swapPlayer = _this.swapEmbedPlayerElement( playerElement, playerInterface );
431435
432 - _this.swapEmbedPlayerElement( playerElement, playerInterface );
433 -
 436+ // Copy over any data attributes from the playerElement
 437+ if( mw.getConfig( 'EmbedPlayer.DataAttributes' ) ) {
 438+ var dataAttr = mw.getConfig( 'EmbedPlayer.DataAttributes' )
 439+ for( var i in dataAttr ){
 440+ if( $j( playerElement ).data( i ) ){
 441+ $j( '#' + playerInterface.id ).data( i, $j( playerElement ).data( i ) );
 442+ }
 443+ }
 444+ }
434445
435446 // Pass the id to any hook that needs to interface prior to checkPlayerSources
436 - mw.log("EmbedPlayer::addElement :trigger :: newEmbedPlayerEvent");
 447+ mw.log("EmbedPlayer::addElement :trigger " + playerInterface.id );
437448 $j( mw ).trigger ( 'newEmbedPlayerEvent', playerInterface.id );
438449
439450 // Issue the checkPlayerSources call to the new player interface:
@@ -546,7 +557,7 @@
547558 // Create a new element to swap the player interface into
548559 var swapPlayerElement = document.createElement('div');
549560
550 - // get properties / methods from playerInterface
 561+ // Get properties / methods from playerInterface
551562 for ( var method in playerInterface ) {
552563 if ( method != 'readyState' ) { // readyState crashes IE ( don't include )
553564 swapPlayerElement[ method ] = playerInterface[ method ];
@@ -554,13 +565,13 @@
555566 }
556567
557568 // Check if we are using native controls ( should keep the video embed around )
558 - if( playerInterface.shouldUseNativeControls() ) {
 569+ if( playerInterface.useNativePlayerControls() ) {
559570 $j( targetElement )
560 - .attr('id', playerInterface.pid )
 571+ .attr( 'id', playerInterface.pid )
561572 .addClass( 'nativeEmbedPlayerPid' )
562573 .show()
563574 .after(
564 - $j( swapPlayerElement ).css('display', 'none')
 575+ $j( swapPlayerElement ).css( 'display', 'none' )
565576 )
566577 } else {
567578 $j( targetElement ).replaceWith( swapPlayerElement );
@@ -575,7 +586,7 @@
576587
577588 // If we don't already have a loadSpiner add one:
578589 if( $j('#loadingSpinner_' + playerInterface.id ).length == 0 ){
579 - if( playerInterface.shouldUseNativeControls() ) {
 590+ if( playerInterface.useNativePlayerControls() ) {
580591 $j( targetElement )
581592 .getAbsoluteOverlaySpinner()
582593 .attr('id', 'loadingSpinner_' + playerInterface.id )
@@ -586,7 +597,7 @@
587598 );
588599 }
589600 }
590 - return true;
 601+ return swapPlayerElement;
591602 },
592603
593604
@@ -862,7 +873,7 @@
863874
864875 // Return the mime type string if not known type.
865876 return this.mimeType;
866 - },
 877+ },
867878
868879 /**
869880 *
@@ -1357,7 +1368,7 @@
13581369 }
13591370
13601371 var playerAttributes = mw.getConfig( 'EmbedPlayer.Attributes' );
1361 - // Setup the player Interface from supported attributes:
 1372+ // Setup the player Interface from supported attributes:
13621373 for ( var attr in playerAttributes ) {
13631374 if ( customAttributes[ attr ] || customAttributes[ attr ] === false ) {
13641375 this[ attr ] = customAttributes[ attr ];
@@ -1374,14 +1385,14 @@
13751386 // string -> boolean
13761387 if( this[ attr ] == "false" ) this[attr] = false;
13771388 if( this[ attr ] == "true" ) this[attr] = true;
1378 - }
 1389+ }
13791390
13801391 if( this.apiTitleKey ){
13811392 this.apiTitleKey = unescape( this.apiTitleKey );
13821393 }
13831394
13841395 // Hide "controls" if using native player controls:
1385 - if( this.shouldUseNativeControls() ){
 1396+ if( this.useNativePlayerControls() ){
13861397 _this.controls = false;
13871398 }
13881399
@@ -1607,9 +1618,19 @@
16081619 finishCheckPlayerSources();
16091620 }
16101621 },
 1622+ /**
 1623+ * Insert and play a video source ( useful for ads or bumper videos )
 1624+ *
 1625+ * Only works while video is in active play back.
 1626+ * Only tested with native playback atm.
 1627+ */
 1628+ insertAndPlaySource: function( source ){
 1629+ mw.log("Error: only native playback supports insertAndPlaySource right now");
 1630+ },
16111631
16121632 /**
16131633 * Load Source video info from mediaWiki Api title key ( this.apiTitleKey )
 1634+ * @@todo move this to mediaWiki 'api' module
16141635 * @param {Function} callback Function called once loading is complete
16151636 */
16161637 loadSourceFromApi: function( callback ){
@@ -2023,7 +2044,7 @@
20242045 this.controlBuilder.addControlBindings();
20252046
20262047 // Once the thumbnail is shown run the mediaReady trigger (if not using native controls)
2027 - if( !this.shouldUseNativeControls() ){
 2048+ if( !this.useNativePlayerControls() ){
20282049 mw.log("mediaLoaded");
20292050 $j( this ).trigger( 'mediaLoaded' );
20302051 }
@@ -2301,7 +2322,7 @@
23022323 var style_atr = '';
23032324
23042325
2305 - if( this.shouldUseNativeControls() ){
 2326+ if( this.useNativePlayerControls() ){
23062327 this.showNativePlayer();
23072328 return ;
23082329 }
@@ -2342,7 +2363,7 @@
23432364 * @returns boolean true if the mwEmbed player interface should be used
23442365 * false if the mwEmbed player interface should not be used
23452366 */
2346 - shouldUseNativeControls: function() {
 2367+ useNativePlayerControls: function() {
23472368 if( this.usenativecontrols === true ){
23482369 return true;
23492370 }
@@ -2483,6 +2504,7 @@
24842505 } else if( this.apiTitleKey ) {
24852506 iframeUrl += 'apiTitleKey=' + escape( this.apiTitleKey ) + '&';
24862507 if ( this.apiProvider ) {
 2508+ // Commons always uses the commons api provider ( special hack should refactor )
24872509 if( mw.parseUri( document.URL ).host == 'commons.wikimedia.org'){
24882510 this.apiProvider = 'commons';
24892511 }
@@ -2645,9 +2667,8 @@
26462668 * Starts the "monitor"
26472669 */
26482670 play: function() {
2649 - var _this = this;
2650 - mw.log( "EmbedPlayer:: play" );
2651 -
 2671+ var _this = this;
 2672+ mw.log( "EmbedPlayer:: play" );
26522673 // Hide any overlay:
26532674 this.controlBuilder.closeMenuOverlay();
26542675
@@ -2669,7 +2690,7 @@
26702691 // Run play hook (if we were previously in paused state )
26712692 if( this.paused ){
26722693 this.paused = false;
2673 - mw.log("trigger play event::");
 2694+ mw.log("trigger play event::");
26742695 $j( this ).trigger( 'play' );
26752696 }
26762697
@@ -2714,12 +2735,13 @@
27152736 * must be overwritten by embed object to support this functionality.
27162737 */
27172738 pause: function( event ) {
2718 - var _this = this;
 2739+ var _this = this;
 2740+
27192741 // only trigger the pause event if not already in paused state:
27202742 if( this.paused === false ){
27212743 this.paused = true;
27222744 mw.log('EmbedPlayer:trigger pause');
2723 - $j( this ).trigger('pause');
 2745+ //$j( this ).trigger('pause' );
27242746 }
27252747
27262748 // update the ctrl "paused state"
@@ -2747,7 +2769,7 @@
27482770 */
27492771 stop: function() {
27502772 var _this = this;
2751 - mw.log( 'mvEmbed:stop:' + this.id );
 2773+ mw.log( 'EmbedPlayer::stop:' + this.id );
27522774
27532775 // no longer seeking:
27542776 this.didSeekJump = false;
@@ -2808,7 +2830,7 @@
28092831 * Update volume function ( called from interface updates )
28102832 * @param {float} percent Percent of full volume
28112833 */
2812 - setVolume: function( percent, dissableTrigger ) {
 2834+ setVolume: function( percent ) {
28132835 // ignore NaN percent:
28142836 if( isNaN( percent ) ){
28152837 return ;
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerJava.js
@@ -220,7 +220,7 @@
221221 this.parent_play();
222222 if ( this.playerElement ) {
223223 try{
224 - this.playerElement.play();
 224+ this.playerElement.play();
225225 }catch( e ){
226226 mw.log("EmbedPlayerJava::Could not issue play request");
227227 }
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerHtml.js
@@ -92,8 +92,8 @@
9393 * @param {Float} perc Percentage to seek into the virtual player
9494 * @param {Function} callback Function called once time has been updated
9595 */
96 - setCurrentTime:function( perc, callback ) {
97 - this.pauseTime = perc * this.getDuration();
 96+ setCurrentTime:function( time, callback ) {
 97+ this.pauseTime = time;
9898 if( callback )
9999 callback();
100100 },
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -40,6 +40,9 @@
4141 'volumeControl' : true,
4242 'overlays' : true
4343 },
 44+
 45+ insertAndPlayingConfig : false,
 46+
4447 /**
4548 * updates the supported features given the "type of player"
4649 */
@@ -64,7 +67,7 @@
6568 mw.log( "native play url:" + this.getSrc() + ' startOffset: ' + this.start_ntp + ' end: ' + this.end_ntp );
6669
6770 // Check if using native controls and already the "pid" is already in the DOM
68 - if( this.shouldUseNativeControls() && $j( '#' + this.pid ).length &&
 71+ if( this.useNativePlayerControls() && $j( '#' + this.pid ).length &&
6972 typeof $j( '#' + this.pid ).get(0).play != 'undefined' ) {
7073 _this.postEmbedJS();
7174 return ;
@@ -205,9 +208,8 @@
206209 mw.log( 'Native::doSeek p: ' + percentage + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
207210 this.seeking = true;
208211 // Run the seeking hook
209 - $j( this.embedPlayer ).trigger( 'onSeek' );
 212+ $j( this.embedPlayer ).trigger( 'onSeek' );
210213
211 -
212214 // Run the onSeeking interface update
213215 this.controlBuilder.onSeek();
214216
@@ -239,12 +241,81 @@
240242 mw.log( 'native::doNativeSeek::' + percentage );
241243 this.seeking = true;
242244 this.seek_time_sec = 0;
243 - this.doSeekedCallback( ( percentage * this.duration ) , function(){
 245+ this.setCurrentTime( ( percentage * this.duration ) , function(){
244246 _this.seeking = false;
245247 _this.monitor();
246 - })
 248+ })
 249+ },
 250+
 251+ insertAndPlaySource: function( src , options ){
 252+ mw.log("NativeEmbed:: insertAndPlaySource: " + src + ' insertAndPlayingConfig:' + this.insertAndPlayingConfig);
 253+ if(!options)
 254+ options = {};
247255
 256+ if( options.lockUI ){
 257+ this.playerElement.controls = false;
 258+ }
 259+
 260+ // Make sure to capture the original source
 261+ if(! this.insertAndPlayingConfig ){
 262+ //alert( 'setup this.insertAndPlayingConfig ');
 263+ this.insertAndPlayingConfig = {
 264+ 'src' : this.getSrc(),
 265+ 'time' : this.currentTime,
 266+ 'callback' : options.callback,
 267+ 'restoreControls' : options.lockUI
 268+ }
 269+ }
 270+ // Try to directly playback the source
 271+ this.switchSrc( src );
 272+
248273 },
 274+ restoreSourcePlayback: function( ){
 275+ var _this = this;
 276+ mw.log( "RestoreSourcePlayback:: empty out insertAndPlayingConfig" );
 277+ if( !this.insertAndPlayingConfig) {
 278+ mw.log("Error: called restored playback with empty insertAndPlayingConfig")
 279+ return;
 280+ }
 281+ this.switchSrc( this.insertAndPlayingConfig.src );
 282+ //this.playerElement.play();
 283+ // Remove insert and playing config flag
 284+ this.insertAndPlayingConfig = false;
 285+
 286+ var time = this.insertAndPlayingConfig.time;
 287+ var callback = this.insertAndPlayingConfig.callback;
 288+
 289+ // run the seek:
 290+ this.setCurrentTime( time ,function(){
 291+ if( this.insertAndPlayingConfig.restoreControls ){
 292+ this.playerElement.controls = true;
 293+ }
 294+ });
 295+ // Give some time for ipad to figure out whats going on:
 296+ setTimeout(function(){
 297+ _this.playerElement.load();
 298+ _this.playerElement.play();
 299+ },100);
 300+
 301+ //alert("insertAndPlayingConfig:: " + this.insertAndPlayingConfig);
 302+ // Run the callback
 303+ if( callback ){
 304+ callback();
 305+ }
 306+ },
 307+ switchSrc: function( src ){
 308+ mw.log( 'switchSrc' )
 309+ if( this.getPlayerElement() ){
 310+ try{
 311+ //this.playerElement.pause();
 312+ this.playerElement.src = src;
 313+ this.playerElement.load();
 314+ this.playerElement.play();
 315+ } catch( e ){
 316+ mw.log("Error: possible error in swiching source playback");
 317+ }
 318+ }
 319+ },
249320
250321 /**
251322 * Seek in a existing stream
@@ -281,37 +352,36 @@
282353 * @param {Float} position Seconds to set the time to
283354 * @param {Function} callback Function called once time has been set.
284355 */
285 - setCurrentTime: function( position , callback ) {
286 - var _this = this;
287 - //mw.log( 'native:setCurrentTime::: ' + position + ' : dur: ' + _this.getDuration() );
288 - this.getPlayerElement();
289 - if ( !this.playerElement ) {
290 - this.load( function() {
291 - _this.doSeekedCallback( position, callback );
292 - } );
293 - } else {
294 - _this.doSeekedCallback( position, callback );
295 - }
296 - },
297 -
298 - /**
299 - * Do the seek request with a callback
300 - *
301 - * @param {Float} position Position in seconds
302 - * @param {Function} callback Function to call once seeking completes
303 - */
304 - doSeekedCallback : function( position, callback ) {
 356+ setCurrentTime: function( time , callback, callbackCount ) {
305357 var _this = this;
 358+ if( !callbackCount )
 359+ callbackCount = 0;
306360 this.getPlayerElement();
307 - var once = function( event ) {
308 - callback();
309 - _this.playerElement.removeEventListener( 'seeked', once, false );
310 - };
311 - // Assume we will get to add the Listener before the seek is done
312 - _this.playerElement.currentTime = position;
313 - _this.playerElement.addEventListener( 'seeked', once, false );
 361+ if( _this.playerElement.readyState >= 1 ){
 362+ if( _this.playerElement.currentTime == time ){
 363+ callback();
 364+ return;
 365+ }
 366+ var once = function( event ) {
 367+ if( callback ){
 368+ callback();
 369+ }
 370+ _this.playerElement.removeEventListener( 'seeked', once, false );
 371+ };
 372+ // Assume we will get to add the Listener before the seek is done
 373+ _this.playerElement.addEventListener( 'seeked', once, false );
 374+ _this.playerElement.currentTime = time;
 375+ } else {
 376+ if( callbackCount >= 300 ){
 377+ mw.log("Error with seek request, media never in ready state");
 378+ return ;
 379+ }
 380+ setTimeout( function(){
 381+ _this.setCurrentTime( time, callback , callbackCount++);
 382+ }, 10 );
 383+ }
314384 },
315 -
 385+
316386 /**
317387 * Get the embed player time
318388 */
@@ -343,11 +413,13 @@
344414 * Pause the video playback
345415 * calls parent_pause to update the interface
346416 */
347 - pause: function() {
348 - this.getPlayerElement();
 417+ pause: function( ) {
 418+ this.getPlayerElement();
349419 this.parent_pause(); // update interface
350420 if ( this.playerElement ) { // update player
351 - this.playerElement.pause();
 421+ if( !this.playerElement.paused ){
 422+ this.playerElement.pause();
 423+ }
352424 }
353425 },
354426
@@ -355,11 +427,15 @@
356428 * Play back the video stream
357429 * calls parent_play to update the interface
358430 */
359 - play: function() {
360 - this.getPlayerElement();
 431+ play: function( ) {
 432+
 433+ this.getPlayerElement();
361434 this.parent_play(); // update interface
362435 if ( this.playerElement && this.playerElement.play ) {
363 - this.playerElement.play();
 436+ // issue a play request if the media is paused:
 437+ if( this.playerElement.paused ){
 438+ this.playerElement.play();
 439+ }
364440 // re-start the monitor:
365441 this.monitor();
366442 }
@@ -508,18 +584,17 @@
509585 * Handle the native paused event
510586 */
511587 onPaused: function(){
512 - mw.log( "embedPlayer:native:paused" );
513 - this.pause();
 588+ mw.log( "EmbedPlayer:native: OnPaused" );
 589+ this.parent_pause();
514590 },
515591
516592 /**
517593 * Handle the native play event
518594 */
519595 onPlay: function(){
520 - mw.log("embedPlayer:native::play");
521 - if( !this.isPlaying () ){
522 - this.play();
523 - }
 596+ mw.log("EmbedPlayer:native:: OnPlay");
 597+ // Update the interface
 598+ this.parent_play();
524599 },
525600
526601 /**
@@ -568,8 +643,15 @@
569644 * Used to update the bufferedPercent
570645 */
571646 onended: function() {
572 - var _this = this;
573 - mw.log( 'EmbedPlayer:native:onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() );
 647+ var _this = this;
 648+ mw.log( 'EmbedPlayer:native: onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() +
 649+ ' insertAndPlayingConfig: ' + this.insertAndPlayingConfig);
 650+
 651+ if( this.insertAndPlayingConfig ){
 652+ this.restoreSourcePlayback();
 653+ this.insertAndPlayingConfig = false;
 654+ return ;
 655+ }
574656 this.onClipDone();
575657 }
576658 };
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerMenu.js
@@ -63,6 +63,14 @@
6464 return ( _this.sequencer.getServer().isConfigured() )
6565 }
6666 },
 67+ 'help_divider': 'divider',
 68+ 'help': {
 69+ 'icon' : 'info',
 70+ 'action' : function(){
 71+ // follow link to
 72+ //$j( this ).attr('href', )
 73+ }
 74+ },
6775 'exit_divider': 'divider',
6876 'exit' : {
6977 'icon' : 'power',

Status & tagging log