r72840 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72839‎ | r72840 | r72841 >
Date:07:24, 12 September 2010
Author:dale
Status:deferred
Tags:
Comment:
* added attributionButton config option as a genneral attribution support type
* added jQuery include with player test
* added about library link to player menu
* added concept of localSettings.js for site config
* removed unused wgScriptCacheDir in mwEmbedFrame.php
Modified paths:
  • /branches/MwEmbedStandAlone/ResourceLoader.php (modified) (history)
  • /branches/MwEmbedStandAlone/localSettings.js (added) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/EmbedPlayer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.PlayerSkinKskin.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/tests/Player_IncludeJQuery.html (added) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbedFrame.php (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbedFrame.php
@@ -13,10 +13,6 @@
1414 * <iframe src="mwEmbedFrame.php?src={SRC URL}&poster={POSTER URL}&width={WIDTH}etc"> </iframe>
1515 */
1616
17 -//Setup the script local script cache directory
18 -// ( has to be hard coded rather than config based for fast non-mediawiki config hits )
19 -$wgScriptCacheDirectory = realpath( dirname( __FILE__ ) ) . '/includes/cache';
20 -
2117 // Setup the mwEmbedFrame
2218 $myMwEmbedFrame = new mwEmbedFrame();
2319
Index: branches/MwEmbedStandAlone/localSettings.js
@@ -0,0 +1,9 @@
 2+/**
 3+* Local Setting file hosts any per site configuration
 4+*
 5+* This file is automatically included in any resourceLoader or mwEmbed.js request
 6+*
 7+* You can put any mw.setConfig('moduleOption', value ) calls in here.
 8+*
 9+* In a fresh svn checkout this file will always be empty.
 10+*/
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -2153,18 +2153,24 @@
21542154
21552155 }
21562156 if ( ! langLoaderRequest.length ) {
2157 - callback();
 2157+ addLocalSettings();
21582158 return ;
21592159 }
21602160
21612161 // Load the launage if set
21622162 mw.load( langLoaderRequest, function(){
2163 - mw.log( 'Done moduleLoaderCheck request' );
 2163+ mw.log( 'Done moduleLoaderCheck request' );
 2164+ addLocalSettings();
 2165+ } );
 2166+ }
 2167+ function addLocalSettings(){
 2168+ mw.log("Load loacal settings")
 2169+ mw.load( 'localSettings.js', function(){
21642170 // Set the mwModuleLoaderCheckFlag flag to true
2165 - mwModuleLoaderCheckFlag = true;
 2171+ mwModuleLoaderCheckFlag = true;
21662172 callback();
2167 - } );
2168 - }
 2173+ })
 2174+ }
21692175
21702176 }
21712177
Index: branches/MwEmbedStandAlone/ResourceLoader.php
@@ -151,8 +151,16 @@
152152
153153 // Output the current language resource js
154154 $this->output .= NamedResourceLoader::getLanguageJs( $this->langCode );
155 -
156 - // Add the required core mwEmbed style sheets Commted out
 155+
 156+ // Output the localSettings.js
 157+ $localSettingsJsPath = realpath( dirname( __FILE__ ) ) . '/localSettings.js';
 158+ if( is_file( $localSettingsJsPath ) ){
 159+ wfSuppressWarnings();
 160+ $this->output .= file_get_contents( $localSettingsJsPath );
 161+ wfRestoreWarnings();
 162+ }
 163+
 164+ // Add the required core mwEmbed style sheets removed for now
157165 // because when creating stand alone packages js package with css
158166 // the paths get messed up.
159167 /*
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js
@@ -39,7 +39,6 @@
4040
4141 /**
4242 * Checks if assets are insync
43 - * re
4443 */
4544 getPlaybackSyncDelta: function( time ){
4645 var _this = this;
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
@@ -331,9 +331,6 @@
332332 if ( size.width ) {
333333 request['iiurlwidth'] = size.width;
334334 }
335 - if( size.height ){
336 - request['iiurlheight'] = size.height;
337 - }
338335
339336 mw.getJSON( this.provider.apiUrl, request, function( data ) {
340337 var imObj = { };
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js
@@ -6,6 +6,7 @@
77 * Default player module configuration
88 */
99 ( function( mw ) {
 10+ window['MW_EMBED_LIBRARY_PAGE'] = 'http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library';
1011
1112 mw.setDefaultConfig( {
1213 // If the player controls should be overlaid on top of the video ( if supported by playback method)
@@ -25,8 +26,19 @@
2627
2728 // If the video player should attribute kaltura
2829 "EmbedPlayer.KalturaAttribution" : true,
 30+
 31+ // The attribution button
 32+ 'EmbedPlayer.AttributionButton' :{
 33+ 'title' : 'Kaltura html5 video library',
 34+ 'href' : MW_EMBED_LIBRARY_PAGE,
 35+ // Style icon to be applied
 36+ 'class' : 'kaltura-icon',
 37+ // An icon image url ( should be a 16x16 image or data url )
 38+ 'iconurl' : false
 39+ },
 40+
2941
30 - // Set the browser player warning flag to true by default ( applies to all players so its not part of attribute defaults above )
 42+ // Set the browser player warning flag displays warning for non optimal playback
3143 "EmbedPlayer.ShowNativeWarning" : true,
3244
3345 // If fullscreen is global enabled.
@@ -137,7 +149,7 @@
138150 });
139151 // Load the embedPlayer module ( then run queued hooks )
140152 mw.load( 'EmbedPlayer', function ( ) {
141 - mw.log("EmbedPlayer:: do rewrite tags");
 153+ mw.log("EmbedPlayer:: do rewrite players:" + $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).length );
142154 // Rewrite the EmbedPlayer.RewriteTags with the
143155 $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer();
144156 })
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/tests/Player_IncludeJQuery.html
@@ -0,0 +1,27 @@
 2+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 3+<html xmlns="http://www.w3.org/1999/xhtml">
 4+<head>
 5+<title>Player sources</title>
 6+
 7+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
 8+<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7/jquery-ui.min.js" type="text/javascript"></script>
 9+<script type="text/javascript" src="../../../mwEmbedLoader.js"></script>
 10+<script type="text/javascript">
 11+ $(document).ready(function(){
 12+ $('#test').text('jQuery $ supported' );
 13+ });
 14+</script>
 15+</head>
 16+<body>
 17+<div id="test"></div>
 18+
 19+<video poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream.jpg"
 20+ duration="10:53" preload="auto">
 21+ <source type="video/webm" src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream_400p.webm" />
 22+ <source type="video/h264" src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream_iphone.m4v" />
 23+ <source type="video/ogg" src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream_400p.ogv" />
 24+</video>
 25+
 26+
 27+</body>
 28+</html>
\ No newline at end of file
Property changes on: branches/MwEmbedStandAlone/modules/EmbedPlayer/tests/Player_IncludeJQuery.html
___________________________________________________________________
Added: svn:executable
129 + *
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -36,6 +36,8 @@
3737 "mwe-embedplayer-download_text" : "Download timed text",
3838 "mwe-embedplayer-download" : "Download",
3939 "mwe-embedplayer-share" : "Share",
 40+ 'mwe-embedplayer-about-library' : 'About kaltura player',
 41+ "mwe-embedplayer-about-library-desc" : 'Kaltura\'s HTML5 Media Library enables you to take advantage of the html5 &lt;video&gt; and &lt;audio&gt; tags today with a consistent player interface across all major browsers. <br> <br> [$1 More about the kaltura player library].',
4042 "mwe-embedplayer-credits" : "Credits",
4143 "mwe-embedplayer-clip_linkback" : "Clip source page",
4244 "mwe-embedplayer-choose_player" : "Choose video player",
@@ -335,7 +337,7 @@
336338 // Make sure we have user preference setup ( for setting preferences on video selection )
337339 mw.setupUserConfig( function() {
338340 // Add each selected element to the player manager:
339 - $j( playerSelect ).each( function( index, playerElement) {
 341+ $j( playerSelect ).each( function( index, playerElement) {
340342 // Make sure the video tag was not generated by our library:
341343 if( $j( playerElement ).hasClass( 'nativeEmbedPlayerPid' ) ){
342344 $j('#loadingSpinner_' + $j( playerElement ).attr('id') ).hide();
@@ -478,8 +480,9 @@
479481 if( ranPlayerSwapFlag ){
480482 return ;
481483 }
 484+ ranPlayerSwapFlag = true;
482485 mw.log("EmbedPlayer::runPlayerSwap::" + $j( playerElement ).attr('id') );
483 - ranPlayerSwapFlag = true;
 486+
484487 var playerInterface = new mw.EmbedPlayer( playerElement , attributes);
485488
486489 _this.swapEmbedPlayerElement( playerElement, playerInterface );
@@ -611,6 +614,7 @@
612615 if( playerInterface.shouldUseNativeControls() ) {
613616 $j( targetElement )
614617 .attr('id', playerInterface.pid )
 618+ .addClass( 'nativeEmbedPlayerPid' )
615619 .after(
616620 $j( swapPlayerElement ).css('display', 'none')
617621 )
@@ -1480,7 +1484,7 @@
14811485
14821486 // Set the player size attributes based loaded video element:
14831487 this.setPlayerSize( element );
1484 -
 1488+
14851489 // Set the plugin id
14861490 this.pid = 'pid_' + this.id;
14871491
@@ -2693,15 +2697,18 @@
26942698 _this.pause();
26952699 } )
26962700 .attr( 'title', gM( 'mwe-embedplayer-pause_clip' ) );
2697 -
2698 -
2699 - // If we previously finished playing this clip run the "replay hook"
2700 - if( this.donePlayingCount > 0 ) {
 2701+
 2702+ // Start the monitor if not already started
 2703+ this.monitor();
 2704+
 2705+ // If we previously finished playing this clip run the "replay hook"
 2706+ if( this.donePlayingCount > 0 ) {
27012707 mw.log("replayEvent");
27022708 $j( this ).trigger( 'replayEvent' );
2703 - }
 2709+ }
27042710 },
27052711
 2712+
27062713 /**
27072714 * Maps the html5 load request. There is no general way to "load" clips so
27082715 * underling plugin-player libs should override.
@@ -3037,13 +3044,11 @@
30383045 }
30393046
30403047 // Call monitor at 250ms interval. ( use setInterval to avoid stacking monitor requests )
3041 - //mw.log("EmbedPlayer::monitor: continue?:" + !this.isStopped() + ' monitorInterval: ' + this.monitorInterval );
3042 - if( ! this.isStopped() ) {
3043 - if( !this.monitorInterval ){
3044 - this.monitorInterval = setInterval( function(){
3045 - if( _this.monitor ){
 3048+ if( ! this.isStopped() ) {
 3049+ if( !this.monitorInterval ){
 3050+ this.monitorInterval = setInterval( function(){
 3051+ if( _this.monitor )
30463052 _this.monitor();
3047 - }
30483053 }, this.monitorRate )
30493054 }
30503055 } else {
@@ -3104,14 +3109,14 @@
31053110 *
31063111 * @param {Float} perc Value between 0 and 1 for position of playhead
31073112 */
3108 - updatePlayHead: function( perc ) {
 3113+ updatePlayHead: function( perc ) {
31093114 $playHead = this.$interface.find( '.play_head' );
31103115 if ( this.controls && $playHead.length != 0 ) {
31113116 var val = parseInt( perc * 1000 );
31123117 $playHead.slider( 'value', val );
31133118 }
3114 - // @@todo should fix this name:
3115 - $j(this).trigger('updatePlayHeadPercent', perc);
 3119+ // @@todo should have 'progress' trigger the same as html5
 3120+ $j( this ).trigger('updatePlayHeadPercent', perc);
31163121 },
31173122
31183123 /**
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.PlayerSkinKskin.js
@@ -46,8 +46,8 @@
4747 'volumeControl': {
4848 'w':40
4949 },
50 - // No kalturaAttribution component for kSkin ( its integrated into the credits screen )
51 - 'kalturaAttribution' : false,
 50+ // No attributionButton component for kSkin ( its integrated into the credits screen )
 51+ 'attributionButton' : false,
5252
5353 // Time display:
5454 'timeDisplay': {
@@ -315,7 +315,7 @@
316316 );
317317 break;
318318 case 'share':
319 - embedPlayer.$interface.find( '.menu-share').html(
 319+ embedPlayer.$interface.find( '.menu-share' ).html(
320320 this.getShare()
321321 );
322322 break;
@@ -339,7 +339,7 @@
340340 .loadingSpinner()
341341 );
342342
343 - if( mw.getConfig( 'EmbedPlayer.KalturaAttribution' ) == true ){
 343+ if( mw.getConfig( 'EmbedPlayer.KalturaAttribution' ) == true ){
344344 $target.append(
345345 $j( '<div />' )
346346 .addClass( 'k-attribution' )
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -2,6 +2,7 @@
33 * Msg text is inherited from embedPlayer
44 */
55
 6+( function( mw ) {
67 /**
78 * mw.PlayerControlBuilder object
89 * @param the embedPlayer element we are targeting
@@ -43,7 +44,10 @@
4445 'download' : true,
4546
4647 // Share the video menu
47 - 'share' : true
 48+ 'share' : true,
 49+
 50+ // Player library link
 51+ 'aboutPlayerLibrary': true
4852 },
4953
5054 // Flag to store the current fullscreen mode
@@ -161,9 +165,9 @@
162166 if( embedPlayer.isTimedTextSupported() ){
163167 this.supportedComponets['timedText'] = true;
164168 }
165 - // Check for kalturaAttribution
166 - if( mw.getConfig( 'EmbedPlayer.KalturaAttribution' ) ){
167 - this.supportedComponets[ 'kalturaAttribution' ] = true;
 169+ // Check for Attribution button
 170+ if( mw.getConfig( 'EmbedPlayer.AttributionButton' ) ){
 171+ this.supportedComponets[ 'attributionButton' ] = true;
168172 }
169173
170174 // Check global fullscreen enabled flag
@@ -813,7 +817,7 @@
814818 );
815819 }
816820
817 - // Setup play-head slider:
 821+ // Setup volume slider:
818822 var sliderConf = {
819823 range: "min",
820824 value: 80,
@@ -935,6 +939,19 @@
936940 $j( ctrlObj.embedPlayer ).trigger( 'showShareEvent' );
937941 }
938942 )
 943+ },
 944+
 945+ 'aboutPlayerLibrary' : function( ctrlObj ){
 946+ return $j.getLineItem(
 947+ gM( 'mwe-embedplayer-about-library' ),
 948+ 'info',
 949+ function( ) {
 950+ ctrlObj.displayOverlay(
 951+ ctrlObj.aboutPlayerLibrary()
 952+ );
 953+ $j( ctrlObj.embedPlayer ).trigger( 'aboutPlayerLibrary' );
 954+ }
 955+ )
939956 }
940957 },
941958
@@ -1050,7 +1067,25 @@
10511068
10521069 return false; // onclick action return false
10531070 },
1054 -
 1071+ aboutPlayerLibrary: function(){
 1072+ return $j( '<div />' )
 1073+ .append(
 1074+ $j( '<h3 />' )
 1075+ .text(
 1076+ gM('mwe-embedplayer-about-library')
 1077+ )
 1078+ ,
 1079+ $j( '<span />')
 1080+ .append(
 1081+ gM('mwe-embedplayer-about-library-desc',
 1082+ $j('<a />').attr({
 1083+ 'href' : MW_EMBED_LIBRARY_PAGE,
 1084+ 'target' : '_new'
 1085+ })
 1086+ )
 1087+ )
 1088+ )
 1089+ },
10551090 /**
10561091 * Get the "share" interface
10571092 *
@@ -1428,15 +1463,31 @@
14291464 },
14301465
14311466 /**
1432 - * The kaltura attribution button
 1467+ * The Attribution button ( by default this is kaltura-icon
14331468 */
1434 - 'kalturaAttribution' : {
 1469+ 'attributionButton' : {
14351470 'w' : 28,
1436 - 'o' : function( ctrlObj ){
 1471+ 'o' : function( ctrlObj ){
 1472+ var buttonConfig = mw.getConfig( 'EmbedPlayer.AttributionButton');
 1473+
 1474+ var $icon = $j('<span />')
 1475+ .addClass( 'ui-icon' );
 1476+ if( buttonConfig['class'] ){
 1477+ $icon.addClass( buttonConfig['class'] )
 1478+ }
 1479+ // Check for source ( by configuration convention this is a 16x16 image
 1480+ if( buttonConfig.iconurl ){
 1481+ $icon.append(
 1482+ $j('<img />')
 1483+ .css({'width': '16px', 'height': '16px'})
 1484+ .attr('src', buttonConfig.iconurl )
 1485+ )
 1486+ }
 1487+
14371488 return $j('<a />')
14381489 .attr({
1439 - 'href': 'http://kaltura.com',
1440 - 'title' : gM( 'mwe-embedplayer-kaltura-platform-title' ),
 1490+ 'href': buttonConfig.href,
 1491+ 'title' : buttonConfig.title,
14411492 'target' : '_new'
14421493 })
14431494 .append(
@@ -1447,10 +1498,9 @@
14481499 'left' : '2px'
14491500 })
14501501 .append(
1451 - $j('<span />')
1452 - .addClass( 'ui-icon kaltura-icon' )
 1502+ $icon
14531503 )
1454 - )
 1504+ )
14551505 }
14561506 },
14571507
@@ -1687,3 +1737,6 @@
16881738 }
16891739 }
16901740 };
 1741+
 1742+
 1743+} )( window.mw );
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/EmbedPlayer.i18n.php
@@ -34,6 +34,9 @@
3535 'mwe-embedplayer-download' => 'Download',
3636 'mwe-embedplayer-share' => 'Share',
3737 'mwe-embedplayer-credits' => 'Credits',
 38+ 'mwe-embedplayer-about-library'=> 'About kaltura player',
 39+ 'mwe-embedplayer-about-library-desc' => 'Kaltura\'s HTML5 Media Library enables you to take advantage of the html5 &lt;video&gt; and &lt;audio&gt; tags today with a consistent player interface across all major browsers. <br> <br> [$1 More about the kaltura player library].',
 40+
3841 'mwe-embedplayer-clip_linkback' => 'Clip source page',
3942 'mwe-embedplayer-choose_player' => 'Choose video player',
4043 'mwe-embedplayer-no-player' => 'No player available for $1',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js
@@ -138,9 +138,15 @@
139139 )
140140 $clipTrackName = $j( '#' + this.getTrackNameInterfaceId( trackIndex ) );
141141 }
142 - // xxx check for specific smilSequenceTrack updates that require TrackNameInterface update
 142+ // Update the TrackNameInterface duration on every draw::
 143+ /*$clipTrackName.find('.trackDuration').text(
 144+ mw.seconds2npt(
 145+ this.sequencer.getSmil().getBody().getClipDuration( smilSequenceTrack )
 146+ )
 147+ )*/
143148
144149
 150+
145151 // Add Sequence track container if not present
146152 var $clipTrackSet = $j( '#' + this.getTrackSetId( trackIndex ))
147153 mw.log( "SequenceTimeline::drawSequenceTrack: id: " + $clipTrackSet.length );
@@ -776,7 +782,15 @@
777783 $trackNameTitle.find('span').attr('title', $j( smilSequenceTrack ).attr('title') );
778784 }
779785
780 - $trackNameContainer.append( $trackNameTitle )
 786+ $trackNameContainer.append(
 787+ $trackNameTitle
 788+ ,
 789+ // Also append a trackDuration span
 790+ $j( '<br />')
 791+ ,
 792+ $j( '<span />').addClass('trackDuration')
 793+
 794+ )
781795 // Wrap the track name in a box that matches the trackNames
782796 return $trackNameContainer;
783797 },

Status & tagging log