r82581 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82580‎ | r82581 | r82582 >
Date:22:59, 21 February 2011
Author:dale
Status:deferred
Tags:
Comment:
adds popup video support for small video embeds
adds no-javascript support for small video embeds
Modified paths:
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MediaWikiSupport/resources/MediaWikiPlayerSupport.js (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery/jquery.triggerQueueCallback.js (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/mwEmbedSupport.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/TimedMediaHandler.i18n.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/TimedMediaHandler.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/resources/PopUpThumbVideo.css (added) (history)
  • /trunk/extensions/TimedMediaHandler/resources/PopUpThumbVideo.js (added) (history)
  • /trunk/extensions/TimedMediaHandler/resources/jquery.popUpThumbVideo.js (deleted) (history)
  • /trunk/extensions/TimedMediaHandler/resources/player_big_play_button.png (added) (history)
  • /trunk/extensions/TimedMediaHandler/resources/player_big_play_button_hover.png (added) (history)

Diff [purge]

Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MediaWikiSupport/resources/MediaWikiPlayerSupport.js
@@ -205,10 +205,21 @@
206206 }
207207 });
208208
209 - $( embedPlayer ).bind('GetShareIframeCode', function(event, callback){
210 - if( data-mwprovider )
 209+ $( embedPlayer ).bind('GetShareIframeSrc', function(event, callback){
211210 // Check the embedPlayer title key:
212 - iframeSrc = $( embedPlayer).attr( 'data-mwtitle')
 211+ var title = $( embedPlayer).attr( 'data-mwtitle');
 212+ // TODO Check the provider key and use that hosts title page entry point!
 213+ var provider = $( embedPlayer).attr( 'data-mwprovider');
 214+
 215+ var iframeUrl = false;
 216+ if( mw.getConfig('wgServer') && mw.getConfig('wgArticlePath') ){
 217+ iframeUrl = mw.getConfig('wgServer') +
 218+ mw.getConfig('wgArticlePath').replace( /\$1/, 'File:' +
 219+ unescape( embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/ , '' ) ) +
 220+ '?' + mw.getConfig( 'Mw.AppendWithJS' ) + '&embedplayer=yes';
 221+ }
 222+
 223+ callback( iframeUrl );
213224 });
214225 };
215226
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery/jquery.triggerQueueCallback.js
@@ -10,8 +10,8 @@
1111 * With triggerQueueCallback() master callback is not called until all the
1212 * binded events have run their local callbacks.
1313 *
14 - * This is useful in cases where you have multiple modules that need to asyncrusly load
15 - * something at a given binded time.
 14+ * This is useful in cases where you have multiple modules that need to do asynchronous loads
 15+ * before issuing the a callback.
1616 *
1717 * @param {string}
1818 * triggerName Name of trigger to be run
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/mwEmbedSupport.js
@@ -398,7 +398,7 @@
399399 */
400400 mw.addDialog = function ( options ) {
401401 // Remove any other dialog
402 - $j( '#mwTempLoaderDialog' ).remove();
 402+ $j( '#mweDialog' ).remove();
403403
404404 if( !options){
405405 options = {};
@@ -421,7 +421,7 @@
422422 $j( 'body' ).append(
423423 $j('<div />')
424424 .attr( {
425 - 'id' : "mwTempLoaderDialog",
 425+ 'id' : "mweDialog",
426426 'title' : options.title
427427 })
428428 .css({
@@ -455,16 +455,16 @@
456456 ],
457457 uiRequest
458458 ], function() {
459 - $j( '#mwTempLoaderDialog' ).dialog( options );
 459+ $j( '#mweDialog' ).dialog( options );
460460 } );
461 - return $j( '#mwTempLoaderDialog' );
 461+ return $j( '#mweDialog' );
462462 };
463463
464464 /**
465465 * Close the loader dialog created with addLoaderDialog
466466 */
467467 mw.closeLoaderDialog = function() {
468 - $j( '#mwTempLoaderDialog' ).dialog( 'destroy' ).remove();
 468+ $j( '#mweDialog' ).dialog( 'destroy' ).remove();
469469 };
470470
471471 // MOVE TO jquery.client
Index: trunk/extensions/TimedMediaHandler/TimedMediaHandler.i18n.php
@@ -28,6 +28,7 @@
2929 'timedmedia-more' => 'More…',
3030 'timedmedia-dismiss' => 'Close',
3131 'timedmedia-download' => 'Download file',
 32+ 'timedmedia-play-media' => 'Play media',
3233 'timedmedia-desc-link' => 'About this file',
3334 'timedmedia-oggThumb-version' => 'OggHandler requires oggThumb version $1 or later.',
3435 'timedmedia-oggThumb-failed' => 'oggThumb failed to create the thumbnail.',
Index: trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php
@@ -42,18 +42,22 @@
4343 }
4444
4545 function toHtml( $options = array() ) {
46 - global $wgVideoTagOut;
 46+ global $wgVideoTagOut, $wgMinimumVideoPlayerSize, $wgOut;
4747
4848 wfLoadExtensionMessages( 'TimedMediaHandler' );
4949 if ( count( func_get_args() ) == 2 ) {
5050 throw new MWException( __METHOD__ .' called in the old style' );
5151 }
52 -
53 - return $this->getXmlTagOutput(
54 - $this->getMediaAttr(),
55 - $this->getMediaSources(),
56 - $this->getLocalTextSources()
57 - );
 52+
 53+ // Check if the video is too small to play inline ( instead do a pop-up dialog )
 54+ if( $this->width <= $wgMinimumVideoPlayerSize && $this->isVideo ){
 55+ // Make sure we add the popUpThum module
 56+ $wgOut->addModules( 'PopUpMediaTransform' );
 57+ $wgOut->addModuleStyles( 'PopUpMediaTransform' );
 58+ return $this->getImagePopUp();
 59+ } else {
 60+ return $this->getXmlMediaTagOutput();
 61+ }
5862 }
5963 // XXX migrate this to the mediawiki XML class as 'tagSet' helper function
6064 static function xmlTagSet( $tagName, $tagSet ){
@@ -67,25 +71,63 @@
6872 return $s;
6973 }
7074
 75+ function getImagePopUp(){
 76+ return Xml::tags( 'div' , array(
 77+ 'id' => "ogg_thumbplayer_" . TimedMediaTransformOutput::$serial++,
 78+ 'class' => 'PopUpMediaTransform',
 79+ 'style' => "width:" . intval( $this->width ) . "px;height:" .
 80+ intval( $this->getPlayerHeight() ) . "px",
 81+ 'data-videopayload' => $this->getXmlMediaTagOutput( $this->getPopupPlayerSize() ),
 82+ ),
 83+ Xml::tags( 'img', array(
 84+ 'style' => 'width:100%;height:100%;',
 85+ 'src' => $this->getPosterUrl(),
 86+ ),'')
 87+ .
 88+ // For javascript disabled browsers provide a link to the asset:
 89+ Xml::tags( 'a', array(
 90+ 'href'=> $this->file->getUrl(),
 91+ 'title' => wfMsg( 'timedmedia-play-media' )
 92+ ), '<b></b>'. // why is the a child tag escaped unless there is an html string prefix?
 93+ Xml::tags( 'div', array(
 94+ 'class' => 'play-btn-large'
 95+ ), '')
 96+ )
 97+ );
 98+ }
 99+
71100 /**
 101+ * Get target popup player size
 102+ * If player is smaller than threshold return size based on wgDefaultUserOptions )
 103+ */
 104+ function getPopupPlayerSize(){
 105+ global $wgDefaultUserOptions, $wgMinimumVideoPlayerSize, $wgImageLimits;
 106+ // Get the max width from the enabled transcode settings:
 107+ $maxImageSize = WebVideoTranscode::getMaxSizeWebStream();
 108+ return WebVideoTranscode::getMaxSizeTransform( $this->file, $maxImageSize);
 109+ }
 110+
 111+ /**
72112 * Call mediaWiki xml helper class to build media tag output from
73113 * supplied arrays
74114 */
75 - function getXmlTagOutput( $mediaAttr, $mediaSources, $textSources ){
 115+ function getXmlMediaTagOutput( $sizeOverride = array() ){
76116 // Try to get the first source src attribute ( usually this should be the source file )
 117+ $mediaSources = $this->getMediaSources();
77118 $firstSource = current( reset( $mediaSources ) );
78 - if( !$firstSource['url']){
 119+ if( !$firstSource['url'] ){
79120 // XXX media handlers don't seem to work with exceptions..
80121 return 'Error missing media source';
81 - }
 122+ };
 123+
82124 // Build the video tag output:
83 - $s = Xml::tags( $this->getTagName(), $mediaAttr,
 125+ $s = Xml::tags( $this->getTagName(), $this->getMediaAttr( $sizeOverride ),
84126
85127 // The set of media sources:
86128 self::xmlTagSet( 'source', $mediaSources ) .
87129
88130 // Timed text:
89 - self::xmlTagSet( 'track', $textSources ) .
 131+ self::xmlTagSet( 'track', $this->getLocalTextSources() ) .
90132
91133 // Fallback text displayed for browsers without js and without video tag support:
92134 /// XXX note we may want to replace this with an image and download link play button
@@ -94,16 +136,18 @@
95137 return $s;
96138 }
97139
98 - function getMediaAttr(){
 140+ function getMediaAttr( $sizeOverride = false ){
99141 global $wgVideoPlayerSkin ;
100142 // Normalize values
101143 $length = floatval( $this->length );
102144 $offset = floatval( $this->offset );
103 - $width = intval( $this->width );
104145
 146+ $width = ( $sizeOverride )? $sizeOverride[0] : intval( $this->width );
 147+ $height = ( $sizeOverride )? $sizeOverride[1]: $this->getPlayerHeight();
 148+
105149 $mediaAttr = array(
106150 'id' => "ogg_player_" . TimedMediaTransformOutput::$serial++,
107 - 'style' => "width:{$width}px;height:" . $this->getPlayerHeight(). "px",
 151+ 'style' => "width:{$width}px;height:{$height}px",
108152 'poster' => $this->getPosterUrl(),
109153 'alt' => $this->file->getTitle()->getText(),
110154
Index: trunk/extensions/TimedMediaHandler/TimedMediaHandler.php
@@ -37,15 +37,10 @@
3838 $wgAutoloadClasses['WebVideoTranscode'] = "$timedMediaDir/WebVideoTranscode/WebVideoTranscode.php";
3939 $wgAutoloadClasses['WebVideoTranscodeJob'] = "$timedMediaDir/WebVideoTranscode/WebVideoTranscodeJob.php";
4040
41 -// Register the Timed Media Handler javascript resources ( mwEmbed modules )
 41+// Register the Timed Media Handler javascript resources ( MwEmbed modules )
4242 MwEmbedResourceManager::register( 'extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer' );
4343 MwEmbedResourceManager::register( 'extensions/TimedMediaHandler/MwEmbedModules/TimedText' );
4444
45 -// MwEmbed module configuration:
46 -$wgMwEmbedModuleConfig['EmbedPlayer.DirectFileLinkWarning'] = true;
47 -$wgMwEmbedModuleConfig['TimedText.ShowInterface'] = 'always';
48 -
49 -
5045 // Localization
5146 $wgExtensionMessagesFiles['TimedMediaHandler'] = "$timedMediaDir/TimedMediaHandler.i18n.php";
5247 $wgExtensionMessagesFiles['TimedMediaHandlerMagic'] = "$timedMediaDir/TimedMediaHandler.i18n.magic.php";
@@ -75,6 +70,19 @@
7671
7772 /******************* CONFIGURATION STARTS HERE **********************/
7873
 74+/*** MwEmbed module configuration: *********************************/
 75+// Show a warning to the user if they are not using an html5 browser with high quality ogg support
 76+$wgMwEmbedModuleConfig['EmbedPlayer.DirectFileLinkWarning'] = true;
 77+
 78+// The text interface should always be shown
 79+// ( even if there are no text tracks for that asset at render time )
 80+$wgMwEmbedModuleConfig['TimedText.ShowInterface'] = 'always';
 81+
 82+/*** end MwEmbed module configuration: ******************************/
 83+
 84+// The minimum size for an embed video player:
 85+$wgMinimumVideoPlayerSize = 200;
 86+
7987 // Set the supported ogg codecs:
8088 $wgMediaVideoTypes = array( 'Theora', 'VP8' );
8189 $wgMediaAudioTypes = array( 'Vorbis', 'Speex', 'FLAC' );
@@ -94,7 +102,6 @@
95103 // Location of the FFmpeg binary ( used to encode WebM and for thumbnails )
96104 $wgFFmpegLocation = '/usr/bin/ffmpeg';
97105
98 -
99106 /**
100107 * Default enabled transcodes
101108 *
Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
@@ -115,7 +115,7 @@
116116 ) . '/' .
117117 $file->getName() . '.' .
118118 $transcodeKey ;
119 -}
 119+ }
120120
121121 static public function getTargetEncodePath( &$file, $transcodeKey ){
122122 // TODO probably should use some other temporary non-web accessible location for
@@ -124,7 +124,19 @@
125125 $ext = strtolower( pathinfo( "$filePath", PATHINFO_EXTENSION ) );
126126 return "{$filePath}.queue.{$ext}";
127127 }
128 -
 128+ /**
 129+ * Get the max size of the web stream ( constant bitrate )
 130+ */
 131+ static public function getMaxSizeWebStream(){
 132+ global $wgEnabledTranscodeSet;
 133+ $maxSize = 0;
 134+ foreach( $wgEnabledTranscodeSet as $transcodeKey ){
 135+ if( isset( self::$derivativeSettings[$transcodeKey]['videoBitrate'] ) ){
 136+ $maxSize = self::$derivativeSettings[$transcodeKey]['maxSize'];
 137+ }
 138+ }
 139+ return $maxSize;
 140+ }
129141 /**
130142 * Static function to get the set of video assets
131143 *
Index: trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php
@@ -11,7 +11,8 @@
1212 // Register TimedMediaHandler Hooks
1313 static function register(){
1414 global $wgParserOutputHooks, $wgHooks, $wgJobClasses, $wgJobExplitRequestTypes,
15 - $wgMediaHandlers, $wgExcludeFromThumbnailPurge, $wgTimedMediaHandlerFileExtensions;
 15+ $wgMediaHandlers, $wgResourceModules, $wgExcludeFromThumbnailPurge,
 16+ $wgTimedMediaHandlerFileExtensions;
1617
1718 // Setup media Handlers:
1819 $wgMediaHandlers['application/ogg'] = 'OggHandler';
@@ -28,6 +29,18 @@
2930 $wgJobExplitRequestTypes+= array(
3031 'webVideoTranscode'
3132 );
 33+
 34+ // Add the PopUpMediaTransform module ( specific to timedMedia handler ( no support in mwEmbed modules )
 35+ $wgResourceModules+= array(
 36+ 'PopUpMediaTransform' => array(
 37+ 'scripts' => 'resources/PopUpThumbVideo.js',
 38+ 'styles' => 'resources/PopUpThumbVideo.css',
 39+ 'localBasePath' => dirname( __FILE__ ),
 40+ 'remoteExtPath' => 'TimedMediaHandler',
 41+ )
 42+ );
 43+
 44+
3245 // Exclude transcoded assets from normal thumbnail purging
3346 // ( a mantaince script could handle transcode asset purging)
3447 $wgExcludeFromThumbnailPurge += $wgTimedMediaHandlerFileExtensions;
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
@@ -1620,12 +1620,35 @@
16211621 getShareIframeObject: function(){
16221622 // allow modules to generate the iframe:
16231623 var iframeEmbedCode ={};
1624 - $( this ).trigger( 'GetShareIframeCode', [ iframeEmbedCode ] );
1625 - if( iframeEmbedCode.code ){
1626 - return frameEmbedCode.code;
1627 - }
 1624+ var iframeUrl = false
 1625+ $( this ).trigger( 'GetShareIframeSrc', function( localIframeSrc ){
 1626+ if( iframeUrl){
 1627+ mw.log("Error multiple modules binding GetShareIframeSrc" );
 1628+ }
 1629+ iframeUrl = localIframeSrc;
 1630+ });
 1631+
 1632+ if( !iframeUrl ){
 1633+ iframeUrl = this.getIframeSourceUrl()
 1634+ }
16281635
1629 - // old style embed:
 1636+ // Set up embedFrame src path
 1637+ var embedCode = '&lt;iframe src=&quot;' + mw.html.escape( iframeUrl ) + '&quot; ';
 1638+
 1639+ // Set width / height of embed object
 1640+ embedCode += 'width=&quot;' + this.getPlayerWidth() +'&quot; ';
 1641+ embedCode += 'height=&quot;' + this.getPlayerHeight() + '&quot; ';
 1642+ embedCode += 'frameborder=&quot;0&quot; ';
 1643+
 1644+ // Close up the embedCode tag:
 1645+ embedCode+='&gt;&lt/iframe&gt;';
 1646+
 1647+ // Return the embed code
 1648+ return embedCode;
 1649+ },
 1650+
 1651+ getIframeSourceUrl: function(){
 1652+ // Point to raw files:
16301653 var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?';
16311654 var params = {'src[]':[]};
16321655
@@ -1634,7 +1657,7 @@
16351658 for( var i=0; i < this.mediaElement.sources.length; i++ ){
16361659 var source = this.mediaElement.sources[i];
16371660 if( source.src ) {
1638 - params['src[]'].push(mw.absoluteUrl( source.src ));
 1661+ params['src[]'].push(mw.absoluteUrl( source.src ));
16391662 }
16401663 }
16411664 // Output the poster attr
@@ -1652,22 +1675,9 @@
16531676 params['data-durationhint'] = parseFloat( this.duration );
16541677 }
16551678 iframeUrl += $j.param( params );
1656 -
1657 - // Set up embedFrame src path
1658 - var embedCode = '&lt;iframe src=&quot;' + mw.html.escape( iframeUrl ) + '&quot; ';
1659 -
1660 - // Set width / height of embed object
1661 - embedCode += 'width=&quot;' + this.getPlayerWidth() +'&quot; ';
1662 - embedCode += 'height=&quot;' + this.getPlayerHeight() + '&quot; ';
1663 - embedCode += 'frameborder=&quot;0&quot; ';
1664 -
1665 - // Close up the embedCode tag:
1666 - embedCode+='&gt;&lt/iframe&gt;';
1667 -
1668 - // Return the embed code
1669 - return embedCode;
 1679+ return iframeUrl;
16701680 },
1671 -
 1681+
16721682 /**
16731683 * Get the share embed Video tag code
16741684 */
Index: trunk/extensions/TimedMediaHandler/resources/jquery.popUpThumbVideo.js
@@ -1,13 +0,0 @@
2 -/**
3 -* Simple script to add pop-up video dialog link support for video thumbnails
4 -*/
5 -( function( mw, $ ) {
6 -
7 - $.fn.popUpVideoLink( options ){
8 - $j(this).click(function(){
9 - // Spawn a new dialog window with the video asset
10 -
11 - })
12 - }
13 -
14 -} )( mediaWiki, jQuery );
\ No newline at end of file
Index: trunk/extensions/TimedMediaHandler/resources/player_big_play_button.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/TimedMediaHandler/resources/player_big_play_button.png
___________________________________________________________________
Added: svn:executable
151 + *
Added: svn:mime-type
162 + application/octet-stream
Index: trunk/extensions/TimedMediaHandler/resources/PopUpThumbVideo.css
@@ -0,0 +1,16 @@
 2+.PopUpMediaTransform a .play-btn-large{
 3+ position : absolute;
 4+ top: 50%;
 5+ left : 50%;
 6+ width: 70px;
 7+ height: 53px;
 8+ margin-left: -35px;
 9+ margin-top: -25px;
 10+ background-image:url('player_big_play_button.png');
 11+}
 12+.PopUpMediaTransform a .play-btn-large :hover{
 13+ background-image:url('player_big_play_button_hover.png');
 14+}
 15+.PopUpMediaTransform {
 16+ position : relative;
 17+}
\ No newline at end of file
Property changes on: trunk/extensions/TimedMediaHandler/resources/PopUpThumbVideo.css
___________________________________________________________________
Added: svn:mime-type
118 + text/plain
Index: trunk/extensions/TimedMediaHandler/resources/player_big_play_button_hover.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/TimedMediaHandler/resources/player_big_play_button_hover.png
___________________________________________________________________
Added: svn:mime-type
219 + application/octet-stream
Index: trunk/extensions/TimedMediaHandler/resources/PopUpThumbVideo.js
@@ -0,0 +1,25 @@
 2+/**
 3+* Simple script to add pop-up video dialog link support for video thumbnails
 4+*/
 5+( function( mw, $ ) {
 6+
 7+ $(document).ready(function(){
 8+ $('.PopUpMediaTransform').each(function(){
 9+ var _parent = this;
 10+ $(this).find('a').click( function(){
 11+ var $video = $( unescape( $(_parent).attr('data-videopayload') ) );
 12+ mw.addDialog({
 13+ 'width' : parseInt( $video.css('width') ) + 25,
 14+ 'height' : parseInt( $video.css('height') ) + 45,
 15+ 'title' : $video.attr('data-mwtitle'),
 16+ 'content' : $video
 17+ })
 18+ .find('video').embedPlayer();
 19+ // don't follow file link
 20+ return false;
 21+ });
 22+
 23+ });
 24+ });
 25+
 26+} )( mediaWiki, jQuery );
\ No newline at end of file
Property changes on: trunk/extensions/TimedMediaHandler/resources/PopUpThumbVideo.js
___________________________________________________________________
Added: svn:eol-style
127 + native
Added: svn:mime-type
228 + text/plain

Status & tagging log