http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72764
Revision: 72764
Author: dale
Date: 2010-09-10 22:40:47 +0000 (Fri, 10 Sep 2010)
Log Message:
-----------
* improved sequence audio playback
* improved preview button with play / pause bindings
* fixed layout of inline player for play dialogs
Modified Paths:
--------------
branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsView.js
branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js
branches/MwEmbedStandAlone/mwEmbed.js
branches/MwEmbedStandAlone/remotes/mediaWiki.js
Modified:
branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
===================================================================
--- branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -331,6 +331,9 @@
if ( size.width ) {
request['iiurlwidth'] = size.width;
}
+ if( size.height ){
+ request['iiurlheight'] = size.height;
+ }
mw.getJSON( this.provider.apiUrl, request, function( data ) {
var imObj = { };
Modified: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
===================================================================
--- branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -3039,10 +3039,8 @@
// Call monitor at 250ms interval. ( use setInterval to avoid
stacking monitor requests )
//mw.log("EmbedPlayer::monitor: continue?:" + !this.isStopped()
+ ' monitorInterval: ' + this.monitorInterval );
if( ! this.isStopped() ) {
- if( !this.monitorInterval ){
-
- this.monitorInterval = setInterval( function(){
- mw.log("monitorInterval!!");
+ if( !this.monitorInterval ){
+ this.monitorInterval = setInterval( function(){
if( _this.monitor ){
_this.monitor();
}
Modified: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
2010-09-10 22:40:47 UTC (rev 72764)
@@ -55,9 +55,13 @@
'mwe-sequencer-clip-transin' => 'Transition in',
'mwe-sequencer-clip-transout' => 'Transition out',
+ 'mwe-sequencer-clip-cancel-edit' => 'Cancel clip edit',
'mwe-sequencer-preview' => 'Preview',
+ 'mwe-sequencer-preview-pause' => 'Pause preview',
+ 'mwe-sequencer-preview-continue' => 'Continue preview',
'mwe-sequencer-apply-changes' => 'Apply changes',
'mwe-sequencer-start-time' => 'Start time',
+ 'mwe-sequencer-asset-source' => 'Source page',
'mwe-sequencer-loading_user_rights' => 'Loading user rights ...',
@@ -110,6 +114,7 @@
'mwe-sequencer-save-no-changes' => 'There are no new edits to save',
'mwe-sequencer-save-summary' => 'Please enter a short summary of
changes:',
'mwe-sequencer-edit_cancel' => 'Cancel sequence edit',
+
'mwe-sequencer-saving_wait' => 'Save in progress (please wait)',
'mwe-sequencer-save_done' => 'Save complete',
Modified:
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
===================================================================
---
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
2010-09-10 21:51:25 UTC (rev 72763)
+++
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -167,7 +167,7 @@
if( !_this.sequencer.getServer().hasLocalChanges() ){
$dialog.html( gM('mwe-sequencer-save-no-changes') );
var closeButton = {};
- closeButton[gM('mwe-ok')]= function(){
$j(this).dialog('close') };
+ closeButton[ gM('mwe-ok') ]= function(){
$j(this).dialog('close') };
$dialog.dialog( "option", "buttons", closeButton);
return ;
}
Modified:
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsView.js
===================================================================
---
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsView.js
2010-09-10 21:51:25 UTC (rev 72763)
+++
branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsView.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -22,14 +22,14 @@
// For now just show the sequence output
$viewSmilXmlDialog = mw.addDialog({
'title' : gM('mwe-sequencer-menu-view-smilxml'),
- 'dragable': true,
- 'height' : 480,
- 'width' : 640,
- 'resizable': true,
- 'content' : $j('<div />')
+ 'dragable': true,
+ 'width' : 800,
+ 'height' : 600,
+ 'resizable': false,
+ 'content' : $j('<div />')
.append(
// Add a loading div
- $j('<div />')
+ $j('<div />')
.addClass('syntaxhighlighter_loader')
.loadingSpinner(),
@@ -47,6 +47,7 @@
// load and run the syntax highlighter:
$j( $viewSmilXmlDialog.find('pre') ).syntaxHighlighter(
function(){
$viewSmilXmlDialog.find('.syntaxhighlighter_loader').remove();
+
$viewSmilXmlDialog.find('.syntaxhighlighter').css('height', '520px');
$viewSmilXmlDialog.find('pre').fadeIn();
});
Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -195,6 +195,9 @@
* ref node that can be inserted into a smil xml tree
*/
getSmilClipFromResource: function( resource, callback ){
+ // fist check if we
+
+
var tagType = 'ref';
if( resource.mime.indexOf( 'image/' ) != -1 ){
tagType = 'img';
@@ -249,24 +252,37 @@
})
)
}
+ }
+ // Check if the source asset is smaller than our target import
size in both width and height:
+ if( resource.width < mw.getConfig(
'Sequencer.AddMediaImageWidth' )
+ &&
+ resource.height < mw.getConfig(
'Sequencer.AddMediaImageHeight' )
+ ) {
+ callback( $smilRef.get(0) );
+ return ;
}
- // Make sure we have source for the asset.
- if( $smilRef.attr('src') ){
- callback( $smilRef.get(0) )
- } else {
- // the resource includes a pointer to its parent search
object
- // from the search object grab the image object for the
target resolution
- resource.pSobj.getImageObj(
- resource,
- {
- 'width' : mw.getConfig(
'Sequencer.AddMediaImageWidth' )
- },
- function( imageObj ){
- $smilRef.attr('src', imageObj.url )
- callback( $smilRef.get(0) );
- }
- )
+
+ // Get the dominate aspect ratio so we can
+ var targetAspect = mw.getConfig( 'Sequencer.AddMediaImageWidth'
) / mw.getConfig( 'Sequencer.AddMediaImageHeight' )
+ var fileAspect = resource.width / resource.height;
+
+ var requestWidth = mw.getConfig( 'Sequencer.AddMediaImageWidth'
);
+ if( targetAspect > fileAspect ){
+ requestWidth = parseInt( mw.getConfig(
'Sequencer.AddMediaImageHeight' ) * fileAspect );
}
+
+ // the resource includes a pointer to its parent search object
+ // from the search object grab the image object for the target
resolution
+ resource.pSobj.getImageObj(
+ resource,
+ {
+ 'width' : requestWidth
+ },
+ function( imageObj ){
+ $smilRef.attr('src', imageObj.url )
+ callback( $smilRef.get(0) );
+ }
+ )
}
}
Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -27,9 +27,16 @@
// Default image duration
"Sequencer.AddMediaImageDuration" : 2,
- // Default image source width
- "Sequencer.AddMediaImageWidth" : 640,
+ // NOTE these values 800x600 are the default display
+ // size for assets in wikimedia commons and helps avoid server
side resizes
+ // and gives the asset a better chance of being served from the
cache
+ // Default import image source width
+ "Sequencer.AddMediaImageWidth" : 800,
+
+ // Default import image source height
+ "Sequencer.AddMediaImageHeight" : 600,
+
// If a asset can be directly added to the sequence by url
// ( if disabled only urls that are part addMedia can be added
)
"Sequencer.AddAssetByUrl" : true,
Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -58,7 +58,7 @@
});
},
- previewClip: function( smilClip ){
+ previewClip: function( smilClip, donePreivewCallback ){
var _this = this;
// Seek and play start of smilClip
var startOffset = $j( smilClip ).data('startOffset');
@@ -67,6 +67,8 @@
this.getEmbedPlayer().setCurrentTime( startOffset, function(){
mw.log("SequencerPlayer::Preview clip: " + startOffset
+ ' to ' + clipEndTime);
_this.getEmbedPlayer().play( clipEndTime );
+ // bind end of segment action
+ $j( _this.sequencer.getEmbedPlayer() ).bind(
'playSegmentEnd', donePreivewCallback);
})
},
Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -349,6 +349,15 @@
}
return this.pagePathUrl.replace( '$1', 'Sequence:' +
titleKey);
},
+
+ getAssetViewUrl: function( titleKey ){
+ // Check that we have a pagePathUrl config:
+ if( !this.pagePathUrl ){
+ return false;
+ }
+ return this.pagePathUrl.replace( '$1', titleKey );
+ },
+
/**
* Get the sequencer 'edit' url
*/
Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -149,18 +149,80 @@
}
},
editActions: {
+ 'sourcePage':{
+ 'displayCheck': function( _this, smilElement ){
+ if( _this.sequencer.getSmil().getTitleKey(
smilElement )
+ &&
+
_this.sequencer.getServer().isConfigured()
+ ){
+ return true;
+ }
+ return false;
+ },
+ 'icon': 'info',
+ 'title': gM('mwe-sequencer-asset-source'),
+ 'action' : function( clickButton, _this, smilElement ){
+ // Update the link
+ $j( clickButton )
+ .attr({
+ 'href':
_this.sequencer.getServer().getAssetViewUrl(
+
$j(smilElement).find("param[name='apiTitleKey']").attr('value')
+ )
+ ,
+ 'target' : '_new'
+ })
+ // follow the link the link
+ return true;
+ }
+ },
'preview' : {
'icon' : 'play',
'title' : gM('mwe-sequencer-preview'),
- 'action': function( _this, smilElement ){
- _this.sequencer.getPlayer().previewClip(
smilElement );
+ 'action': function( clickButton, _this, smilElement ){
+ _this.sequencer.getPlayer().previewClip(
smilElement, function(){
+ // preview done, restore original state:
+ $j(clickButton).replaceWith (
+ _this.getEditAction(
smilElement, 'preview' )
+ )
+ });
// xxx todo update preview button to "pause" /
"play"
+ var doPause = function(){
+ $j( clickButton ).find( '.ui-icon')
+ .removeClass( 'ui-icon-pause' )
+ .addClass( 'ui-icon-play' )
+ $j( clickButton ).find('.btnText').text(
+
gM('mwe-sequencer-preview-continue')
+ )
+
_this.sequencer.getEmbedPlayer().pause();
+ }
+ var doPlay = function(){
+ // setup pause button:
+ $j( clickButton ).find( '.ui-icon')
+ .removeClass( 'ui-icon-play' )
+ .addClass( 'ui-icon-pause' )
+ $j( clickButton ).find('.btnText').text(
+
gM('mwe-sequencer-preview-pause')
+ )
+ // keep the target preview end time:
+ // xxx should probably refactor this..
a bit of abstraction leak here:
+ _this.sequencer.getEmbedPlayer().play(
+
_this.sequencer.getEmbedPlayer().playSegmentEndTime
+ );
+ }
+ $j( clickButton ).unbind().click(function(){
+ if(
_this.sequencer.getEmbedPlayer().paused ){
+ doPlay();
+ } else {
+ doPause();
+ }
+ })
+ doPlay();
}
- },
+ },
'cancel' : {
'icon': 'close',
- 'title' : gM('mwe-cancel'),
- 'action' : function( _this, smilElement ){
+ 'title' : gM('mwe-sequencer-clip-cancel-edit'),
+ 'action' : function(clickButton, _this, smilElement ){
$j.each(
_this.getToolSet(
_this.sequencer.getSmil().getRefType( smilElement )
@@ -724,16 +786,21 @@
});
// Add tab bindings
- $toolsContainer.tabs({
- select: function(event, ui) {
+ $toolsContainer.tabs();
+
+ // Build out global edit Actions buttons after the container
+ for( var editActionId in this.editActions ){
+ // Check if the edit action has a conditional display:
+ var displayEidtAction = true;
+ if( this.editActions[ editActionId ].displayCheck ){
+ displayEidtAction = this.editActions[
editActionId ].displayCheck( _this, smilElement );
+ }
+ if( displayEidtAction ){
+ $toolsContainer.after(
+ this.getEditAction( smilElement,
editActionId )
+ )
}
- })
- // Build out global edit Actions buttons after the container
- for( var editActionId in this.editActions ){
- $toolsContainer.after(
- this.getEditAction( smilElement, editActionId )
- )
}
},
getCurrentsmilElement: function(){
@@ -765,7 +832,7 @@
'margin': '5px'
})
.click( function(){
- editAction.action( _this, smilElement );
+ return editAction.action( this, _this,
smilElement );
})
return $actionButton;
},
Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
===================================================================
--- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
2010-09-10 21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
2010-09-10 22:40:47 UTC (rev 72764)
@@ -241,6 +241,7 @@
// Check if we reached playSegmentEndTime and pause playback
if( this.playSegmentEndTime && this.smilPlayTime >=
this.playSegmentEndTime ) {
mw.log("monitor:: Reached playSegmentEndTime pause
playback: " + this.playSegmentEndTime );
+ $j( this ).trigger( 'playSegmentEnd' );
this.playSegmentEndTime= null;
this.pause();
this.parent_monitor();
Modified: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js
===================================================================
--- branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js 2010-09-10
21:51:25 UTC (rev 72763)
+++ branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js 2010-09-10
22:40:47 UTC (rev 72764)
@@ -449,6 +449,16 @@
return $html;
},
+ getTitleKey: function( smilElement ){
+ // check directly for the attribute:
+ if( $j(smilElement).attr('apititlekey') ){
+ return $j(smilElement).attr('apititlekey') ;
+ }
+ if( $j(smilElement).find("param[name='apiTitleKey']").length ) {
+ return
$j(smilElement).find("param[name='apiTitleKey']").attr('value');
+ }
+ return false;
+ },
/**
* Get the smil resource type based on nodeName and type attribute
*/
Modified: branches/MwEmbedStandAlone/mwEmbed.js
===================================================================
--- branches/MwEmbedStandAlone/mwEmbed.js 2010-09-10 21:51:25 UTC (rev
72763)
+++ branches/MwEmbedStandAlone/mwEmbed.js 2010-09-10 22:40:47 UTC (rev
72764)
@@ -1132,13 +1132,13 @@
var $dialog = $j( '#mwTempLoaderDialog'
).show().dialog( options );
// center the dialog
// xxx figure out why jquery ui is messing up here
- $j( '#mwTempLoaderDialog' ).parent('.ui-dialog').css({
+ /*$j( '#mwTempLoaderDialog' ).parent('.ui-dialog').css({
'position' : 'absolute',
'left' : '50%',
'margin-left': -1 * $dialog.width()/2,
'top' : '50%',
'margin-top': -1 * $dialog.height()/2
- });
+ }); */
} );
return $j( '#mwTempLoaderDialog' );
}
Modified: branches/MwEmbedStandAlone/remotes/mediaWiki.js
===================================================================
--- branches/MwEmbedStandAlone/remotes/mediaWiki.js 2010-09-10 21:51:25 UTC
(rev 72763)
+++ branches/MwEmbedStandAlone/remotes/mediaWiki.js 2010-09-10 22:40:47 UTC
(rev 72764)
@@ -449,19 +449,13 @@
// close the
dialog
$j(this).dialog( 'close' ).remove();
};
- mw.addDialog( {
+ var $dialog =
mw.addDialog( {
'title' :
decodeURIComponent( apiTitleKey.replace(/_/g, ' ') ),
'content' :
html_out,
- 'buttons' :
buttons
- })
- // Dialog size setup is
a bit strange:
- .css( {
- 'height' :
dialogHeight + 'px'
- })
- .parent().css( {
- // we hard code
the default resolution to 400 above
- 'width' :
'435px',
- } )
+ 'buttons' :
buttons,
+ 'height' :
dialogHeight,
+ 'width' : 425
+ })
// Update the embed
code to use the mwEmbed player:
$j( '#mwe_' + vidId
).embedPlayer( function(){
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs