r75504 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75503‎ | r75504 | r75505 >
Date:04:47, 27 October 2010
Author:dale
Status:resolved (Comments)
Tags:
Comment:
* bug 25661 set warning msg to <label /> rather than <span />
* bug 25658 workaround for webkit/ quicktime draw error
* fix cookie warning check
* forced synchronize loads ( resource loader update stopgap )
* updated iframe support for kaltura based iframe rewrite
* updated embedPlayer to deal better with non pixle based css sizes ( ie 100% )
* fixed tigger events per useNativePlayerControls option ( prevents doulbe event firing )
* switched to iframe for default 'share' option ( allows for cross domain messaging api while preserving css / javascript sandbox )
* added list of html5 events to native player ( will refactor event handling shortly )
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.PlayerSkinKskin.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.style.PlayerSkinKskin.css (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbedFrame.php (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbedFrame.php
@@ -27,10 +27,11 @@
2828 'apiProvider',
2929 'durationHint',
3030 'poster',
31 - 'kEntryId',
32 - 'kWidgetId' ,
33 - 'skin'
 31+ 'kentryid',
 32+ 'kwidgetid' ,
 33+ 'skin'
3434 );
 35+ var $playerIframeId = 'iframeVid';
3536
3637 // When used in direct source mode the source asset.
3738 // NOTE: can be an array of sources in cases of "many" sources set
@@ -53,7 +54,12 @@
5455 $this->$attributeKey = htmlspecialchars( $_GET[$attributeKey] );
5556 }
5657 }
57 -
 58+
 59+ // Check for debug flag
 60+ if( isset( $_GET['debug'] ) ){
 61+ $this->debug = true;
 62+ }
 63+
5864 // Process the special "src" attribute
5965 if( isset( $_GET['src'] ) ){
6066 if( is_array( $_GET['src'] ) ){
@@ -66,12 +72,14 @@
6773 }
6874
6975 }
70 - private function getVideoTag(){
 76+ private function getVideoTag( ){
7177 // Add default video tag with 100% width / height
7278 // ( parent embed is responsible for setting the iframe size )
73 - $o = '<video style="width:100%;height:100%"';
 79+ $o = '<video id="' . htmlspecialchars( $this->playerIframeId ) . '" style="width:100%;height:100%"';
7480 foreach( $this->playerAttributes as $attributeKey){
75 - $o.= ' ' . $attributeKey . '="' . htmlspecialchars( $this->$attributeKey ) . '"';
 81+ if( isset( $this->$attributeKey ) ){
 82+ $o.= ' ' . $attributeKey . '="' . htmlspecialchars( $this->$attributeKey ) . '"';
 83+ }
7684 }
7785 //Close the video attributes
7886 $o.='>';
@@ -81,14 +89,14 @@
8290 $o.= '<source src="' . htmlspecialchars( $src ) . '"></source>';
8391 }
8492 }
85 - $o.= '</video>';
 93+ $o.= '</video>';
8694 return $o;
8795 }
8896 private function outputEmbedFrame( ){
8997 // Setup the embed string based on attribute set:
9098 $embedResourceList = 'window.jQuery,mwEmbed,mw.style.mwCommon,$j.fn.menu,mw.style.jquerymenu,mw.EmbedPlayer,mw.EmbedPlayerNative,mw.EmbedPlayerJava,mw.PlayerControlBuilder,$j.fn.hoverIntent,mw.style.EmbedPlayer,$j.cookie,$j.ui,mw.style.ui_redmond,$j.widget,$j.ui.mouse,mw.PlayerSkinKskin,mw.style.PlayerSkinKskin,mw.TimedText,mw.style.TimedText,$j.ui.slider';
9199
92 - if( $this->kEntryId ){
 100+ if( $this->kentryid ){
93101 $embedResourceList.= ',' . implode(',', array(
94102 'KalturaClientBase',
95103 'KalturaClient',
@@ -99,7 +107,7 @@
100108 'mw.KWidgetSupport',
101109 'mw.KAnalytics',
102110 'mw.KDPMapping',
103 - 'mw.MobilePlayerTimeline',
 111+ 'mw.MobileAdTimeline',
104112 'mw.KAds'
105113 ) );
106114 }
@@ -110,32 +118,45 @@
111119 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
112120 <title>mwEmbed iframe</title>
113121 <style type="text/css">
114 - body {
115 - margin-left: 0px;
116 - margin-top: 0px;
117 - margin-right: 0px;
118 - margin-bottom: 0px;
 122+ body {
 123+ margin:0;
 124+ position:fixed;
 125+ top:0px;
 126+ left:0px;
 127+ bottom:0px;
 128+ right:0px;
 129+
119130 }
120 - </style>
121 - <script type="text/javascript" src="ResourceLoader.php?class=<?php echo $embedResourceList?>"></script>
 131+ </style>
 132+ <script type="text/javascript" src="ResourceLoader.php?class=<?php
 133+ echo $embedResourceList;
 134+ if( $this->debug ){
 135+ echo '&debug=true';
 136+ }
 137+ ?>"></script>
 138+
122139 <script type="text/javascript">
123140 //Set some iframe embed config:
124 -
125 - // Do not overlay controls since we cant dynamically resize the embed window.
126 - mw.setConfig( 'EmbedPlayer.OverlayControls', false );
127 -
128141 // We can't support full screen in object context since it requires outter page DOM control
129142 mw.setConfig( 'EmbedPlayer.EnableFullscreen', false );
 143+
 144+ // Enable the iframe player server:
 145+ mw.setConfig( 'EmbedPlayer.EnalbeIFramePlayerServer', true );
130146
 147+ mw.ready(function(){
 148+ // Trigger fullscreen so that iframe resize keeps player size
 149+ $j( '#<?php echo htmlspecialchars( $this->playerIframeId )?>' )
 150+ .get(0).fullscreen();
 151+ });
131152 </script>
132153 </head>
133154 <body>
134155 <?
135 - // Check if we have code to output player embed
136 - if( $this->apiTitleKey || count( $this->sources ) != 0 ) {
 156+ // Check if we have a way to get sources:
 157+ if( $this->apiTitleKey || $this->kentryid || count( $this->sources ) != 0 ) {
137158 echo $this->getVideoTag();
138159 } else {
139 - echo "Error: mwEmbedFrame missing required parameter ( src or apiTitleKey )";
 160+ echo "Error: mwEmbedFrame missing required parameter for video sources";
140161 }
141162 ?>
142163 </body>
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -398,17 +398,17 @@
399399
400400 // xxx should use refactor "ready" stuff into a "domReady" class
401401 // So we would not have local scope globals like this:
402 - if ( mwReadyFlag ) {
 402+ //if ( mwReadyFlag ) {
403403 // Load the module directly if load request is after
404404 // mw.ready has run
405 - this.load( resourceSet, callback );
406 - } else {
407 - this.addToModuleLoaderQueue(
408 - loadRequest,
409 - resourceSet,
410 - callback
411 - );
412 - }
 405+ this.load( resourceSet, callback );
 406+ //} else {
 407+ // this.addToModuleLoaderQueue(
 408+ // loadRequest,
 409+ // resourceSet,
 410+ // callback
 411+ // );
 412+ //}
413413 return ;
414414 }
415415
@@ -1419,12 +1419,12 @@
14201420
14211421 // If jQuery is available and debug is off load the script via jQuery
14221422 // ( will use XHR if on same domain )
1423 - if( mw.isset( 'window.jQuery' )
1424 - && mw.getConfig( 'debug' ) === false
 1423+ if( mw.isset( 'window.jQuery' )
 1424+ && mw.getConfig( 'debug' ) === false
14251425 && typeof $j != 'undefined'
14261426 && mw.parseUri( url ).protocal != 'file'
14271427 && !isCssFile )
1428 - {
 1428+ {
14291429 $j.getScript( url, myCallback);
14301430 return ;
14311431 }
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js
@@ -61,20 +61,25 @@
6262
6363 // The default share embed mode ( can be "object" or "videojs" )
6464 //
65 - // "object" will provide a <object tag pointing to mwEmbedFrame.php
 65+ // "iframe" will provide a <iframe tag pointing to mwEmbedFrame.php
6666 // Object embedding should be much more compatible with sites that
6767 // let users embed flash applets
6868 // "videojs" will include the source javascript and video tag to
6969 // rewrite the player on the remote page DOM
7070 // Video tag embedding is much more mash-up friendly but exposes
7171 // the remote site to the mwEmbed javascript and can be a xss issue.
72 - "EmbedPlayer.ShareEmbedMode" : 'object',
 72+ "EmbedPlayer.ShareEmbedMode" : 'iframe',
7373
7474 // Default player skin name
7575 "EmbedPlayer.SkinName" : "mvpcf",
7676
7777 // Number of milliseconds between interface updates
78 - 'EmbedPlayer.MonitorRate' : 250
 78+ 'EmbedPlayer.MonitorRate' : 250,
 79+
 80+ // If the embedPlayer should accept arguments from
 81+ 'EmbedPlayer.EnalbeIFramePlayerServer' : false,
 82+
 83+ 'EmbedPLayer.IFramePlayer.DomainWhiteList' : '*'
7984 } );
8085
8186 // Add class file paths
@@ -98,7 +103,10 @@
99104 "mw.PlayerSkinKskin" : "skins/kskin/mw.PlayerSkinKskin.js",
100105
101106 "mw.PlayerSkinMvpcf" : "skins/mvpcf/mw.PlayerSkinMvpcf.js",
102 - "mw.style.PlayerSkinMvpcf" : "skins/mvpcf/mw.style.PlayerSkinMvpcf.css"
 107+ "mw.style.PlayerSkinMvpcf" : "skins/mvpcf/mw.style.PlayerSkinMvpcf.css",
 108+
 109+ "mw.IFramePlayerApiServer" : "mw.IFramePlayerApiServer.js",
 110+ "mw.IFramePlayerApiClient" : "mw.IFramePlayerApiClient.js"
103111 } );
104112
105113 /**
@@ -124,12 +132,10 @@
125133 * mwEmbed player is setup before any other mw.ready calls
126134 */
127135 mw.addSetupHook( function( callback ) {
128 - mw.rewritePagePlayerTags();
129 - // Run the setupFlag to continue setup
130 - callback();
 136+ mw.rewritePagePlayerTags( callback );
131137 });
132138
133 - mw.rewritePagePlayerTags = function() {
 139+ mw.rewritePagePlayerTags = function( callback ) {
134140 mw.log( 'EmbedPlayer:: Document::' + mw.documentHasPlayerTags() );
135141 if( mw.documentHasPlayerTags() ) {
136142 var rewriteElementCount = 0;
@@ -147,13 +153,15 @@
148154 .attr('id', 'loadingSpinner_' + $j( element ).attr('id') )
149155 .addClass( 'playerLoadingSpinner' );
150156
151 - });
 157+ });
152158 // Load the embedPlayer module ( then run queued hooks )
153 - mw.load( 'EmbedPlayer', function ( ) {
 159+ mw.load( 'EmbedPlayer', function ( ) {
154160 mw.log("EmbedPlayer:: do rewrite players:" + $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).length );
155161 // Rewrite the EmbedPlayer.RewriteTags with the
156 - $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer();
 162+ $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer( callback );
157163 })
 164+ } else {
 165+ callback();
158166 }
159167 }
160168
@@ -185,8 +193,7 @@
186194 '$j.fn.menu',
187195 'mw.style.jquerymenu',
188196 '$j.ui.slider'
189 - ]
190 -
 197+ ]
191198 ];
192199
193200 // Pass every tag being rewritten through the update request function
@@ -242,7 +249,13 @@
243250 if( $j.inArray( 'mw.style.PlayerSkin' + skinCaseName, dependencyRequest ) == -1 ){
244251 dependencyRequest.push( 'mw.style.PlayerSkin' + skinCaseName );
245252 }
246 -
 253+
 254+ // Check if the iFrame player server is enabled:
 255+ if( mw.getConfig('EmbedPlayer.EnalbeIFramePlayerServer') ){
 256+ dependencyRequest.push( 'mw.IFramePlayerApiServer' );
 257+ }
 258+
 259+
247260 // Allow extension to extend the request.
248261 $j( mw ).trigger( 'LoaderEmbedPlayerUpdateRequest',
249262 [ playerElement, dependencyRequest ] );
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -440,7 +440,7 @@
441441 $j( '#' + playerInterface.id ).data( i, $j( playerElement ).data( i ) );
442442 }
443443 }
444 - }
 444+ }
445445
446446 // Pass the id to any hook that needs to interface prior to checkPlayerSources
447447 mw.log("EmbedPlayer::addElement :trigger " + playerInterface.id );
@@ -580,8 +580,8 @@
581581
582582 // Set swapPlayerElement has height / width set and set to loading:
583583 $j( swapPlayerElement ).css( {
584 - 'width' : playerInterface.width + 'px',
585 - 'height' : playerInterface.height + 'px'
 584+ 'width' : playerInterface.width,
 585+ 'height' : playerInterface.height
586586 } );
587587
588588 // If we don't already have a loadSpiner add one:
@@ -1385,10 +1385,12 @@
13861386 // string -> boolean
13871387 if( this[ attr ] == "false" ) this[attr] = false;
13881388 if( this[ attr ] == "true" ) this[attr] = true;
1389 - }
 1389+ }
 1390+ //
13901391
 1392+
13911393 if( this.apiTitleKey ){
1392 - this.apiTitleKey = unescape( this.apiTitleKey );
 1394+ this.apiTitleKey = decodeURI( this.apiTitleKey );
13931395 }
13941396
13951397 // Hide "controls" if using native player controls:
@@ -1499,15 +1501,32 @@
15001502 * @param {Element} element Source element to grab size from
15011503 */
15021504 setPlayerSize: function( element ) {
 1505+
 1506+ this.height = $j(element).css( 'height' );
 1507+ this.width = $j(element).css( 'width' );
15031508
1504 - this.height = parseInt( $j(element).css( 'height' ) );
1505 - this.width = parseInt( $j(element).css( 'width' ) );
1506 -
1507 - if( !this.height && !this.width ) {
1508 - this.height = parseInt( $j(element).attr( 'height' ) );
1509 - this.width = parseInt( $j(element).attr( 'width' ) );
1510 - }
 1509+ // Set to parent size ( resize events will cause player size updates)
 1510+ if( this.height.indexOf('100%') != -1 || this.width.indexOf('100%') != -1 ){
 1511+ $relativeParent = $j(element).parents().filter(function() {
 1512+ // reduce to only relative position or "body" elements
 1513+ return $j(this).is('body') || $j(this).css('position') == 'relative';
 1514+ }).slice(0,1); // grab only the "first"
 1515+ this.width = $relativeParent.width();
 1516+ this.height = $relativeParent.height();
 1517+ }
 1518+ // make sure height and width are a number
 1519+ this.height = parseInt( this.height );
 1520+ this.width = parseInt( this.width );
 1521+
 1522+ // Set via attribute if CSS is zero or NaN and we have an attribute value:
 1523+ this.height = ( this.height==0 || isNaN( this.height )
 1524+ && $j(element).attr( 'height' ) ) ?
 1525+ parseInt( $j(element).attr( 'height' ) ): this.height;
 1526+ this.width = ( this.width == 0 || isNaN( this.width )
 1527+ && $j(element).attr( 'width' ) )?
 1528+ parseInt( $j(element).attr( 'width' ) ): this.width;
15111529
 1530+
15121531 // Special case for audio
15131532 // Firefox sets audio height to "0px" while webkit uses 32px .. force zero:
15141533 if( element.tagName.toLowerCase() == 'audio' && this.height == '32' ) {
@@ -1556,7 +1575,7 @@
15571576 this.width = size.width;
15581577 this.height = size.height;
15591578 var playerSize = {'width' : this.width, 'height' : this.height };
1560 - // check if height needs to include interface contorls
 1579+ // check if height needs to include interface controls
15611580 if( ! this.controlBuilder.checkOverlayControls() ){
15621581 size.height = size.height + this.controlBuilder.height;
15631582 }
@@ -1576,7 +1595,7 @@
15771596 * @return {Number} pixel height of the video
15781597 */
15791598 getPlayerWidth: function() {
1580 - return parseInt( this.width );
 1599+ return $j( this ).width();
15811600 },
15821601
15831602 /**
@@ -1585,7 +1604,7 @@
15861605 * @return {Number} pixel height of the video
15871606 */
15881607 getPlayerHeight: function() {
1589 - return parseInt( this.height );
 1608+ return $j( this ).height();
15901609 },
15911610
15921611 /**
@@ -1726,7 +1745,7 @@
17271746 */
17281747 checkForTimedText: function( ) {
17291748 var _this = this;
1730 - mw.log( 'EmbedPlayer::checkForTimedText: ' + _this.id + " height: " + this.height );
 1749+ mw.log( 'EmbedPlayer::checkForTimedText: ' + _this.id );
17311750 // Check for timedText support
17321751 if( this.isTimedTextSupported() ) {
17331752 mw.load( 'TimedText', function() {
@@ -2052,7 +2071,7 @@
20532072 * Show the player
20542073 */
20552074 showPlayer : function () {
2056 - mw.log( 'EmbedPlayer:: Show player: ' + this.id );
 2075+ mw.log( 'EmbedPlayer:: Show player: ' + this.id + ' interace: w:' + this.width + ' h:' + this.height);
20572076 var _this = this;
20582077 // Set-up the local controlBuilder instance:
20592078 this.controlBuilder = new mw.PlayerControlBuilder( this );
@@ -2065,8 +2084,8 @@
20662085 $j('<div>')
20672086 .addClass( 'mwplayer_interface ' + this.controlBuilder.playerClass )
20682087 .css({
2069 - 'width' : parseInt( this.width ) + 'px',
2070 - 'height' : parseInt( this.height ) + 'px',
 2088+ 'width' : this.width,
 2089+ 'height' : this.height,
20712090 'position' : 'relative'
20722091 })
20732092 )
@@ -2177,34 +2196,9 @@
21782197 this.serverSeekTime = mw.npt2seconds( start_npt );
21792198 }
21802199 },
 2200+
21812201
21822202 /**
2183 - * Render a thumbnail at a given time
2184 - * NOTE: Should overwrite by embed library if we can render frames natively
2185 - *
2186 - * @param {Object} options Options for rendered timeline thumb
2187 - */
2188 - renderTimelineThumbnail: function( options ) {
2189 - var my_thumb_src = this.mediaElement.getPosterSrc();
2190 - // check if our thumbnail has a time attribute:
2191 - if ( my_thumb_src.indexOf( 't=' ) !== -1 ) {
2192 - var time_ntp = mw.seconds2npt ( options.time + parseInt( this.startOffset ) );
2193 - my_thumb_src = mw.replaceUrlParams( my_thumb_src, {
2194 - 't' : time_ntp,
2195 - 'size' : options.size
2196 - });
2197 - }
2198 - var thumb_class = ( typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : '';
2199 - return '<div class="ui-corner-all ' + thumb_class + '" src="' + my_thumb_src + '" ' +
2200 - 'style="height:' + options.height + 'px;' +
2201 - 'width:' + options.width + 'px" >' +
2202 - '<img src="' + my_thumb_src + '" ' +
2203 - 'style="height:' + options.height + 'px;' +
2204 - 'width:' + options.width + 'px">' +
2205 - '</div>';
2206 - },
2207 -
2208 - /**
22092203 * Update Thumb time with npt formated time
22102204 * @param {String} time NPT formated time to update thumbnail
22112205 */
@@ -2482,8 +2476,8 @@
24832477 */
24842478 getEmbeddingHTML: function() {
24852479 switch( mw.getConfig( 'EmbedPlayer.ShareEmbedMode' ) ){
2486 - case 'object':
2487 - return this.getShareEmbedObject()
 2480+ case 'iframe':
 2481+ return this.getShareIframeObject();
24882482 break;
24892483 case 'videojs':
24902484 return this.getShareEmbedVideoJs();
@@ -2532,31 +2526,18 @@
25332527
25342528 if( this.duration ) {
25352529 params.durationHint = parseFloat( this.duration );
2536 - }
2537 - // Set width / height of iframe embed ( child iframe / object can't read parent frame size )
2538 - if( this.width ){
2539 - params.width = parseInt( this.width );
2540 - }
2541 - if( this.height ){
2542 - params.height = parseInt( this.height );
2543 - }
 2530+ }
25442531 iframeUrl += $j.param( params );
25452532
25462533 // Set up embedFrame src path
2547 - var embedCode = '&lt;object data=&quot;' + mw.escapeQuotesHTML( iframeUrl ) + '&quot; ';
 2534+ var embedCode = '&lt;iframe src=&quot;' + mw.escapeQuotesHTML( iframeUrl ) + '&quot; ';
25482535
2549 - // Set width / height of embed object ( give extra space for controls )
2550 - if( this.width || this.height ){
2551 - embedCode += ( this.width )? 'width=&quot;' + this.width +'&quot; ': '';
2552 - embedCode += ( this.height )? 'height=&quot;' +
2553 - parseInt( this.height + this.controlBuilder.getHeight() + 2 ) +
2554 - '&quot; ': '';
2555 - }
2556 - //Make sure overflow is hidden:
2557 - embedCode += 'style=&quot;overflow:hidden&quot; ';
2558 -
 2536+ // Set width / height of embed object
 2537+ embedCode += 'width=&quot;' + this.getPlayerWidth() +'&quot; ';
 2538+ embedCode += 'height=&quot;' + this.getPlayerHeight() + '&quot; ';
 2539+
25592540 // Close up the embedCode tag:
2560 - embedCode+='&gt;&lt/object&gt;';
 2541+ embedCode+='&gt;&lt/iframe&gt;';
25612542
25622543 // Return the embed code
25632544 return embedCode;
@@ -2671,7 +2652,15 @@
26722653 * Starts the "monitor"
26732654 */
26742655 play: function() {
2675 - var _this = this;
 2656+ var _this = this;
 2657+ // Run play hook (if we we did not bind the native player )
 2658+ if( this.paused && this.useNativePlayerControls() ){
 2659+ this.paused = false;
 2660+ mw.log("trigger play event::" + !this.paused);
 2661+ $j( this ).trigger( 'play' );
 2662+ }
 2663+ this.paused = false;
 2664+
26762665 mw.log( "EmbedPlayer:: play" );
26772666 // Hide any overlay:
26782667 this.controlBuilder.closeMenuOverlay();
@@ -2689,16 +2678,9 @@
26902679 } else {
26912680 // the plugin is already being displayed
26922681 this.seeking = false;
2693 - }
 2682+ }
26942683
2695 - // Run play hook (if we were previously in paused state )
2696 - if( this.paused ){
2697 - this.paused = false;
2698 - mw.log("trigger play event::");
2699 - //$j( this ).trigger( 'play' );
2700 - }
27012684
2702 -
27032685 this.$interface.find('.play-btn span')
27042686 .removeClass( 'ui-icon-play' )
27052687 .addClass( 'ui-icon-pause' );
@@ -2740,13 +2722,13 @@
27412723 */
27422724 pause: function( event ) {
27432725 var _this = this;
2744 -
2745 - // only trigger the pause event if not already in paused state:
2746 - if( this.paused === false ){
 2726+ // Trigger the pause event if not already paused and using native controls:
 2727+ if( this.paused === false && this.useNativePlayerControls() ){
27472728 this.paused = true;
2748 - mw.log('EmbedPlayer:trigger pause');
2749 - //$j( this ).trigger('pause' );
2750 - }
 2729+ mw.log('EmbedPlayer:trigger pause:' + this.paused);
 2730+ $j( this ).trigger('pause' );
 2731+ }
 2732+ this.paused = true;
27512733
27522734 // update the ctrl "paused state"
27532735 this.$interface.find('.play-btn span' )
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.style.PlayerSkinKskin.css
@@ -187,7 +187,6 @@
188188 border: medium none;
189189 display: none;
190190 left: 0;
191 - opacity: 0.9;
192191 position: absolute;
193192 top: 0;
194193 z-index: 2;
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/kskin/mw.PlayerSkinKskin.js
@@ -36,7 +36,7 @@
3737 .append(
3838 $j( '<span />' )
3939 .text( gM( 'mwe-embedplayer-menu_btn' ) )
40 - )
 40+ );
4141 }
4242 },
4343 'volumeControl': {
@@ -63,7 +63,14 @@
6464 'top' : '0px',
6565 'bottom' : ( ctrlObj.getHeight() + 2 ) + 'px'
6666 } );
67 -
 67+
 68+ // Note safari can't display video overlays with text:
 69+ // see bug https://bugs.webkit.org/show_bug.cgi?id=48379
 70+
 71+ var userAgent = navigator.userAgent.toLowerCase();
 72+ if( userAgent.indexOf('safari') != -1 ){
 73+ $menuOverlay.css('opacity', '0.9');
 74+ }
6875 // Setup menu offset ( if player height < getOverlayHeight )
6976 // This displays the menu outside of the player on small embeds
7077 if ( embedPlayer.getPlayerHeight() < ctrlObj.getOverlayHeight() ) {
@@ -116,7 +123,7 @@
117124 'bottom' : '0px',
118125 'right' : '45px',
119126 'overflow' : 'hidden'
120 - } )
 127+ } );
121128 for ( var menuItem in ctrlObj.supportedMenuItems ) {
122129 $menuScreens.append(
123130 $j( '<div />' )
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -117,13 +117,7 @@
118118 'right' : '0px'
119119 } );
120120 // Check for overlay controls:
121 - if( _this.checkOverlayControls() ) {
122 - $controlBar.hide();
123 - // Make sure the interface is correct height:
124 - embedPlayer.$interface.css( {
125 - 'height' : parseInt( embedPlayer.height )
126 - } );
127 - } else {
 121+ if( ! _this.checkOverlayControls() ) {
128122 // Add some space to interface for the control bar ( if not overlaying controls )
129123 embedPlayer.$interface.css( {
130124 'height' : parseInt( embedPlayer.height ) + parseInt( this.height ) +2
@@ -495,10 +489,11 @@
496490 'width' : embedPlayer.getWidth(),
497491 'height' : embedPlayer.getHeight()
498492 });
 493+
499494 // Restore the play button
500495 $interface.find('.play-btn-large').animate( {
501 - 'left' : ( ( embedPlayer.getPlayerWidth() - this.getComponentWidth( 'playButtonLarge' ) ) / 2 ),
502 - 'top' : ( ( embedPlayer.getPlayerHeight() -this.getComponentHeight( 'playButtonLarge' ) ) / 2 )
 496+ 'left' : ( ( embedPlayer.getWidth() - this.getComponentWidth( 'playButtonLarge' ) ) / 2 ),
 497+ 'top' : ( ( embedPlayer.getHeight() -this.getComponentHeight( 'playButtonLarge' ) ) / 2 )
503498 } );
504499
505500 },
@@ -638,6 +633,7 @@
639634 * set to true for the player or via config
640635 */
641636 checkOverlayControls: function(){
 637+
642638 //if the player "supports" overlays:
643639 if( ! this.embedPlayer.supports['overlays'] ){
644640 return false;
@@ -653,8 +649,9 @@
654650 return false;
655651 }
656652
657 - // don't hide controls when content "height" is 0 ( audio tags )
658 - if( this.embedPlayer.getPlayerHeight() == 0 ){
 653+ // Don't hide controls when content "height" is 0px ( audio tags )
 654+ if( this.embedPlayer.getPlayerHeight() === 0 &&
 655+ $j(this.embedPlayer).css('height').indexOf('%') == -1 ){
659656 return false;
660657 }
661658 if( this.embedPlayer.controls === false ){
@@ -718,8 +715,10 @@
719716 mw.log( 'controlBuilder: doWarningBindinng: ' + preferenceId + ' wm: ' + warningMsg);
720717 // Set up local pointer to the embedPlayer
721718 var embedPlayer = this.embedPlayer;
722 - var _this = this;
 719+ var _this = this;
723720
 721+ // make sure the
 722+
724723 $j( embedPlayer ).hoverIntent({
725724 'timeout': 2000,
726725 'over': function() {
@@ -761,30 +760,28 @@
762761 'type' : "checkbox",
763762 'name' : 'ffwarn_' + embedPlayer.id
764763 })
765 - .click( function() {
766 - if ( $j( this ).is( ':checked' ) ) {
767 - // Set up a cookie for 7 days:
768 - $j.cookie( preferenceId, false, { expires: 7 } );
769 - // Set the current instance
770 - mw.setConfig( preferenceId, false );
771 - $j( '#warningOverlay_' + embedPlayer.id ).fadeOut( 'slow' );
772 - // set the local prefrence to false
773 - _this.addWarningFlag = false;
774 - } else {
775 - mw.setConfig( preferenceId, true );
776 - $j.cookie( preferenceId, true );
777 - }
 764+ .click( function() {
 765+ mw.log("WarningBindinng:: set " + preferenceId + ' to hidewarning ' );
 766+ // Set up a cookie for 30 days:
 767+ $j.cookie( preferenceId, 'hidewarning', { expires: 30 } );
 768+ // Set the current instance
 769+ mw.setConfig( preferenceId, false );
 770+ $j( '#warningOverlay_' + embedPlayer.id ).fadeOut( 'slow' );
 771+ // set the local prefrence to false
 772+ _this.addWarningFlag = false;
778773 } )
779774 );
780775 $targetWarning.append(
781 - $j('<span />')
 776+ $j('<label />')
782777 .text( gM( 'mwe-embedplayer-do_not_warn_again' ) )
 778+ .attr( 'for', 'ffwarn_' + embedPlayer.id )
783779 );
784780 }
785781 // Check the global config before showing the warning
786 - if ( mw.getConfig( preferenceId ) === true ){
 782+ if ( mw.getConfig( preferenceId ) === true && $j.cookie( preferenceId ) != 'hidewarning' ){
 783+ mw.log("WarningBindinng:: show warning " + mw.getConfig( preferenceId ) + ' cookie: '+ $j.cookie( preferenceId ) + 'typeof:' + typeof $j.cookie( preferenceId ));
787784 $j( '#warningOverlay_' + embedPlayer.id ).fadeIn( 'slow' );
788 - }
 785+ };
789786 },
790787 'out': function() {
791788 $j( '#warningOverlay_' + embedPlayer.id ).fadeOut( 'slow' );
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -25,12 +25,39 @@
2626 // NOTE the bug where onSeeked does not seem fire consistently may no longer be applicable
2727 prevCurrentTime: -1,
2828
29 - // Store the progress event ( updated durring monitor )
 29+ // Store the progress event ( updated during monitor )
3030 progressEventData: null,
3131
3232 // If the media loaded event has been fired
3333 mediaLoadedFlag: null,
3434
 35+ // All the native events per:
 36+ // http://www.w3.org/TR/html5/video.html#mediaevents
 37+ nativeEvents : [
 38+ 'loadstart',
 39+ 'progress',
 40+ 'suspend',
 41+ 'abort',
 42+ 'error',
 43+ 'emptied',
 44+ 'stalled',
 45+ 'play',
 46+ 'pause',
 47+ 'loadedmetadata',
 48+ 'loadeddata',
 49+ 'waiting',
 50+ 'playing',
 51+ 'canplay',
 52+ 'canplaythough',
 53+ 'seeking',
 54+ 'seeked',
 55+ 'timeupdate',
 56+ 'ended',
 57+ 'ratechange',
 58+ 'durationchange',
 59+ 'volumechange'
 60+ ],
 61+
3562 // Native player supported feature set
3663 supports: {
3764 'playHead' : true,
@@ -39,10 +66,8 @@
4067 'timeDisplay' : true,
4168 'volumeControl' : true,
4269 'overlays' : true
43 - },
 70+ },
4471
45 - insertAndPlayingConfig : false,
46 -
4772 /**
4873 * updates the supported features given the "type of player"
4974 */
@@ -130,37 +155,22 @@
131156 mw.log( "f:native:postEmbedJS:" );
132157
133158 // Setup local pointer:
134 - var vid = this.getPlayerElement();
135 - if ( typeof this.playerElement != 'undefined' ) {
136 - // Apply media element bindings:
137 - this.applyMediaElementBindings();
138 -
139 - // Check for load flag
140 - if ( this.onlyLoadFlag ) {
141 - vid.pause();
142 - vid.load();
143 - } else {
144 - // Issue play request
145 - vid.play();
146 - }
147 -
148 - setTimeout( function() {
149 - _this.monitor();
150 - }, 100 );
151 -
152 - } else {
153 - // False inserts don't seem to be as much of a problem as before:
154 - mw.log( 'Could not grab vid obj trying again:' + typeof this.playerElement );
155 - this.grab_try_count++;
156 - if ( this.grab_count == 20 ) {
157 - mw.log( 'Could not get vid object after 20 tries re-run: getEmbedObj() ?' ) ;
158 - } else {
159 - setTimeout( function() {
160 - _this.postEmbedJS();
161 - }, 150 );
162 - }
163 -
164 - }
 159+ var vid = this.getPlayerElement();
 160+ // Apply media element bindings:
 161+ this.applyMediaElementBindings();
 162+
 163+ // Check for load flag
 164+ if ( this.onlyLoadFlag ) {
 165+ vid.pause();
 166+ vid.load();
 167+ } else {
 168+ // Issue play request
 169+ vid.play();
 170+ }
 171+
 172+ setTimeout( function() {
 173+ _this.monitor();
 174+ }, 100 );
165175 },
166176
167177 /**
@@ -173,6 +183,7 @@
174184 mw.log( " Error: applyMediaElementBindings without player elemnet");
175185 return ;
176186 }
 187+
177188 // Bind events to local js methods:
178189 vid.addEventListener( 'canplaythrough', function() { $j( _this ).trigger('canplaythrough'); }, true);
179190 vid.addEventListener( 'loadedmetadata', function() { _this.onloadedmetadata() }, true);
@@ -321,7 +332,7 @@
322333 this.getPlayerElement();
323334
324335 if ( !this.playerElement ) {
325 - mw.log( 'Error: mwEmbedPlayer::getPlayerElementTime: missing ' + this.id + ' stop monitor' );
 336+ mw.log( 'mwEmbedPlayer::getPlayerElementTime: ' + this.id + ' not in dom ( stop monitor)' );
326337 return false;
327338 }
328339 // Return the playerElement currentTime
@@ -432,6 +443,7 @@
433444 onVolumeChange: function(){
434445 //mw.log( "native::volumechange::trigger" );
435446 //this.volume = this.playerElement.volume;
 447+ $j( this ).trigger( 'volumechange' );
436448 },
437449
438450 /**
@@ -504,10 +516,14 @@
505517 */
506518 onSeeked: function() {
507519 mw.log("native:onSeeked");
508 - this.seeking = false;
 520+
509521 mw.log("native:onSeeked:trigger");
510522 // Trigger the html5 action on the parent
511 - $j( this ).trigger( 'seeked' );
 523+ if( this.seeking && this.useNativePlayerControls() ){
 524+ this.seeking = false;
 525+ $j( this ).trigger( 'seeked' );
 526+ }
 527+ this.seeking = false;
512528 },
513529
514530 /**
@@ -522,8 +538,8 @@
523539 * Handle the native play event
524540 */
525541 onPlay: function(){
526 - mw.log("EmbedPlayer:native:: OnPlay");
527 - // Update the interface
 542+ mw.log("EmbedPlayer:native:: OnPlay");
 543+ // Update the interface ( if paused )
528544 this.parent_play();
529545 },
530546
@@ -574,8 +590,7 @@
575591 */
576592 onended: function() {
577593 var _this = this;
578 - mw.log( 'EmbedPlayer:native: onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() +
579 - ' insertAndPlayingConfig: ' + this.insertAndPlayingConfig);
 594+ mw.log( 'EmbedPlayer:native: onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() );
580595
581596 this.onClipDone();
582597 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r75534Follup up to r75504. getShareEmbedObject was renamed to getShareIframeObjecthartman12:24, 27 October 2010
r75565* fixed audio player size regression with r75504 ...dale19:00, 27 October 2010
r75574mwRemoteEmbed: <? -> <?php...hartman20:06, 27 October 2010

Comments

#Comment by TheDJ (talk | contribs)   12:19, 27 October 2010

After these changes, audio players now get a 100% window size dummy poster.

#Comment by TheDJ (talk | contribs)   12:35, 27 October 2010

mwEmbedFrame.php is broken.

PHP Parse error: syntax error, unexpected '}' in /Users/hartman/Development/MwEmbedStandAlone/mwEmbedFrame.php on line 165

#Comment by TheDJ (talk | contribs)   20:15, 27 October 2010

Was fixed with r75565

#Comment by Mdale (talk | contribs)   19:50, 27 October 2010

these issues should be fixed in r75565

Status & tagging log