Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -248,11 +248,11 @@ |
249 | 249 | * @param [ Optional ] {Function} callback Function to be called once video interfaces are ready |
250 | 250 | * |
251 | 251 | */ |
252 | | - $.fn.embedPlayer = function( attributes, callback ) { |
| 252 | + $.fn.embedPlayer = function( attributes, callback ) { |
253 | 253 | mw.log('embedPlayer on: ' + this.selector); |
254 | | - var player_select = this.selector; |
| 254 | + var playerSelect = this.selector; |
255 | 255 | |
256 | | - // Handle optional include of attributes argument: |
| 256 | + //Handle optional include of attributes argument: |
257 | 257 | if( typeof attributes == 'function' ){ |
258 | 258 | callback = attributes; |
259 | 259 | } |
— | — | @@ -263,16 +263,16 @@ |
264 | 264 | mw.playerManager = new EmbedPlayerManager(); |
265 | 265 | |
266 | 266 | // Run the global hooks that mw.playerManager is ready |
267 | | - mw.runHook( 'EmbedPlayerManagerReady' ); |
| 267 | + $j( mw ).trigger( 'EmbedPlayerManagerReady' ); |
268 | 268 | } |
269 | 269 | |
270 | | - // Add the embedPlayer ready callback |
271 | | - if( typeof callback == 'function' ) { |
| 270 | + //Add the embedPlayer ready callback |
| 271 | + if( typeof callback == 'function' ){ |
272 | 272 | mw.playerManager.addCallback( callback ); |
273 | | - } |
274 | | - |
| 273 | + } |
| 274 | + |
275 | 275 | // Add each selected element to the player manager: |
276 | | - $j( player_select ).each( function(na, playerElement) { |
| 276 | + $j( playerSelect ).each( function(na, playerElement) { |
277 | 277 | mw.playerManager.addElement( playerElement, attributes); |
278 | 278 | } ); |
279 | 279 | } |
— | — | @@ -299,7 +299,6 @@ |
300 | 300 | init: function( ) { |
301 | 301 | this.callbackFunctions = []; |
302 | 302 | this.playerList = []; |
303 | | - mw.addHookSystem ( this ); |
304 | 303 | }, |
305 | 304 | |
306 | 305 | /** |
— | — | @@ -372,11 +371,12 @@ |
373 | 372 | var playlistPlayer = new mw.PlayList( element, attributes ); |
374 | 373 | |
375 | 374 | // Swap in playlist player interface |
376 | | - _this.swapEmbedPlayerElement( element, playlistPlayer ); |
| 375 | + _this.swapEmbedPlayerElement( element, playerInterface ); |
377 | 376 | |
378 | | - // Pass the id to any hook that needs to interface prior to showPlayer code |
379 | | - _this.runHook( 'swapedPlayerId', playerInterface.id ); |
| 377 | + // Pass the id to any hook that needs to interface prior to checkPlayerSources |
| 378 | + $j( _this ).trigger ( 'swapedPlayerId', playerInterface.id ); |
380 | 379 | |
| 380 | + |
381 | 381 | // Issue the checkPlayerSources call to the new playlist interface: |
382 | 382 | $j( '#' + playlistPlayer.id ).get(0).showPlayer(); |
383 | 383 | } ); |
— | — | @@ -394,10 +394,10 @@ |
395 | 395 | mw.log("runPlayerSwap::" + $j( element ).attr('id') ); |
396 | 396 | ranPlayerSwapFlag = true; |
397 | 397 | var playerInterface = new mw.EmbedPlayer( element , attributes); |
398 | | - _this.swapEmbedPlayerElement( element, playerInterface ); |
| 398 | + _this.swapEmbedPlayerElement( element, playerInterface ); |
399 | 399 | |
400 | 400 | // Pass the id to any hook that needs to interface prior to checkPlayerSources |
401 | | - _this.runHook( 'swapedPlayerId', playerInterface.id ); |
| 401 | + $j( _this ).trigger ( 'swapedPlayerId', playerInterface.id ); |
402 | 402 | |
403 | 403 | // Issue the checkPlayerSources call to the new player interface: |
404 | 404 | // make sure to use the element that is in the DOM: |
— | — | @@ -560,10 +560,9 @@ |
561 | 561 | // Remove the player loader spinner: |
562 | 562 | $j('#loadSpiner_' + player.id ).remove(); |
563 | 563 | |
564 | | - // Run the player ready hook |
565 | | - player.runHook( 'playerReady' ); |
| 564 | + // Run the player ready trigger |
| 565 | + $j( player ).trigger( 'playerReady' ); |
566 | 566 | |
567 | | - // Check if all the players are ready |
568 | 567 | var is_ready = true; |
569 | 568 | for ( var i = 0; i < this.playerList.length; i++ ) { |
570 | 569 | var currentPlayer = $j( '#' + this.playerList[i] ).get( 0 ); |
— | — | @@ -595,7 +594,7 @@ |
596 | 595 | |
597 | 596 | mediaSource.prototype = { |
598 | 597 | // MIME type of the source. |
599 | | - mimeType: null, |
| 598 | + mimeType:null, |
600 | 599 | |
601 | 600 | // URI of the source. |
602 | 601 | uri:null, |
— | — | @@ -648,7 +647,7 @@ |
649 | 648 | if ( typeof pUrl[ 'queryKey' ][ 't' ] != 'undefined' ) { |
650 | 649 | this[ 'URLTimeEncoding' ] = true; |
651 | 650 | } |
652 | | - // Set the source attributes local var |
| 651 | + |
653 | 652 | var sourceAttr = mw.getConfig( 'embedPlayerSourceAttributes' ); |
654 | 653 | |
655 | 654 | for ( var i = 0; i < sourceAttr.length; i++ ) { // array loop: |
— | — | @@ -973,15 +972,15 @@ |
974 | 973 | * @return mediaSource elements. |
975 | 974 | * @type Array |
976 | 975 | */ |
977 | | - getSources: function( mime_filter ) { |
978 | | - if ( !mime_filter ) { |
| 976 | + getSources: function( mimeFilter ) { |
| 977 | + if ( !mimeFilter ) { |
979 | 978 | return this.sources; |
980 | 979 | } |
981 | 980 | // Apply mime filter: |
982 | 981 | var source_set = new Array(); |
983 | 982 | for ( var i = 0; i < this.sources.length ; i++ ) { |
984 | 983 | if ( this.sources[i].mimeType && |
985 | | - this.sources[i].mimeType.indexOf( mime_filter ) != -1 ) |
| 984 | + this.sources[i].mimeType.indexOf( mimeFilter ) != -1 ) |
986 | 985 | source_set.push( this.sources[i] ); |
987 | 986 | } |
988 | 987 | return source_set; |
— | — | @@ -1144,7 +1143,7 @@ |
1145 | 1144 | // make sure an existing element with the same src does not already exist: |
1146 | 1145 | for ( var i = 0; i < this.sources.length; i++ ) { |
1147 | 1146 | if ( this.sources[i].src == newSrc ) { |
1148 | | - // Source already exists update any new attributes: |
| 1147 | + // Source already exists update any new attr: |
1149 | 1148 | this.sources[i].updateSource( element ); |
1150 | 1149 | return this.sources[i]; |
1151 | 1150 | } |
— | — | @@ -1152,8 +1151,8 @@ |
1153 | 1152 | } |
1154 | 1153 | // Create a new source |
1155 | 1154 | var source = new mediaSource( element ); |
1156 | | - |
1157 | | - this.sources.push( source ); |
| 1155 | + |
| 1156 | + this.sources.push( source ); |
1158 | 1157 | mw.log( 'tryAddSource: added source ::' + source + 'sl:' + this.sources.length ); |
1159 | 1158 | return source; |
1160 | 1159 | }, |
— | — | @@ -1169,7 +1168,7 @@ |
1170 | 1169 | if ( this.isPlayableType( this.sources[i].mimeType ) ) { |
1171 | 1170 | playableSources.push( this.sources[i] ); |
1172 | 1171 | } else { |
1173 | | - mw.log( "type " + this.sources[i].mimeType + 'is not playable' ); |
| 1172 | + //mw.log( "type " + this.sources[i].mimeType + 'is not playable' ); |
1174 | 1173 | } |
1175 | 1174 | }; |
1176 | 1175 | return playableSources; |
— | — | @@ -1244,9 +1243,6 @@ |
1245 | 1244 | // Stores the loading errors |
1246 | 1245 | 'loadError' : false, |
1247 | 1246 | |
1248 | | - // Loading external data flag ( for delaying interface updates ) |
1249 | | - 'loading_external_data' : false, |
1250 | | - |
1251 | 1247 | // Thumbnail updating flag ( to avoid rewriting an thumbnail thats already being updated) |
1252 | 1248 | 'thumbnail_updating' : false, |
1253 | 1249 | |
— | — | @@ -1285,12 +1281,10 @@ |
1286 | 1282 | init: function( element, customAttributes ) { |
1287 | 1283 | var _this = this; |
1288 | 1284 | // Set customAttributes if unset: |
1289 | | - if ( !customAttributes ) |
| 1285 | + if ( !customAttributes ) { |
1290 | 1286 | customAttributes = { }; |
| 1287 | + } |
1291 | 1288 | |
1292 | | - //Add a hook system to the embedPlayer |
1293 | | - mw.addHookSystem( _this ); |
1294 | | - |
1295 | 1289 | var playerAttributes = mw.getConfig( 'embedPlayerAttributes' ); |
1296 | 1290 | // Setup the player Interface from supported attributes: |
1297 | 1291 | for ( var attr in playerAttributes ) { |
— | — | @@ -1371,8 +1365,8 @@ |
1372 | 1366 | } |
1373 | 1367 | |
1374 | 1368 | // Add the mediaElement object with the elements sources: |
1375 | | - this.mediaElement = new mediaElement( element ); |
1376 | | - |
| 1369 | + this.mediaElement = new mediaElement( element ); |
| 1370 | + |
1377 | 1371 | }, |
1378 | 1372 | |
1379 | 1373 | /** |
— | — | @@ -1431,6 +1425,7 @@ |
1432 | 1426 | ) { |
1433 | 1427 | var defaultSize = mw.getConfig( 'videoSize' ).split( 'x' ); |
1434 | 1428 | this['width'] = defaultSize[0]; |
| 1429 | + |
1435 | 1430 | // Special height default for audio tag ( if not set ) |
1436 | 1431 | if( element.tagName.toLowerCase() == 'audio' ) { |
1437 | 1432 | this['height'] = 0; |
— | — | @@ -1464,7 +1459,7 @@ |
1465 | 1460 | * If we need to get media sources form an external file |
1466 | 1461 | * that request is issued here |
1467 | 1462 | */ |
1468 | | - checkPlayerSources: function( callbackChain ) { |
| 1463 | + checkPlayerSources: function() { |
1469 | 1464 | mw.log( 'f:checkPlayerSources: ' + this.id ); |
1470 | 1465 | var _this = this; |
1471 | 1466 | var sourceCount = this.mediaElement.getPlayableSources().length; |
— | — | @@ -1482,19 +1477,16 @@ |
1483 | 1478 | } ); |
1484 | 1479 | return ; |
1485 | 1480 | } |
1486 | | - // Check for hooks to handle checkPlayerSources |
1487 | | - if( this.hooks[ 'checkPlayerSources' ].length ) { |
1488 | | - this.runHook( 'checkPlayerSources', function(){ |
1489 | | - _this.checkForTimedText(); |
1490 | | - }); |
1491 | | - } else { |
1492 | | - // no hooks run check for timed text directly |
1493 | | - _this.checkForTimedText(); |
1494 | | - } |
1495 | 1481 | |
| 1482 | + // Run embedPlayer sources hook |
| 1483 | + $j( this ).trigger ( 'checkPlayerSources', function(){ |
| 1484 | + // Continue application flow and check for Timed Text |
| 1485 | + _this.checkForTimedText(); |
| 1486 | + }); |
1496 | 1487 | }, |
| 1488 | + |
1497 | 1489 | /** |
1498 | | - * Load Source video info From Api title key ( this.apiTitleKey ) |
| 1490 | + * Load Source video info from mediaWiki Api title key ( this.apiTitleKey ) |
1499 | 1491 | * @param {Function} callback Function called once loading is complete |
1500 | 1492 | */ |
1501 | 1493 | loadSourceFromApi: function( callback ){ |
— | — | @@ -1610,7 +1602,7 @@ |
1611 | 1603 | // Auto select player based on default order |
1612 | 1604 | if ( !this.mediaElement.selectedSource ) { |
1613 | 1605 | // check for parent clip: |
1614 | | - if ( typeof this.pc != 'undefined' ) { |
| 1606 | + if ( typeof this.pc != 'undefined' ) { |
1615 | 1607 | mw.log( 'no sources, type:' + this.type + ' check for html' ); |
1616 | 1608 | // debugger; |
1617 | 1609 | // do load player if just displaying innerHTML: |
— | — | @@ -1629,7 +1621,6 @@ |
1630 | 1622 | // Inherit the playback system of the selected player: |
1631 | 1623 | this.inheritEmbedPlayer(); |
1632 | 1624 | } else { |
1633 | | - |
1634 | 1625 | // No source's playable |
1635 | 1626 | var missingType = ''; |
1636 | 1627 | var or = ''; |
— | — | @@ -1637,7 +1628,6 @@ |
1638 | 1629 | missingType += or + this.mediaElement.sources[i].mimeType; |
1639 | 1630 | or = ' or '; |
1640 | 1631 | } |
1641 | | - |
1642 | 1632 | // Get from parent playlist if set: |
1643 | 1633 | if ( this.pc ){ |
1644 | 1634 | missingType = this.pc.type; |
— | — | @@ -1780,32 +1770,21 @@ |
1781 | 1771 | mw.log( 'updated seek_time_sec: ' + mw.seconds2npt ( this.seek_time_sec ) ); |
1782 | 1772 | this.stop(); |
1783 | 1773 | this.didSeekJump = true; |
1784 | | - |
1785 | 1774 | // Update the slider |
1786 | 1775 | this.updatePlayHead( percent ); |
1787 | | - |
1788 | | - // Do play request in 100ms ( give the dom time to swap out the embed player ) |
1789 | | - setTimeout( function() { |
1790 | | - _this.play() |
1791 | | - }, 100 ); |
1792 | 1776 | } |
| 1777 | + // Do play request in 100ms ( give the dom time to swap out the embed player ) |
| 1778 | + setTimeout( function() { |
| 1779 | + _this.play() |
| 1780 | + }, 100 ); |
1793 | 1781 | |
1794 | 1782 | // Run the onSeeking interface update |
1795 | | - this.onSeek(); |
1796 | | - |
1797 | | - }, |
| 1783 | + // NOTE ctrlBuilder should really bind to html5 events rather |
| 1784 | + // than explicitly calling it or inheriting stuff. |
| 1785 | + this.ctrlBuilder.onSeek(); |
| 1786 | + }, |
1798 | 1787 | |
1799 | 1788 | /** |
1800 | | - * function fired once seeking is taking place |
1801 | | - */ |
1802 | | - onSeek: function(){ |
1803 | | - // Update the interface: |
1804 | | - this.setStatus( gM( 'mwe-seeking' ) ); |
1805 | | - // Run the seeking hook |
1806 | | - this.runHook( 'onSeek' ); |
1807 | | - }, |
1808 | | - |
1809 | | - /** |
1810 | 1789 | * Seeks to the requested time and issues a callback when ready |
1811 | 1790 | * (should be overwritten by client that supports frame serving) |
1812 | 1791 | */ |
— | — | @@ -1839,7 +1818,7 @@ |
1840 | 1819 | this.bufferStartFlag = false; |
1841 | 1820 | this.bufferEndFlag = false; |
1842 | 1821 | |
1843 | | - |
| 1822 | + // Make sure the player is |
1844 | 1823 | mw.log( 'performing embed for ' + _this.id ); |
1845 | 1824 | // mw.log('should embed:' + embed_code); |
1846 | 1825 | _this.doEmbedHTML() |
— | — | @@ -1851,7 +1830,8 @@ |
1852 | 1831 | * On clip done action. Called once a clip is done playing |
1853 | 1832 | */ |
1854 | 1833 | onClipDone: function() { |
1855 | | - mw.log( 'base:onClipDone' ); |
| 1834 | + mw.log( 'base:onClipDone' ); |
| 1835 | + |
1856 | 1836 | |
1857 | 1837 | // Stop the clip (load the thumbnail etc) |
1858 | 1838 | this.stop(); |
— | — | @@ -1870,11 +1850,11 @@ |
1871 | 1851 | } |
1872 | 1852 | // Do the ctrlBuilder onClip done interface |
1873 | 1853 | this.ctrlBuilder.onClipDone(); |
1874 | | - |
1875 | | - // Fire the html5 ended binding / event |
| 1854 | + |
| 1855 | + // Fire the html5 ended binding |
1876 | 1856 | $j( this ).trigger( 'ended' ); |
1877 | 1857 | |
1878 | | - //Set the clip done playing count: |
| 1858 | + // Update the clip done playing count: |
1879 | 1859 | this.donePlayingCount ++; |
1880 | 1860 | }, |
1881 | 1861 | |
— | — | @@ -1897,8 +1877,8 @@ |
1898 | 1878 | // Make sure the ctrlBuilder bindings are up-to-date |
1899 | 1879 | this.ctrlBuilder.addControlHooks(); |
1900 | 1880 | |
1901 | | - // Once the thumbnail is shown run the mediaReady hook |
1902 | | - this.runHook( 'mediaLoaded' ); |
| 1881 | + // Once the thumbnail is shown run the mediaReady trigger |
| 1882 | + $j( this ).trigger( 'mediaLoaded' ); |
1903 | 1883 | }, |
1904 | 1884 | |
1905 | 1885 | /** |
— | — | @@ -1923,7 +1903,6 @@ |
1924 | 1904 | this.ctrlBuilder = new ctrlBuilder( this ); |
1925 | 1905 | |
1926 | 1906 | var _this = this; |
1927 | | - |
1928 | 1907 | // Make sure we have interface_wrap |
1929 | 1908 | if( $j( this ).parent( '.interface_wrap' ).length == 0 ) { |
1930 | 1909 | // Select "player" |
— | — | @@ -1966,9 +1945,9 @@ |
1967 | 1946 | * @param {String} [misssingType] missing type mime |
1968 | 1947 | */ |
1969 | 1948 | showPluginMissingHTML : function( misssingType ) { |
1970 | | - //remove the loading spinner if present: |
| 1949 | + // Remove the loading spinner if present: |
1971 | 1950 | $j('#loadSpiner_' + this.id ).remove(); |
1972 | | - |
| 1951 | + |
1973 | 1952 | // If the native video is already displayed hide it: |
1974 | 1953 | if( $j( '#' + this.pid ).length != 0 ){ |
1975 | 1954 | $j('#loadSpiner_' + this.id ).remove(); |
— | — | @@ -2026,7 +2005,7 @@ |
2027 | 2006 | this.mediaElement.updateSourceTimes( start_npt, end_npt ); |
2028 | 2007 | |
2029 | 2008 | // update mv_time |
2030 | | - this.setStatus( start_npt + '/' + end_npt ); |
| 2009 | + this.ctrlBuilder.setStatus( start_npt + '/' + end_npt ); |
2031 | 2010 | |
2032 | 2011 | // reset slider |
2033 | 2012 | this.updatePlayHead( 0 ); |
— | — | @@ -2178,8 +2157,9 @@ |
2179 | 2158 | mw.log( 'embedPlayer:updateThumbnailHTML::' + this.id ); |
2180 | 2159 | var thumb_html = ''; |
2181 | 2160 | var class_atr = ''; |
2182 | | - var style_atr = ''; |
| 2161 | + var style_atr = ''; |
2183 | 2162 | |
| 2163 | + |
2184 | 2164 | if( this.useNativeControls() ){ |
2185 | 2165 | this.showNativePlayer(); |
2186 | 2166 | return ; |
— | — | @@ -2187,9 +2167,9 @@ |
2188 | 2168 | |
2189 | 2169 | // Set by default thumb value if not found |
2190 | 2170 | var posterSrc = ( this.poster ) ? this.poster : |
2191 | | - mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg'; |
| 2171 | + mw.getConfig( 'imagesPath' ) + 'vid_default_thumb.jpg'; |
2192 | 2172 | |
2193 | | - // Poster support is not very good in all browsers |
| 2173 | + // Poster support is not very consistant in browsers |
2194 | 2174 | // use a jpg poster image: |
2195 | 2175 | $j( this ).html( |
2196 | 2176 | $j( '<img />' ) |
— | — | @@ -2204,7 +2184,7 @@ |
2205 | 2185 | }) |
2206 | 2186 | .addClass( 'playerPoster' ) |
2207 | 2187 | ); |
2208 | | - |
| 2188 | + |
2209 | 2189 | if ( this.controls |
2210 | 2190 | && this.height > this.ctrlBuilder.getComponentHeight( 'playButtonLarge' ) |
2211 | 2191 | ) { |
— | — | @@ -2217,7 +2197,7 @@ |
2218 | 2198 | /** |
2219 | 2199 | * Checks if native controls should be used |
2220 | 2200 | * |
2221 | | - * @param [player] Object Optional player object to check controls attribute |
| 2201 | + * @param [player] Object Optional player object to check controls attribute |
2222 | 2202 | * @returns boolean true if the mwEmbed player interface should be used |
2223 | 2203 | * false if the mwEmbed player interface should not be used |
2224 | 2204 | */ |
— | — | @@ -2507,14 +2487,12 @@ |
2508 | 2488 | this.doPlayTracking(); |
2509 | 2489 | } |
2510 | 2490 | |
2511 | | - // Run play hook: |
2512 | | - this.runHook( 'play' ); |
2513 | | - |
2514 | | - // If we previusly finished playing this clip run the "replay hook" |
| 2491 | + //Run play hook: |
| 2492 | + $j( this ).trigger( 'onPlay' ); |
| 2493 | + // If we previusly finished playing this clip run the "replay hook" |
2515 | 2494 | if( this.donePlayingCount > 0 ){ |
2516 | | - this.runHook( 'replay' ); |
| 2495 | + $j( this ).trigger( 'onReplay' ); |
2517 | 2496 | } |
2518 | | - |
2519 | 2497 | }, |
2520 | 2498 | |
2521 | 2499 | /** |
— | — | @@ -2587,7 +2565,7 @@ |
2588 | 2566 | this.showThumbnail(); |
2589 | 2567 | this.bufferedPercent = 0; // reset buffer state |
2590 | 2568 | this.updatePlayHead( 0 ); |
2591 | | - this.setStatus( this.getTimeRange() ); |
| 2569 | + this.ctrlBuilder.setStatus( this.getTimeRange() ); |
2592 | 2570 | } |
2593 | 2571 | |
2594 | 2572 | //Bind play-btn-large play |
— | — | @@ -2710,14 +2688,13 @@ |
2711 | 2689 | if ( parseInt( this.startOffset ) != 0 ) { |
2712 | 2690 | // If start offset include that calculation |
2713 | 2691 | this.updatePlayHead( ( this.currentTime - this.startOffset ) / this.duration ); |
2714 | | - var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) + |
2715 | | - parseFloat( this.duration ) ) : ''; |
2716 | | - this.setStatus( mw.seconds2npt( this.currentTime ) + et ); |
| 2692 | + var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) + parseFloat( this.duration ) ) : ''; |
| 2693 | + this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + et ); |
2717 | 2694 | } else { |
2718 | 2695 | this.updatePlayHead( this.currentTime / this.duration ); |
2719 | 2696 | // Only include the end time if longTimeDisp is enabled: |
2720 | 2697 | var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( this.duration ) : ''; |
2721 | | - this.setStatus( mw.seconds2npt( this.currentTime ) + et ); |
| 2698 | + this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + et ); |
2722 | 2699 | } |
2723 | 2700 | } |
2724 | 2701 | // Check if we are "done" |
— | — | @@ -2729,16 +2706,16 @@ |
2730 | 2707 | } else { |
2731 | 2708 | // Media lacks duration just show end time |
2732 | 2709 | if ( this.isStoped() ) { |
2733 | | - this.setStatus( this.getTimeRange() ); |
| 2710 | + this.ctrlBuilder.setStatus( this.getTimeRange() ); |
2734 | 2711 | } else if ( this.isPaused() ) { |
2735 | | - this.setStatus( gM( 'mwe-paused' ) ); |
| 2712 | + this.ctrlBuilder.setStatus( gM( 'mwe-paused' ) ); |
2736 | 2713 | } else if ( this.isPlaying() ) { |
2737 | 2714 | if ( this.currentTime && ! this.duration ) |
2738 | | - this.setStatus( mw.seconds2npt( this.currentTime ) + ' /' ); |
| 2715 | + this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + ' /' ); |
2739 | 2716 | else |
2740 | | - this.setStatus( " - - - " ); |
| 2717 | + this.ctrlBuilder.setStatus( " - - - " ); |
2741 | 2718 | } else { |
2742 | | - this.setStatus( this.getTimeRange() ); |
| 2719 | + this.ctrlBuilder.setStatus( this.getTimeRange() ); |
2743 | 2720 | } |
2744 | 2721 | } |
2745 | 2722 | |
— | — | @@ -2751,14 +2728,13 @@ |
2752 | 2729 | }, 250 ) |
2753 | 2730 | } |
2754 | 2731 | |
2755 | | - this.runHook( 'monitor' ); |
| 2732 | + $j( this ).trigger( 'onMonitor' ); |
2756 | 2733 | }, |
2757 | 2734 | |
2758 | 2735 | /** |
2759 | 2736 | * Update the buffer status based on the local bufferedPercent var |
2760 | 2737 | */ |
2761 | 2738 | updateBufferStatus: function() { |
2762 | | - |
2763 | 2739 | // Get the buffer target based for playlist vs clip |
2764 | 2740 | $buffer = this.$interface.find( '.mw_buffer' ); |
2765 | 2741 | |
— | — | @@ -2778,15 +2754,14 @@ |
2779 | 2755 | // if we have not already run the buffer start hook |
2780 | 2756 | if( this.bufferedPercent > 0 && !this.bufferStartFlag ) { |
2781 | 2757 | this.bufferStartFlag = true; |
2782 | | - this.runHook( 'bufferStart' ); |
| 2758 | + $j( this ).trigger( 'onBufferStart' ); |
2783 | 2759 | } |
2784 | 2760 | |
2785 | 2761 | // if we have not already run the buffer end hook |
2786 | 2762 | if( this.bufferedPercent == 1 && !this.bufferEndFlag){ |
2787 | 2763 | this.bufferEndFlag = true; |
2788 | | - this.runHook( 'bufferEnd' ); |
| 2764 | + $j( this ).trigger( 'onBufferEnd' ); |
2789 | 2765 | } |
2790 | | - |
2791 | 2766 | }, |
2792 | 2767 | |
2793 | 2768 | /** |
— | — | @@ -2846,7 +2821,7 @@ |
2847 | 2822 | this.jump_time = options['start']; |
2848 | 2823 | this.seek_time_sec = mw.npt2seconds( options['start'] ); |
2849 | 2824 | // trim output to |
2850 | | - this.setStatus( gM( 'mwe-seek_to', mw.seconds2npt( this.seek_time_sec ) ) ); |
| 2825 | + this.ctrlBuilder.setStatus( gM( 'mwe-seek_to', mw.seconds2npt( this.seek_time_sec ) ) ); |
2851 | 2826 | mw.log( 'DO update: ' + this.jump_time ); |
2852 | 2827 | this.updateThumbTime( rel_start_sec ); |
2853 | 2828 | }, |
— | — | @@ -2857,20 +2832,10 @@ |
2858 | 2833 | hideHighlight: function() { |
2859 | 2834 | var eid = ( this.pc ) ? this.pc.pp.id:this.id; |
2860 | 2835 | $j( '#mv_seeker_' + eid + ' .mv_highlight' ).hide(); |
2861 | | - this.setStatus( this.getTimeRange() ); |
2862 | | - }, |
| 2836 | + this.ctrlBuilder.setStatus( this.getTimeRange() ); |
| 2837 | + }, |
2863 | 2838 | |
2864 | | - /** |
2865 | | - * Updates the player status that displays short text msgs and the play clock |
2866 | | - * @param {String} value Status string value to update |
2867 | | - */ |
2868 | | - setStatus: function( value ) { |
2869 | | - // update status: |
2870 | | - this.$interface.find( '.time-disp' ).html( value ); |
2871 | | - }, |
2872 | 2839 | |
2873 | | - |
2874 | | - |
2875 | 2840 | /** |
2876 | 2841 | * Helper Functions for selected source |
2877 | 2842 | */ |
— | — | @@ -3072,9 +3037,9 @@ |
3073 | 3038 | /** |
3074 | 3039 | * Checks if a player is supported by id |
3075 | 3040 | */ |
3076 | | - isSupportedPlayer: function( player_id ){ |
| 3041 | + isSupportedPlayer: function( playerId ){ |
3077 | 3042 | for( var i=0; i < this.players.length; i++ ){ |
3078 | | - if( this.players[i].id == player_id ){ |
| 3043 | + if( this.players[i].id == playerId ){ |
3079 | 3044 | return true; |
3080 | 3045 | } |
3081 | 3046 | } |
— | — | @@ -3133,26 +3098,26 @@ |
3134 | 3099 | /** |
3135 | 3100 | * Sets the format preference. |
3136 | 3101 | * |
3137 | | - * @param {String} mime_format Prefered format |
| 3102 | + * @param {String} mimeFormat Prefered format |
3138 | 3103 | */ |
3139 | | - setFormatPreference : function ( mime_format ) { |
3140 | | - this.preference['format_preference'] = mime_format; |
| 3104 | + setFormatPreference : function ( mimeFormat ) { |
| 3105 | + this.preference['format_preference'] = mimeFormat; |
3141 | 3106 | mw.setUserConfig( 'playerPref', this.preference); |
3142 | 3107 | }, |
3143 | 3108 | |
3144 | 3109 | /** |
3145 | 3110 | * Sets the player preference |
3146 | 3111 | * |
3147 | | - * @param {String} player_id Prefered player id |
| 3112 | + * @param {String} playerId Prefered player id |
3148 | 3113 | * @param {String} mimeType Mime type for the associated player stream |
3149 | 3114 | */ |
3150 | | - setPlayerPreference : function( player_id, mimeType ) { |
| 3115 | + setPlayerPreference : function( playerId, mimeType ) { |
3151 | 3116 | var selected_player = null; |
3152 | 3117 | for ( var i = 0; i < this.players.length; i++ ) { |
3153 | | - if ( this.players[i].id == player_id ) { |
| 3118 | + if ( this.players[i].id == playerId ) { |
3154 | 3119 | selected_player = this.players[i]; |
3155 | | - mw.log( 'choosing ' + player_id + ' for ' + mimeType ); |
3156 | | - this.preference[ mimeType ] = player_id; |
| 3120 | + mw.log( 'choosing ' + playerId + ' for ' + mimeType ); |
| 3121 | + this.preference[ mimeType ] = playerId; |
3157 | 3122 | mw.setUserConfig( 'playerPref', this.preference ); |
3158 | 3123 | break; |
3159 | 3124 | } |
— | — | @@ -3211,12 +3176,12 @@ |
3212 | 3177 | /** |
3213 | 3178 | * If the browsers supports a given mimetype |
3214 | 3179 | * |
3215 | | - * @param {String} mimetype Mime type for browser plug-in check |
| 3180 | + * @param {String} mimeType Mime type for browser plug-in check |
3216 | 3181 | */ |
3217 | | - supportedMimeType: function( mimetype ) { |
3218 | | - for ( var i = navigator.plugins.length; i-- > 0; ) { |
| 3182 | + supportedMimeType: function( mimeType ) { |
| 3183 | + for ( var i =0; i < navigator.plugins.length; i++ ) { |
3219 | 3184 | var plugin = navigator.plugins[i]; |
3220 | | - if ( typeof plugin[mimetype] != "undefined" ) |
| 3185 | + if ( typeof plugin[ mimeType ] != "undefined" ) |
3221 | 3186 | return true; |
3222 | 3187 | } |
3223 | 3188 | return false; |
— | — | @@ -3226,23 +3191,23 @@ |
3227 | 3192 | * Detects what plug-ins the client supports |
3228 | 3193 | */ |
3229 | 3194 | detect: function() { |
3230 | | - mw.log( "embedPlayer: running detect" ); |
| 3195 | + mw.log( "embedPlayer: running detect" ); |
3231 | 3196 | this.players = new mediaPlayers(); |
3232 | 3197 | // every browser supports html rendering: |
3233 | 3198 | this.players.addPlayer( htmlPlayer ); |
3234 | | - // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to |
3235 | | - // search navigator.mimeTypes to see if it's installed |
3236 | | - var javaEnabled = navigator.javaEnabled(); |
3237 | | - // Some browsers filter out duplicate mime types, hiding some plugins |
3238 | | - var uniqueMimesOnly = $j.browser.opera || $j.browser.safari; |
3239 | | - // Opera will switch off javaEnabled in preferences if java can't be found. |
3240 | | - // And it doesn't register an application/x-java-applet mime type like Mozilla does. |
3241 | | - if ( javaEnabled ) { |
3242 | | - this.players.addPlayer( cortadoPlayer ); |
3243 | | - } |
| 3199 | + // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to |
| 3200 | + // search navigator.mimeTypes to see if it's installed |
| 3201 | + var javaEnabled = navigator.javaEnabled(); |
| 3202 | + // Some browsers filter out duplicate mime types, hiding some plugins |
| 3203 | + var uniqueMimesOnly = $j.browser.opera || $j.browser.safari; |
| 3204 | + // Opera will switch off javaEnabled in preferences if java can't be found. |
| 3205 | + // And it doesn't register an application/x-java-applet mime type like Mozilla does. |
| 3206 | + if ( javaEnabled ) { |
| 3207 | + this.players.addPlayer( cortadoPlayer ); |
| 3208 | + } |
3244 | 3209 | |
3245 | | - // ActiveX plugins |
3246 | | - if ( $j.browser.msie ) { |
| 3210 | + // ActiveX plugins |
| 3211 | + if ( $j.browser.msie ) { |
3247 | 3212 | // check for flash |
3248 | 3213 | if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash' ) ) { |
3249 | 3214 | // try to get the flash version for omtk include: |