r88192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88191‎ | r88192 | r88193 >
Date:14:58, 15 May 2011
Author:dale
Status:deferred
Tags:
Comment:
Fixed the audio rendering support to have a set size and work better with default size of player by
Removed the source selection controlBar component when there is only one source available
Modified paths:
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php
@@ -52,10 +52,19 @@
5353 if ( $this->isVideo ) {
5454 return intval( $this->height );
5555 } else {
56 - // Give sound files a height of 0
57 - return 0;
 56+ // Give sound files a height of 20px
 57+ return 20;
5858 }
5959 }
 60+ function getPlayerWidth(){
 61+ // Check if "video" tag output:
 62+ if ( $this->isVideo ) {
 63+ return intval( $this->width );
 64+ } else {
 65+ // Give sound files a height of 20px
 66+ return 220;
 67+ }
 68+ }
6069
6170 function getTagName(){
6271 return ( $this->isVideo ) ? 'video' : 'audio';
@@ -92,7 +101,7 @@
93102 return Xml::tags( 'div' , array(
94103 'id' => "ogg_thumbplayer_" . TimedMediaTransformOutput::$serial++,
95104 'class' => 'PopUpMediaTransform',
96 - 'style' => "width:" . intval( $this->width ) . "px;height:" .
 105+ 'style' => "width:" . intval( $this->getPlayerWidth() ) . "px;height:" .
97106 intval( $this->getPlayerHeight() ) . "px",
98107 'data-videopayload' => $this->getXmlMediaTagOutput( $this->getPopupPlayerSize() ),
99108 ),
@@ -190,7 +199,7 @@
191200 $length = floatval( $this->length );
192201 $offset = floatval( $this->offset );
193202
194 - $width = $sizeOverride ? $sizeOverride[0] : intval( $this->width );
 203+ $width = $sizeOverride ? $sizeOverride[0] : $this->getPlayerWidth();
195204 $height = $sizeOverride ? $sizeOverride[1]: $this->getPlayerHeight();
196205
197206 // The poster url:
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
@@ -208,7 +208,7 @@
209209 $( mw ).trigger ( 'EmbedPlayerNewPlayer', $( '#' + playerInterface.id ).get(0) );
210210
211211 // Add a player ready binding:
212 - $( '#' + playerInterface.id ).bind( 'playerReady', areSelectedPlayersReady);
 212+ $( '#' + playerInterface.id ).bind( 'playerReady', areSelectedPlayersReady );
213213
214214 // Issue the checkPlayerSources call to the new player
215215 // interface: make sure to use the element that is in the DOM:
@@ -527,6 +527,9 @@
528528
529529 var playerAttributes = mw.getConfig( 'EmbedPlayer.Attributes' );
530530
 531+ // Copy over the tag type
 532+ this.virtualTagName = element.tagName.toLowerCase();
 533+
531534 // Setup the player Interface from supported attributes:
532535 for ( var attr in playerAttributes ) {
533536 // We can't use $(element).attr( attr ) because we have to check for boolean attributes:
@@ -690,13 +693,13 @@
691694 // Special case for audio
692695 // Firefox sets audio height to "0px" while webkit uses 32px .. force
693696 // zero:
694 - if( element.tagName.toLowerCase() == 'audio' && this.height == '32' ) {
695 - this.height = 0;
 697+ if( this.isAudio() && this.height == '32' ) {
 698+ this.height = 20;
696699 }
697700
698701 // Use default aspect ration to get height or width ( if rewriting a
699702 // non-audio player )
700 - if( element.tagName.toLowerCase() != 'audio' && this.videoAspect ) {
 703+ if( this.isAudio() && this.videoAspect ) {
701704 var aspect = this.videoAspect.split( ':' );
702705 if( this.height && !this.width ) {
703706 this.width = parseInt( this.height * ( aspect[0] / aspect[1] ) );
@@ -724,8 +727,8 @@
725728 }
726729
727730 // Special height default for audio tag ( if not set )
728 - if( element.tagName.toLowerCase() == 'audio' ) {
729 - this.height = 0;
 731+ if( this.isAudio() ) {
 732+ this.height = 20;
730733 }else{
731734 this.height = defaultSize[1];
732735 }
@@ -966,12 +969,14 @@
967970 * Check if the selected source is an audio element:
968971 */
969972 isAudio: function(){
970 - return ( this.mediaElement.selectedSource.mimeType.indexOf('audio/') !== -1 );
 973+ return ( this.virtualTagName == 'audio'
 974+ ||
 975+ ( this.mediaElement && this.mediaElement.selectedSource.mimeType.indexOf('audio/') !== -1 )
 976+ );
971977 },
972978
973979 /**
974 - * Get the plugin embed html ( should be implemented by embed player
975 - * interface )
 980+ * Get the plugin embed html ( should be implemented by embed player interface )
976981 */
977982 doEmbedHTML: function() {
978983 return 'Error: function doEmbedHTML should be implemented by embed player interface ';
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
@@ -129,7 +129,8 @@
130130 'height' : parseInt( embedPlayer.height ) - parseInt( this.height )
131131 } );
132132 }*/
133 - // Make room for audio controls in the interface:
 133+
 134+ // Make room for audio controls in the interface ( if we have a zero height
134135 if( embedPlayer.isAudio() && embedPlayer.$interface.height() == 0 ){
135136 embedPlayer.$interface.css( {
136137 'height' : this.height
@@ -180,6 +181,10 @@
181182 this.supportedComponets[ 'options'] = false;
182183 }
183184
 185+ // Check if we have multiple playable sources ( if only one source don't display source switch )
 186+ if( embedPlayer.mediaElement.getPlayableSources().length == 1 ){
 187+ this.supportedComponets[ 'sourceSwitch'] = false;
 188+ }
184189
185190 var addComponent = function( component_id ){
186191 if ( _this.supportedComponets[ component_id ] ) {
@@ -850,13 +855,12 @@
851856 if( mw.isIpad() ){
852857 return false;
853858 }
854 -
855859
856 - // Don't hide controls when content "height" is 0px ( audio tags )
857 - if( this.embedPlayer.getPlayerHeight() === 0 &&
858 - $(this.embedPlayer).css('height').indexOf('%') === -1 ){
 860+ // Don't hide controls when its an audio player
 861+ if( this.embedPlayer.isAudio() ){
859862 return false;
860863 }
 864+
861865 if( this.embedPlayer.controls === false ){
862866 return false;
863867 }

Status & tagging log