http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68696
Revision: 68696 Author: dale Date: 2010-06-29 01:37:54 +0000 (Tue, 29 Jun 2010) Log Message: ----------- some smil seeking fixes Modified Paths: -------------- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js branches/MwEmbedStandAlone/remotes/mediaWiki.js Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js =================================================================== --- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -114,8 +114,8 @@ // Update the render target with bodyElements for the requested time this.getBody().renderTime( time ); - // Wait until buffer is ready - this.getBuffer().timeIsBuffered( time, callback ); + // Wait until buffer is ready and run the callback + this.getBuffer().addAssetsReadyCallback( callback ); }, /** Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js =================================================================== --- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -128,6 +128,7 @@ break; } }, + /** * Transform video for time */ @@ -135,14 +136,16 @@ // get the video element var vid = $j ( '#' + this.smil.getAssetId( smilElement ) ).get(0); // Check for "start offset" - - // Run a seek and ( buffer automatically registers ready points ) + mw.log( "transformVideoForTime:: ct:" +vid.currentTime + ' should be: ' + animateTime ); - vid.currentTime = animateTime; + // Register a buffer ready callback + this.smil.getBuffer().videoBufferSeek( smilElement, animateTime, function(){ + mw.log( "transformVideoForTime:: seek complete "); + } ); }, /** - * transformTextForTime + * Transform Text For Time */ transformTextForTime: function( textElement, animateTime ) { //mw.log("transformTextForTime:: " + animateTime ); Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js =================================================================== --- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -61,6 +61,7 @@ */ renderTime: function( time, deltaTime ){ var _this = this; + mw.log( "renderTime:: " + time ); // Get all the draw elements from the body this time: var elementList = this.getElementsForTime( time , Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js =================================================================== --- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -7,6 +7,13 @@ } mw.SmilBuffer.prototype = { + + // Stores currently loading assets. + assetLoadingSet: [], + + // + assetLoadingCallbacks : [], + /** * Constructor: */ @@ -17,16 +24,84 @@ /** * Runs a callback once the buffer time is ready. */ - timeIsBuffered: function( time, callback ) { + timeIsReady: function( time, callback ) { + // Get active body elements - // Get active body elements - //this.smil.getBody().getElementsForTime( time ); - // Check load status per temporal offset // setTimeout to call self until buffer is ready + + // Temp ( assume ready ); + callback(); + }, + + /** + * Add a callback for when assets loaded and "ready" + */ + addAssetsReadyCallback: function( callback ) { + mw.log( "addAssetsReadyCallback:: " + this.assetLoadingSet.length ); + // if no assets are "loading" issue the callback directly: + if ( this.assetLoadingSet.length == 0 ){ + if( callback ) + callback(); + return ; + } + // Else we need to add a loading callback ( will be called once all the assets are ready ) + this.assetLoadingCallbacks.push( callback ); + }, + + /** + * Add a asset to the loading set: + * @param assetId The asset to add to loading set + */ + addAssetLoading: function( assetId ) { + this.assetLoadingSet.push( assetId ); + }, + + /** + * Asset is ready, check queue and issue callback if empty + */ + assetReady: function( assetId ) { + for( var i=0; i < this.assetLoadingSet.length ; i++ ){ + if( assetId == this.assetLoadingSet[i] ) { + this.assetLoadingSet.splice( i, 1 ); + } + } + if( this.assetLoadingSet.length === 0 ) { + while( this.assetLoadingCallbacks.length ) { + this.assetLoadingCallbacks.shift()(); + } + } + }, + + + videoBufferSeek: function ( smilElement, seekTime, callback ){ + var _this = this; + // Get the video target: + var $vid = $j ( '#' + this.smil.getAssetId( smilElement ) ); - // Temp ( assume ready ): - callback(); + // Add the asset to the loading set + _this.addAssetLoading( $vid.attr('id' ) ); + + var runSeekCallback = function(){ + $vid.unbind( 'seeked' ).bind( 'seeked', function(){ + _this.assetReady( $vid.attr('id' ) ); + if( callback ) { + callback(); + } + }); + $vid.attr('currentTime', seekTime ); + } + + // Read the video state: http://www.w3.org/TR/html5/video.html#dom-media-have_nothing + if( $vid.attr('readyState') == 0 /* HAVE_NOTHING */ ){ + // Check that we have metadata ( so we can issue the seek ) + $vid.unbind( 'loadedmetadata' ).bind( 'loadedmetadata', function(){ + runSeekCallback(); + } ); + }else { + // Already have metadata directly issue the seek with callback + runSeekCallback(); + } } } \ No newline at end of file Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js =================================================================== --- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -453,7 +453,7 @@ 'xx-large' : '1.72em' } if( sizeMap[ cssAttributes['font-size'] ] ){ - cssAttributes['font-size'] = cssAttributes[ textCss['font-size'] ]; + cssAttributes['font-size'] = sizeMap[ cssAttributes['font-size'] ]; } // If the font size is pixel based parent span will have no effect, Modified: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js =================================================================== --- branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -808,7 +808,7 @@ // Resize the interface for layoutMode == 'ontop' ( if not in fullscreen ) // NOTE this shoudl be a call to controlBuilder not handled here inline if( ! this.embedPlayer.controlBuilder.fullscreenMode ){ - if( this.embedPlayer.controlBuilder.checkEmbedPlayer.OverlayControls() ){ + if( this.embedPlayer.controlBuilder.checkOverlayControls() ){ var playerHeight = this.embedPlayer.getHeight(); } else { var playerHeight = this.embedPlayer.getHeight() + this.embedPlayer.controlBuilder.getHeight(); Modified: branches/MwEmbedStandAlone/remotes/mediaWiki.js =================================================================== --- branches/MwEmbedStandAlone/remotes/mediaWiki.js 2010-06-29 01:31:41 UTC (rev 68695) +++ branches/MwEmbedStandAlone/remotes/mediaWiki.js 2010-06-29 01:37:54 UTC (rev 68696) @@ -425,7 +425,7 @@ // Show the control bar for two seconds (auto play is confusing without it ) embedPlayer.controlBuilder.showControlBar(); // hide the controls if they should they are overlayed on the video - if( embedPlayer.controlBuilder.checkEmbedPlayer.OverlayControls() ){ + if( embedPlayer.controlBuilder.checkOverlayControls() ){ setTimeout( function(){ embedPlayer.controlBuilder.hideControlBar(); }, 4000 ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs