Index: branches/js2-work/phase3/js/mwEmbed/mwEmbedFrame.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | if( $this->apiTitleKey || count( $this->sources ) != 0 ) { |
160 | 160 | echo $this->getVideoTag(); |
161 | 161 | } else { |
162 | | - echo "Error: mwEmbedFrame missing required parameter"; |
| 162 | + echo "Error: mwEmbedFrame missing required parameter ( src or apiTitleKey )"; |
163 | 163 | } |
164 | 164 | ?> |
165 | 165 | </body> |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | <title> Sample Themed Player </title> |
7 | 7 | Pre-loading demo ( stuff ) likely needed for video display |
8 | 8 | <!-- |
9 | | - <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script> |
| 9 | + <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,mw.style.jquerymenu,$j.cookie,$j.ui.slider,mw.TimedText"></script> |
10 | 10 | <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=mwEmbed"></script> |
11 | 11 | <link rel="stylesheet" href="../skins/styles.css" type="text/css" media="screen" /> |
12 | 12 | <link rel="stylesheet" href="../skins/mvpcf/EmbedPlayer.css" type="text/css" media="screen" /> |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadForm.js |
— | — | @@ -382,7 +382,7 @@ |
383 | 383 | $j( uploadMenuTarget ).empty().loadingSpinner(); |
384 | 384 | |
385 | 385 | // if selectUploadProviderCb is set run the callback |
386 | | - if( selectUploadProviderCb ){ |
| 386 | + if( selectUploadProviderCb ) { |
387 | 387 | selectUploadProviderCb( uploadProvider ) |
388 | 388 | } |
389 | 389 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | /** |
157 | 157 | * Issues a seek to the playerElement |
158 | 158 | */ |
159 | | - doSeek:function( prec ) { |
| 159 | + doSeek: function( prec ) { |
160 | 160 | var _this = this; |
161 | 161 | if( this.playerElement ) { |
162 | 162 | var seek_time = prec * this.getDuration(); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js |
— | — | @@ -103,8 +103,39 @@ |
104 | 104 | */ |
105 | 105 | mw.addDOMReadyHook( function() { |
106 | 106 | if( mw.documentHasPlayerTags() ) { |
| 107 | + var rewriteElementCount = 0; |
| 108 | + |
107 | 109 | // Add the setup hook since we have player tags |
108 | | - mw.addSetupHook( function( callback ) { |
| 110 | + mw.addSetupHook( function( callback ) { |
| 111 | + |
| 112 | + // Set each player to loading ( as early on as possible ) |
| 113 | + $j( mw.getConfig( 'rewritePlayerTags' ) ).each( function( index, element ){ |
| 114 | + |
| 115 | + // Assign an the element an ID (if its missing one) |
| 116 | + if ( $j( element ).attr( "id" ) == '' ) { |
| 117 | + $j( element ).attr( "id", 'v' + ( rewriteElementCount++ ) ); |
| 118 | + } |
| 119 | + |
| 120 | + // Hide the video tag and add a loader: |
| 121 | + var pos = $j( element ).offset(); |
| 122 | + $j( element ).css({ |
| 123 | + 'opacity' : 0, |
| 124 | + 'position': 'absolute' |
| 125 | + } ) |
| 126 | + |
| 127 | + $j('body').append( |
| 128 | + $j('<div />') |
| 129 | + .loadingSpinner() |
| 130 | + .attr('id', 'loadSpiner_' + $j( element ).attr('id') ) |
| 131 | + .css({ |
| 132 | + 'width' : 32, |
| 133 | + 'height' : 32, |
| 134 | + 'position': 'absolute', |
| 135 | + 'top' : pos.top + 30, |
| 136 | + 'left' : pos.left + 30, |
| 137 | + }) |
| 138 | + ) |
| 139 | + }); |
109 | 140 | // Load the embedPlayer module ( then run queued hooks ) |
110 | 141 | mw.load( 'EmbedPlayer', function ( ) { |
111 | 142 | // Rewrite the rewritePlayerTags with the |
— | — | @@ -139,7 +170,8 @@ |
140 | 171 | 'JSON' |
141 | 172 | ], |
142 | 173 | [ |
143 | | - '$j.fn.menu', |
| 174 | + '$j.fn.menu', |
| 175 | + 'mw.style.jquerymenu', |
144 | 176 | '$j.ui.slider' |
145 | 177 | ] |
146 | 178 | ]; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -333,18 +333,14 @@ |
334 | 334 | */ |
335 | 335 | addElement: function( element, attributes ) { |
336 | 336 | var _this = this; |
337 | | - |
338 | | - // Assign id if unset |
339 | | - var element_id = $j( element ).attr( "id" ); |
340 | | - if ( element_id == '' ) { |
341 | | - element_id = 'v' + this.playerList.length; |
342 | | - $j( element ).attr( "id", element_id); |
343 | | - } |
344 | | - |
| 337 | + |
| 338 | + if ( !element.id || element.id == '' ) { |
| 339 | + mw.log("Error: element is missing id "); |
| 340 | + } |
345 | 341 | mw.log('EmbedPlayerManager: addElement:: ' + element.id ); |
346 | 342 | |
347 | 343 | // Add the element id to playerList |
348 | | - this.playerList.push( element_id ); |
| 344 | + this.playerList.push( element.id ); |
349 | 345 | |
350 | 346 | // Check for class based player skin |
351 | 347 | var skinClassRequest = [ ]; |
— | — | @@ -372,8 +368,8 @@ |
373 | 369 | var playlistPlayer = new mw.PlayList( element, attributes ); |
374 | 370 | |
375 | 371 | // Swap in playlist player interface |
376 | | - _this.swapEmbedPlayerElement( element, playlistPlayer ); |
377 | | - |
| 372 | + _this.swapEmbedPlayerElement( element, playlistPlayer ); |
| 373 | + |
378 | 374 | // Issue the checkPlayerSources call to the new playlist interface: |
379 | 375 | $j( '#' + playlistPlayer.id ).get(0).showPlayer(); |
380 | 376 | } ); |
— | — | @@ -381,26 +377,27 @@ |
382 | 378 | case 'video': |
383 | 379 | case 'audio': |
384 | 380 | // By default treat the rewrite request as "video" |
385 | | - default: |
386 | | - var ranPlayerSwapFlag = false; |
387 | | - |
| 381 | + default: |
| 382 | + var ranPlayerSwapFlag = false; |
388 | 383 | // Local callback to runPlayer swap once element has metadata |
389 | | - function runPlayerSwap() { |
390 | | - if( ranPlayerSwapFlag ) |
| 384 | + function runPlayerSwap() { |
| 385 | + if( ranPlayerSwapFlag ){ |
391 | 386 | return ; |
| 387 | + } |
392 | 388 | mw.log("runPlayerSwap::" + $j( element ).attr('id') ); |
393 | 389 | ranPlayerSwapFlag = true; |
394 | 390 | var playerInterface = new mw.EmbedPlayer( element , attributes); |
395 | | - _this.swapEmbedPlayerElement( element, playerInterface ); |
| 391 | + _this.swapEmbedPlayerElement( element, playerInterface ); |
396 | 392 | // Issue the checkPlayerSources call to the new player interface: |
397 | | - // make sure to use the element that is in the DOM: |
398 | | - $j( '#' + $j( element ).attr('id') ).get(0).checkPlayerSources(); |
| 393 | + // make sure to use the element that is in the DOM: |
| 394 | + $j( '#' + playerInterface.id ).get(0).checkPlayerSources(); |
399 | 395 | } |
400 | 396 | |
401 | 397 | if( waitForMeta ) { |
402 | 398 | mw.log(' WaitForMeta ( video missing height (' + $j( element ).attr('height') + '), width (' + $j( element ).attr('width') + ') or duration' ); |
403 | 399 | element.removeEventListener( "loadedmetadata", runPlayerSwap, true ); |
404 | 400 | element.addEventListener( "loadedmetadata", runPlayerSwap, true ); |
| 401 | + |
405 | 402 | // Time-out of 5 seconds ( maybe still playable but no timely metadata ) |
406 | 403 | setTimeout( runPlayerSwap, 5000 ); |
407 | 404 | }else{ |
— | — | @@ -497,8 +494,15 @@ |
498 | 495 | $j( swapPlayerElement ).css( { |
499 | 496 | 'width' : playerInterface.width + 'px', |
500 | 497 | 'height' : playerInterface.height + 'px' |
501 | | - } ).loadingSpinner(); |
502 | | - |
| 498 | + } ) |
| 499 | + //if we don't already have a loadSpiner add one: |
| 500 | + if( ! $j('#loadSpiner_' + playerInterface.id ).length ){ |
| 501 | + $j( swapPlayerElement ).append( |
| 502 | + $j('<div style="margin:auto;top:35%;position:relative;width:32px;height:32px;"/>') |
| 503 | + .loadingSpinner() |
| 504 | + .addClass( "loadingSpinner" ) |
| 505 | + ); |
| 506 | + } |
503 | 507 | return true; |
504 | 508 | }, |
505 | 509 | |
— | — | @@ -516,6 +520,9 @@ |
517 | 521 | mw.log( 'ReadyToPlay callback player:' + player.id ); |
518 | 522 | player.readyToPlay = true; |
519 | 523 | |
| 524 | + // Remove the player loader spiner: |
| 525 | + $j('#loadSpiner_' + player.id ).remove(); |
| 526 | + |
520 | 527 | var is_ready = true; |
521 | 528 | for ( var i = 0; i < this.playerList.length; i++ ) { |
522 | 529 | var currentPlayer = $j( '#' + this.playerList[i] ).get( 0 ); |
— | — | @@ -1256,11 +1263,7 @@ |
1257 | 1264 | } |
1258 | 1265 | if ( $j( element ).attr( 'poster' ) ) { |
1259 | 1266 | _this.poster = $j( element ).attr( 'poster' ); |
1260 | | - } |
1261 | | - // Set by default thumb value if not found |
1262 | | - if( ! _this.poster ) { |
1263 | | - _this.poster = mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg' ; |
1264 | | - } |
| 1267 | + } |
1265 | 1268 | |
1266 | 1269 | // Set the skin name from the class |
1267 | 1270 | var sn = $j(element).attr( 'class' ); |
— | — | @@ -1329,9 +1332,15 @@ |
1330 | 1333 | } |
1331 | 1334 | } ); |
1332 | 1335 | }, |
1333 | | - |
1334 | 1336 | |
1335 | 1337 | /** |
| 1338 | + * for plugin-players to update supported features |
| 1339 | + */ |
| 1340 | + updateFeatureSupport: function(){ |
| 1341 | + return ; |
| 1342 | + }, |
| 1343 | + |
| 1344 | + /** |
1336 | 1345 | * Set the width & height from css style attribute, element attribute, or by default value |
1337 | 1346 | * if no css or attribute is provided set a callback to resize. |
1338 | 1347 | * |
— | — | @@ -1644,8 +1653,8 @@ |
1645 | 1654 | |
1646 | 1655 | // Load the selected player |
1647 | 1656 | this.selected_player.load( function() { |
1648 | | - // Get the selected player Interface |
1649 | | - var playerInterface = window[ _this.selected_player.library + 'Embed' ]; |
| 1657 | + // Get embed library player Interface |
| 1658 | + var playerInterface = window[ _this.selected_player.library + 'Embed' ]; |
1650 | 1659 | |
1651 | 1660 | for ( var method in playerInterface ) { |
1652 | 1661 | if ( _this[method] && !_this['parent_' + method] ) { |
— | — | @@ -1653,6 +1662,9 @@ |
1654 | 1663 | } |
1655 | 1664 | _this[ method ] = playerInterface[method]; |
1656 | 1665 | } |
| 1666 | + // Run any constructor code: |
| 1667 | + _this.updateFeatureSupport(); |
| 1668 | + |
1657 | 1669 | _this.getDuration(); |
1658 | 1670 | _this.showPlayer(); |
1659 | 1671 | // Call the global player mannager to inform this video interface is 100% ready: |
— | — | @@ -1730,14 +1742,14 @@ |
1731 | 1743 | /** |
1732 | 1744 | * Get the plugin embed html ( should be implemented by embed player interface ) |
1733 | 1745 | */ |
1734 | | - doEmbedHTML : function() { |
| 1746 | + doEmbedHTML: function() { |
1735 | 1747 | return 'Error: function doEmbedHTML should be implemented by embed player interface '; |
1736 | 1748 | }, |
1737 | 1749 | |
1738 | 1750 | /** |
1739 | 1751 | * Seek function (should be implemented by embed player interface ) |
1740 | 1752 | */ |
1741 | | - doSeek : function( percent ) { |
| 1753 | + doSeek: function( percent ) { |
1742 | 1754 | var _this = this; |
1743 | 1755 | if ( this.supportsURLTimeEncoding() ) { |
1744 | 1756 | // Make sure this.seek_time_sec is up-to-date: |
— | — | @@ -1854,8 +1866,7 @@ |
1855 | 1867 | * Show the player |
1856 | 1868 | */ |
1857 | 1869 | showPlayer : function () { |
1858 | | - mw.log( 'Show player: ' + this.id ); |
1859 | | - |
| 1870 | + mw.log( 'Show player: ' + this.id ); |
1860 | 1871 | // Set-up the local ctrlBuilder instance: |
1861 | 1872 | this.ctrlBuilder = new ctrlBuilder( this ); |
1862 | 1873 | |
— | — | @@ -2094,9 +2105,21 @@ |
2095 | 2106 | var thumb_html = ''; |
2096 | 2107 | var class_atr = ''; |
2097 | 2108 | var style_atr = ''; |
2098 | | - |
| 2109 | + |
| 2110 | + // Set by default thumb value if not found |
| 2111 | + var posterSrc = ( this.poster ) ? this.poster : |
| 2112 | + mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg'; |
| 2113 | + |
| 2114 | + // Remove any old thumbnail items: |
| 2115 | + $j( this ).find( '.playerPoster,.loadingSpinner,.play-btn-large' ).remove(); |
| 2116 | + |
| 2117 | + var dummyvid = document.createElement( "video" ); |
2099 | 2118 | // put it all in the div container dc_id |
2100 | | - $j( this ).html( |
| 2119 | + |
| 2120 | + // Poster support is not very consistant in browsers |
| 2121 | + // use a jpg poster image: |
| 2122 | + // use a jpg thumbnail: |
| 2123 | + $j( this ).append( |
2101 | 2124 | $j( '<img />' ) |
2102 | 2125 | .css({ |
2103 | 2126 | 'position' : 'relative', |
— | — | @@ -2105,9 +2128,10 @@ |
2106 | 2129 | }) |
2107 | 2130 | .attr({ |
2108 | 2131 | 'id' : 'img_thumb_' + this.id, |
2109 | | - 'src' : this.poster |
| 2132 | + 'src' : posterSrc |
2110 | 2133 | }) |
2111 | | - ); |
| 2134 | + .addClass( 'playerPoster' ) |
| 2135 | + ); |
2112 | 2136 | |
2113 | 2137 | if ( this.controls |
2114 | 2138 | && this.height > this.ctrlBuilder.getComponentHeight( 'playButtonLarge' ) |
— | — | @@ -2148,11 +2172,16 @@ |
2149 | 2173 | } |
2150 | 2174 | } else { |
2151 | 2175 | // Output all the video sources: |
2152 | | - for( var i=0; i < this.mediaElement.length; i++ ){ |
| 2176 | + for( var i=0; i < this.mediaElement.sources.length; i++ ){ |
| 2177 | + var source = this.mediaElement.sources[i]; |
2153 | 2178 | if( source.src ) { |
2154 | | - iframeUrl +='src[]=' + escape( mw.absoluteUrl( source.src ) ) + '&'; |
| 2179 | + iframeUrl += 'src[]=' + escape( mw.absoluteUrl( source.src ) ) + '&'; |
2155 | 2180 | } |
2156 | | - } |
| 2181 | + } |
| 2182 | + // Output the poster attr |
| 2183 | + if( this.poster ){ |
| 2184 | + iframeUrl += 'poster=' + escape( this.poster ) + '&'; |
| 2185 | + } |
2157 | 2186 | } |
2158 | 2187 | |
2159 | 2188 | // Set the skin if set to something other than default |
— | — | @@ -2247,7 +2276,8 @@ |
2248 | 2277 | embedCode += '>'; |
2249 | 2278 | |
2250 | 2279 | // Output all the video sources: |
2251 | | - for( var i=0; i < this.mediaElement.length; i++ ){ |
| 2280 | + for( var i=0; i < this.mediaElement.sources.length; i++ ){ |
| 2281 | + var source = this.mediaElement.sources[i]; |
2252 | 2282 | if( source.src ) { |
2253 | 2283 | embedCode +='<source src="' + |
2254 | 2284 | mw.absoluteUrl( source.src ) + |
— | — | @@ -2831,7 +2861,7 @@ |
2832 | 2862 | preference : { }, |
2833 | 2863 | |
2834 | 2864 | // Stores the default set of players for a given mime type |
2835 | | - default_players : { }, |
| 2865 | + default_players : { }, |
2836 | 2866 | |
2837 | 2867 | /** |
2838 | 2868 | * Initializartion function sets the default order for players for |
— | — | @@ -2875,6 +2905,18 @@ |
2876 | 2906 | }, |
2877 | 2907 | |
2878 | 2908 | /** |
| 2909 | + * Checks if a player is supported by id |
| 2910 | + */ |
| 2911 | + isSupportedPlayer: function( player_id ){ |
| 2912 | + for( var i=0; i < this.players.length; i++ ){ |
| 2913 | + if( this.players[i].id == player_id ){ |
| 2914 | + return true; |
| 2915 | + } |
| 2916 | + } |
| 2917 | + return false; |
| 2918 | + }, |
| 2919 | + |
| 2920 | + /** |
2879 | 2921 | * get players that support a given mimeType |
2880 | 2922 | * |
2881 | 2923 | * @param {String} mimeType Mime type of player set |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/skins/ctrlBuilder.js |
— | — | @@ -380,7 +380,7 @@ |
381 | 381 | _this.showControlBar(); |
382 | 382 | // Once we move the mouse keep displayed for 4 seconds |
383 | 383 | setTimeout(checkMovedMouse, 4000); |
384 | | - }else{ |
| 384 | + } else { |
385 | 385 | // Check for mouse movement every 250ms |
386 | 386 | _this.hideControlBar(); |
387 | 387 | setTimeout(checkMovedMouse, 250 ); |
— | — | @@ -508,15 +508,25 @@ |
509 | 509 | // Set up local pointer to the embedPlayer |
510 | 510 | var embedPlayer = this.embedPlayer; |
511 | 511 | var _this = this; |
| 512 | + var $interface = embedPlayer.$interface; |
512 | 513 | |
513 | 514 | // Setup target shortcut to control-bar |
514 | | - $target = embedPlayer.$interface; |
| 515 | + $target = embedPlayer.$interface; |
515 | 516 | var mouseIn = false; |
516 | 517 | // Add hide show bindings for control overlay (if overlay is enabled ) |
517 | | - if( _this.checkOverlayControls() ) { |
| 518 | + if( ! _this.checkOverlayControls() ) { |
| 519 | + $interface.unbind().show(); |
| 520 | + } else { // hide show controls: |
| 521 | + //$interface.css({'background-color': 'red'}); |
| 522 | + // Bind a startTouch to show controls |
| 523 | + $interface.bind( 'touchstart', function() { |
| 524 | + _this.showControlBar(); |
| 525 | + // ( once the user touched the video "don't hide" ) |
| 526 | + } ); |
518 | 527 | // Add a special absolute overlay for hover ( to keep menu displayed |
519 | | - $j( embedPlayer.$interface ).hover( |
| 528 | + $interface.hover( |
520 | 529 | function(){ |
| 530 | + mw.log("CALL HOVER"); |
521 | 531 | // Show controls with a set timeout ( avoid fade in fade out on short mouse over ) |
522 | 532 | setTimeout( function() { |
523 | 533 | if( mouseIn ){ |
— | — | @@ -529,7 +539,7 @@ |
530 | 540 | mouseIn = false; |
531 | 541 | // Hide controls ( delay hide if menu is visible ) |
532 | 542 | function hideCheck(){ |
533 | | - if ( embedPlayer.$interface.find( '.overlay-win' ).length != 0 |
| 543 | + if ( $interface.find( '.overlay-win' ).length != 0 |
534 | 544 | || $j('.menuPositionHelper').is(':visible' ) ) { |
535 | 545 | setTimeout( hideCheck, 250 ); |
536 | 546 | return ; |
— | — | @@ -543,8 +553,6 @@ |
544 | 554 | setTimeout( hideCheck, 1000 ); |
545 | 555 | } |
546 | 556 | ); |
547 | | - } else { |
548 | | - $j( embedPlayer.$interface ).unbind().show(); |
549 | 557 | } |
550 | 558 | |
551 | 559 | // Add recommend firefox if we have non-native playback: |
— | — | @@ -585,7 +593,8 @@ |
586 | 594 | * Show the control bar |
587 | 595 | */ |
588 | 596 | showControlBar : function(){ |
589 | | - var animateDuration = 'slow'; |
| 597 | + var animateDuration = 'slow'; |
| 598 | + $j( this.embedPlayer.getPlayerElement() ).css('z-index', '1') |
590 | 599 | // Move up itext if present |
591 | 600 | this.embedPlayer.$interface.find( '.itext' ) |
592 | 601 | .animate( |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/skins/mvpcf/EmbedPlayer.css |
— | — | @@ -5,7 +5,6 @@ |
6 | 6 | /*Video player*/ |
7 | 7 | .mv-player { |
8 | 8 | color: #FFF; |
9 | | - background: #000; |
10 | 9 | } |
11 | 10 | |
12 | 11 | /* large play button: */ |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js |
— | — | @@ -37,6 +37,18 @@ |
38 | 38 | // if the object supports playlist functions |
39 | 39 | 'playlist_swap_loader' : true |
40 | 40 | }, |
| 41 | + /** |
| 42 | + * updates the supported features given the "type of player" |
| 43 | + */ |
| 44 | + updateFeatureSupport: function(){ |
| 45 | + // iWhatever devices appear to have a broken |
| 46 | + // dom overlay implementation of video atm. (hopefully iphone OS 4 fixes this ) |
| 47 | + if ((navigator.userAgent.indexOf('iPhone') != -1) || |
| 48 | + (navigator.userAgent.indexOf('iPod') != -1) || |
| 49 | + (navigator.userAgent.indexOf('iPad') != -1)) { |
| 50 | + this.supports.overlays = false; |
| 51 | + } |
| 52 | + }, |
41 | 53 | |
42 | 54 | /** |
43 | 55 | * Return the embed code |
— | — | @@ -57,11 +69,9 @@ |
58 | 70 | 'height' : '100%' |
59 | 71 | } ) |
60 | 72 | ) |
61 | | - mw.log( "Embed code: " + $j( this ).html() ) |
62 | | - |
63 | | - setTimeout( function() { |
64 | | - _this.postEmbedJS(); |
65 | | - }, 150 ); |
| 73 | + mw.log( "Embed code: " + $j( this ).html() ); |
| 74 | + // directly run postEmbedJS ( if playerElement is not avaliable it will retry ) |
| 75 | + _this.postEmbedJS(); |
66 | 76 | }, |
67 | 77 | |
68 | 78 | /** |
— | — | @@ -70,14 +80,13 @@ |
71 | 81 | postEmbedJS: function() { |
72 | 82 | var _this = this; |
73 | 83 | mw.log( "f:native:postEmbedJS:" ); |
74 | | - this.getPlayerElement(); |
75 | | - if ( typeof this.playerElement != 'undefined' ) { |
76 | | - |
77 | | - // Setup some bindings: |
78 | | - var vid = $j( this.playerElement ).get(0); |
79 | | - |
| 84 | + |
| 85 | + // Setup local pointer: |
| 86 | + var vid = this.getPlayerElement(); |
| 87 | + if ( typeof this.playerElement != 'undefined' ) { |
| 88 | + // Setup some bindings: |
80 | 89 | // Bind events to local js methods: |
81 | | - vid.addEventListener( 'canplaythrough', function() { _this.canplaythrough }, true); |
| 90 | + vid.addEventListener( 'canplaythrogh', function() { _this.canplaythrough }, true); |
82 | 91 | vid.addEventListener( 'loadedmetadata', function() { _this.onloadedmetadata() }, true); |
83 | 92 | vid.addEventListener( 'progress', function( e ) { _this.onprogress( e ) }, true); |
84 | 93 | vid.addEventListener( 'ended', function() { _this.onended() }, true); |
— | — | @@ -86,11 +95,16 @@ |
87 | 96 | |
88 | 97 | // Check for load flag |
89 | 98 | if ( this.onlyLoadFlag ) { |
90 | | - this.playerElement.load(); |
| 99 | + vid.pause(); |
| 100 | + vid.load(); |
91 | 101 | } else { |
92 | 102 | // Issue play request |
93 | | - this.playerElement.play(); |
| 103 | + vid.play(); |
94 | 104 | } |
| 105 | + |
| 106 | + // Run the "hook" for any extensions that need to bind things to the actual video elemnt |
| 107 | + this.runHook( 'postEmbedJS' ) |
| 108 | + |
95 | 109 | setTimeout( function() { |
96 | 110 | _this.monitor(); |
97 | 111 | }, 100 ); |
— | — | @@ -99,16 +113,16 @@ |
100 | 114 | // False inserts don't seem to be as much of a problem as before: |
101 | 115 | mw.log( 'Could not grab vid obj trying again:' + typeof this.playerElement ); |
102 | 116 | this.grab_try_count++; |
103 | | - if ( this.grab_count == 20 ) { |
| 117 | + if ( this.grab_count == 20 ) { |
104 | 118 | mw.log( 'Could not get vid object after 20 tries re-run: getEmbedObj() ?' ) ; |
105 | 119 | } else { |
106 | 120 | setTimeout( function() { |
107 | 121 | _this.postEmbedJS(); |
108 | | - }, 200 ); |
| 122 | + }, 150 ); |
109 | 123 | } |
110 | 124 | |
111 | 125 | } |
112 | | - }, |
| 126 | + }, |
113 | 127 | |
114 | 128 | /** |
115 | 129 | * Issue a seeking request. |
— | — | @@ -219,6 +233,7 @@ |
220 | 234 | */ |
221 | 235 | monitor: function() { |
222 | 236 | this.getPlayerElement(); // make sure we have .vid obj |
| 237 | + |
223 | 238 | if ( !this.playerElement ) { |
224 | 239 | mw.log( 'could not find video embed: ' + this.id + ' stop monitor' ); |
225 | 240 | return false; |
— | — | @@ -226,7 +241,8 @@ |
227 | 242 | |
228 | 243 | // update currentTime |
229 | 244 | this.currentTime = this.playerElement.currentTime; |
230 | | - |
| 245 | + |
| 246 | + //mw.log( 'ns: ' + this.playerElement.networkState + ' error:' + this.playerElement.error); |
231 | 247 | //mw.log('currentTime:' + this.currentTime); |
232 | 248 | // once currentTime is updated call parent_monitor |
233 | 249 | this.parent_monitor(); |
— | — | @@ -294,8 +310,9 @@ |
295 | 311 | */ |
296 | 312 | updateVolumen: function( percentage ) { |
297 | 313 | this.getPlayerElement(); |
298 | | - if ( this.playerElement ) |
| 314 | + if ( this.playerElement ) { |
299 | 315 | this.playerElement.volume = percentage; |
| 316 | + } |
300 | 317 | }, |
301 | 318 | |
302 | 319 | /** |
— | — | @@ -342,7 +359,7 @@ |
343 | 360 | /** |
344 | 361 | * Get /update the playerElement value |
345 | 362 | */ |
346 | | - getPlayerElement : function () { |
| 363 | + getPlayerElement: function () { |
347 | 364 | this.playerElement = $j( '#' + this.pid ).get( 0 ); |
348 | 365 | return this.playerElement; |
349 | 366 | }, |
— | — | @@ -377,8 +394,9 @@ |
378 | 395 | oncanplaythrough: function() { |
379 | 396 | mw.log('f:oncanplaythrough'); |
380 | 397 | this.getPlayerElement(); |
381 | | - if ( ! this.paused ) |
382 | | - this.playerElement.play(); |
| 398 | + if ( ! this.paused ) { |
| 399 | + this.playerElement.play(); |
| 400 | + } |
383 | 401 | }, |
384 | 402 | |
385 | 403 | /** |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js |
— | — | @@ -26,7 +26,6 @@ |
27 | 27 | "mwe-please-login" : "The request failed. Are you logged in on $1 ? Please $2 and try again", |
28 | 28 | "mwe-log-in-link" : "log in", |
29 | 29 | "mwe-remember-loging" : "General security reminder: Only login to web sites when your address bar displays that site's address." |
30 | | - |
31 | 30 | } ); |
32 | 31 | |
33 | 32 | |
— | — | @@ -406,8 +405,7 @@ |
407 | 406 | nestedServerFrame = getServerFrame( { |
408 | 407 | 'apiUrl' : mw.getLocalApiUrl(), |
409 | 408 | 'pageName' : 'ApiProxyNestedCb' |
410 | | - } ); |
411 | | - |
| 409 | + } ); |
412 | 410 | // Update the context to include the nestedCallbackFlag flag in the request |
413 | 411 | return nestedServerFrame; |
414 | 412 | } |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -463,8 +463,9 @@ |
464 | 464 | * @param {Function} hookFunction Function to be called at hook time |
465 | 465 | */ |
466 | 466 | targetObj.addHook = function( hookName, hookFunction ) { |
467 | | - if( ! this.hooks[ hookName ] ) |
| 467 | + if( ! this.hooks[ hookName ] ) { |
468 | 468 | this.hooks[ hookName ] = [ ]; |
| 469 | + } |
469 | 470 | this.hooks[ hookName ].push( hookFunction ) |
470 | 471 | } |
471 | 472 | |
— | — | @@ -775,8 +776,8 @@ |
776 | 777 | scriptRequest = baseClassPath; |
777 | 778 | } |
778 | 779 | if( ! scriptRequest ) { |
779 | | - mw.log( "Could not get url for class " + className ); |
780 | | - return ; |
| 780 | + mw.log( "Error Could not get url for class " + className ); |
| 781 | + return false; |
781 | 782 | } |
782 | 783 | } |
783 | 784 | |
— | — | @@ -785,15 +786,23 @@ |
786 | 787 | |
787 | 788 | // Set the top level load done to the callback |
788 | 789 | mw.setLoadDoneCB( className, callback ); |
| 790 | + |
789 | 791 | |
790 | 792 | // Issue the request to load the class (include class name in result callback: |
791 | 793 | mw.getScript( scriptRequest, function( scriptRequest ) { |
| 794 | + // If its a "syle sheet" manually set its class to true |
| 795 | + if( scriptRequest.substr( scriptRequest.lastIndexOf( '.' ), 4 ).toLowerCase() == 'css' && |
| 796 | + className.substr(0,8) == 'mw.style' ){ |
| 797 | + window [ className ] = true; |
| 798 | + } |
| 799 | + |
792 | 800 | // Debug output |
793 | 801 | if(! mw.isset( className ) |
794 | 802 | && mwLoadDoneCB[ className ] != 'done' ) { |
795 | 803 | mw.log( 'Possible Error: ' + className +' not set in time, or not defined in:' + "\n" + _this.getClassPath( className ) ); |
796 | 804 | } |
797 | 805 | // Call load done (incase the script did not include a loadDone callback ) |
| 806 | + // if the script loader (did call loadDone this loadDone will be ignored |
798 | 807 | mw.loadDone( className ); |
799 | 808 | } ); |
800 | 809 | //mw.log( 'done with running getScript request ' ); |
— | — | @@ -852,7 +861,7 @@ |
853 | 862 | if( this.classPaths[ className ] ) |
854 | 863 | return this.classPaths[ className ] |
855 | 864 | return false; |
856 | | - } |
| 865 | + } |
857 | 866 | } |
858 | 867 | /** |
859 | 868 | * Load done callback for script loader |
— | — | @@ -1541,10 +1550,11 @@ |
1542 | 1551 | * @param {Function} callback Function to call once script is loaded |
1543 | 1552 | */ |
1544 | 1553 | mw.getScript = function( scriptRequest, callback ) { |
1545 | | - // Setup the local callback |
| 1554 | + // Setup the local scope callback instace |
1546 | 1555 | var myCallback = function(){ |
1547 | | - if( callback ) |
| 1556 | + if( callback ) { |
1548 | 1557 | callback( scriptRequest ); |
| 1558 | + } |
1549 | 1559 | } |
1550 | 1560 | // Set the base url based scriptLoader availability & type of scriptRequest |
1551 | 1561 | // ( presently script loader only handles "classes" not relative urls: |
— | — | @@ -1552,7 +1562,7 @@ |
1553 | 1563 | |
1554 | 1564 | // Check if its a class name, ( ie does not start with "/" and does not include :// |
1555 | 1565 | var isClassName = ( scriptRequest.indexOf('://') == -1 && scriptRequest.indexOf('/') !== 0 )? true : false; |
1556 | | - |
| 1566 | + |
1557 | 1567 | var ext = scriptRequest.substr( scriptRequest.lastIndexOf( '.' ), 4 ).toLowerCase(); |
1558 | 1568 | var isCssFile = ( ext == '.css') ? true : false ; |
1559 | 1569 | |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -182,6 +182,7 @@ |
183 | 183 | 'kskinConfig', |
184 | 184 | 'mw.style.kskin', |
185 | 185 | '$j.fn.menu', |
| 186 | + 'mw.style.jquerymenu', |
186 | 187 | 'mw.TimedText' |
187 | 188 | ]; |
188 | 189 | // Quick sniff use java if IE and native if firefox |