r59820 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59819‎ | r59820 | r59821 >
Date:05:18, 8 December 2009
Author:dale
Status:deferred
Tags:
Comment:
* improved libEmbedPlayer documentation
* unified getSrc and getURI to getSrc

* incomplete summary of changed function names:

doEmbedHTML() -> setupEmbedPlayer()
relatedTitleKeySearch() -> getRelatedFromTitleKey()
doThumbnailHTML() -> showThumbnail()
setSliderValue() -> updatePlayHead()
getNextPrevLinks() -> getNearbyClipLinks()
showNextPrevLinks -> showNearbyClipLinks()
refreshControlsHTML -> refreshControls()
getControlsHTML -> getControls()
getHTML -> showPlayer()
userSelectFormat -> setFormatPreference()
userSelectPlayer -> setPlayerPreference()

doSeekedCb() -> doSeekedCallback()

Unified playerElement:
getVID() -> getPlayerElement()
getVLC() -> getPlayerElement()
getKDP() -> getPlayerElement()

removed
-playlistSupport()
-relativeCurrentTime()
-mediaPlayer.loading_callbacks()
-nativeEmbed.onLoadedCallback -> to single callback
Modified paths:
  • /branches/js2-work/phase3/js2/js2stopgap.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/flowplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/genericEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/htmlEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/kplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/omtkEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/vlcEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/skins/kskin/kskin.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js2/js2stopgap.js
@@ -9510,4 +9510,4 @@
95119511 }
95129512
95139513 // Define a dummy mw.load() function
9514 -mw.load = function ( callback ) { callback() }
 9514+mw.load = function ( loadRequest, callback ) { callback() }
Index: branches/js2-work/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php
@@ -388,7 +388,7 @@
389389 'mwe-generic_missing_plugin' => 'You browser does not appear to support the following playback type: <b>$1</b><br />Visit the <a href="http://commons.wikimedia.org/wiki/Commons:Media_help">Playback Methods</a> page to download a player.<br />',
390390 'mwe-for_best_experience' => 'For a better video playback experience we recommend:<br /><b><a href="http://www.mozilla.com/en-US/firefox/upgrade.html?from=mwEmbed">Firefox 3.5</a>.</b>',
391391 'mwe-do_not_warn_again' => 'Dismiss for now.',
392 - 'mwe-playerselect' => 'Players',
 392+ 'mwe-playerSelect' => 'Players',
393393 'mwe-read_before_embed' => '<a href="http://mediawiki.org/wiki/Security_Notes_on_Remote_Embedding" target="_new">Read this</a> before embedding.',
394394 'mwe-embed_site_or_blog' => 'Embed on a page',
395395 'mwe-related_videos' => 'Related videos',
Index: branches/js2-work/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php
@@ -28,6 +28,7 @@
2929 global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory;
3030 if ( !isset( $jvar[1] ) )
3131 return false;
 32+
3233 $jClassSet = FormatJson::decode( '{' . $jvar[1] . '}', true );
3334 foreach ( $jClassSet as $jClass => $jPath ) {
3435 // Strip $ from jClass (as they are stripped on URL request parameter input)
Index: branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.js
@@ -220,9 +220,8 @@
221221 if ( embedObj.userSlide ) {
222222 embedObj.userSlide = false;
223223 embedObj.seeking = true;
224 - // stop the monitor timer (if we can)
225 - if ( embedObj.stopMonitor )
226 - embedObj.stopMonitor();
 224+ // Stop the monitor timer (if we can)
 225+ embedObj.stopMonitor();
227226
228227 var perc = ui.value / 1000;
229228 // set seek time (in case we have to do a url seek)
@@ -247,7 +246,7 @@
248247 // videoOptions ... @@todo should be merged with something more like kskin.js:
249248 $opt.find( '.vo_selection' ).click( function() {
250249 embedObj.displayHTML();
251 - embedObj.showPlayerselect( $target.find( '.videoOptionsComplete' ) );
 250+ embedObj.showPlayerSelect( $target.find( '.videoOptionsComplete' ) );
252251 $opt.hide();
253252 return false;
254253 } );
Index: branches/js2-work/phase3/js2/mwEmbed/skins/kskin/kskin.js
@@ -22,7 +22,7 @@
2323
2424 // Menu items for the kskin:
2525 menu_items:[
26 - 'playerselect',
 26+ 'playerSelect',
2727 'download',
2828 'share',
2929 'credits',
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js
@@ -85,22 +85,22 @@
8686
8787 // What tags will be re-written to video player by default
8888 // set to empty string or null to avoid automatic rewrites
89 - 'rewriteTags' : 'video,audio,playlist',
 89+ 'rewritePlayerTags' : 'video,audio,playlist',
9090
9191 /**
9292 * If jQuery / mwEmbed should always be loaded.
9393 *
9494 * mwEmbedSetup ignores this flag and is run if:
9595 * If your js calls mw.addOnloadHook ( callback_function )
96 - * If your page includes any tags set in config.rewriteTags
 96+ * If your page includes any tags set in config.rewritePlayerTags
9797 *
98 - * This flag increases page performace on pages that do not use mwEmbed
 98+ * This flag increases page performance on pages that do not use mwEmbed
9999 * and don't already load jQuery
100100 *
101101 * For examle when including the mwEmbed.js in your blog template
102102 * mwEmbed will only load extra js on blog posts that include the video tag.
103103 *
104 - * NOTE: Future articture will probably do away with this flag and refactor it into
 104+ * NOTE: Future architecture will probably do away with this flag and refactor it into
105105 * a smaller "remotePageMwEmbed.js" script similar to remoteMwEmbed.js in the js2 folder
106106 */
107107 'alwaysSetupMwEmbed' : false,
@@ -112,7 +112,10 @@
113113 'k_attribution' : true,
114114
115115 // The path of mvEmbed in mediaWiki folder
116 - 'mediaWikiPath' : 'js2/mwEmbed/'
 116+ 'mediaWikiPath' : 'js2/mwEmbed/',
 117+
 118+ //If we are in debug mode ( results in fresh debugg javascript includes )
 119+ 'debug' : false
117120 }
118121
119122
@@ -915,6 +918,7 @@
916919 // Make sure the class is not already defined:
917920 if ( $.isset( className ) ){
918921 js_log( 'Class ( ' + className + ' ) already defined ' );
 922+ callback();
919923 return ;
920924 }
921925
@@ -959,7 +963,7 @@
960964 * class name file path pairs.
961965 *
962966 * classSet must be strict JSON to allow the
963 - * scriptLoader to parse the file paths.
 967+ * php scriptLoader to parse the file paths.
964968 */
965969 addClassFilePaths: function( classSet ){
966970 for( var i in classSet ){
@@ -1074,12 +1078,13 @@
10751079 // Flag to ensure setup is only run once:
10761080 var mwSetupFlag = false;
10771081
1078 - $.setupMwEmbed = function ( ) {
1079 -
 1082+ $.setupMwEmbed = function ( ) {
10801083 // Only run the setup once:
10811084 if( mwSetupFlag )
10821085 return ;
10831086 mwSetupFlag = true;
 1087+
 1088+ js_log( 'mw:setupMwEmbed' );
10841089
10851090 // Make sure jQuery is loaded:
10861091 $.load( 'window.jQuery', function(){
@@ -1105,9 +1110,12 @@
11061111 mwDojQueryBindings();
11071112
11081113 // Check for tag-rewrites ( sometimes checked twice but ensures fresh dom check )
1109 - if( $.documentHasRewriteTags() ){
 1114+ if( $.documentHasPlayerTags() ){
11101115 // Load the embedPlayer module ( then run queued hooks )
1111 - ms.load( 'embedPlayer', function ( ) {
 1116+ mw.load( 'player', function ( ) {
 1117+ // Rewrite the rewritePlayerTags with the
 1118+ $j( $.getConfig( 'rewritePlayerTags' ) ).embedPlayer()
 1119+ // Run mw hooks:
11121120 mw.runLoadHooks();
11131121 } );
11141122 }else{
@@ -1116,8 +1124,10 @@
11171125 }
11181126 } );
11191127 }
 1128+
11201129 //Flag to register the domReady has been called
11211130 var mwDomReadyFlag = false;
 1131+
11221132 /**
11231133 * This will get called when the DOM is ready
11241134 * Will check configuration and issue a mw.setupMwEmbed call if needed
@@ -1136,7 +1146,7 @@
11371147 }
11381148
11391149 // Check for rewrite tags:
1140 - if ( $.documentHasRewriteTags() ) {
 1150+ if ( $.documentHasPlayerTags() ) {
11411151 $.setupMwEmbed();
11421152 return ;
11431153 }
@@ -1165,29 +1175,37 @@
11661176 }
11671177
11681178 /**
1169 - * Check the current DOM for any tags in "rewriteTags"
 1179+ * Check the current DOM for any tags in "rewritePlayerTags"
11701180 */
1171 - $.documentHasRewriteTags = function(){
1172 - var tags = $.getRewriteTags();
1173 - return ( tags && tags.length );
 1181+ $.documentHasPlayerTags = function(){
 1182+ var tagElm = $.getPlayerTagElements( true );
 1183+ if( tagElm && tagElm.length )
 1184+ return true;
 1185+ return false;
11741186 }
1175 - $.getRewriteTags = function(){
1176 - var tagString = $.getConfig( 'rewriteTags' );
 1187+ /**
 1188+ * Gets page elements that match the rewritePlayerTags config
 1189+ *
 1190+ * @param {Boolean} getOne Flag to retive only one tag ( faster for simple has tag checks )
 1191+ */
 1192+ $.getPlayerTagElements = function( getOne ){
 1193+ var tagString = $.getConfig( 'rewritePlayerTags' );
11771194 if( ! tagString || tagString == '' )
11781195 return false;
11791196
11801197 // Tags should be separated by ","
11811198 var tags = tagString.split(',');
1182 -
 1199+ var tagsInDOM = [ ];
11831200 // Check for tags:
11841201 for( var i in tags ){
1185 - var tagsInDOM = document.getElementsByTagName( tags[ i ] );
1186 - // If tags found return true
1187 - if( tagsInDOM.length > 0 ){
1188 - return true;
 1202+ var tagElements = document.getElementsByTagName( tags[ i ] );
 1203+ for(var j = 0; j < tagElements.length; j++ ){
 1204+ tagsInDOM.push( tagElements[ j ] );
 1205+ if( getOne )
 1206+ return tagsInDOM;
11891207 }
1190 - }
1191 - return false;
 1208+ }
 1209+ return tagsInDOM;
11921210 }
11931211
11941212 /**
@@ -1199,16 +1217,22 @@
12001218 * @param {Function} callback Function to call once script is loaded
12011219 */
12021220 $.getScript = function( url, callback ){
 1221+ // Add on the request paramaters to the url:
 1222+ url += ( url.indexOf( '?' ) === -1 )? '?' : '&';
12031223
 1224+ // Get url Param also updates the "debug" var
 1225+ url += $.getUrlParam();
 1226+
12041227 js_log( 'mw.getScript: ' + url );
12051228
1206 - // If jQuery is available just use getScript
1207 - if( $.isset( 'window.jQuery' ) ) {
 1229+ // If jQuery is available and debug is off get the scirpt j
 1230+ if( $.isset( 'window.jQuery' ) && $.getConfig( 'debug' ) === false ) {
12081231 $j.getScript( url, callback );
12091232 return ;
12101233 }
12111234
1212 - // No jQuery load and bind manually: ( copied from jQuery ajax function )
 1235+ // No jQuery or we want a script instead of XHR eval for debugging
 1236+ // Load and bind manually: ( copied from jQuery ajax function )
12131237 var head = document.getElementsByTagName("head")[0];
12141238 var script = document.createElement("script");
12151239 script.setAttribute( 'src', url );
@@ -1257,7 +1281,7 @@
12581282 // Check for scriptLoader include of mwEmbed:
12591283 if ( src.indexOf( 'mwScriptLoader.php' ) !== -1 ) {
12601284 // Script loader is in the root of MediaWiki, Include the default mwEmbed extension path:
1261 - mwpath = src.substr( 0, src.indexOf( 'mwScriptLoader.php' ) ) + $.conf.mediaWikiPath;
 1285+ mwpath = src.substr( 0, src.indexOf( 'mwScriptLoader.php' ) ) + $.getConfig( 'mediaWikiPath' );
12621286 }
12631287
12641288 // Script-loader has jsScriptLoader name when local:
@@ -1309,7 +1333,7 @@
13101334 var mwUrlParam = null;
13111335
13121336 /**
1313 - * Get URL Paramaters per paramaters in the host script include
 1337+ * Get URL Parameters per parameters in the host script include
13141338 */
13151339 $.getUrlParam = function() {
13161340 if ( mwUrlParam )
@@ -1323,7 +1347,7 @@
13241348
13251349 // If we're in debug mode, get a fresh unique request key and pass on "debug" param
13261350 if ( mw.parseUri( mwEmbedSrc ).queryKey['debug'] == 'true' ) {
1327 -
 1351+ $.setConfig( 'debug', true );
13281352 var d = new Date();
13291353 req_param += 'urid=' + d.getTime() + '&debug=true';
13301354
@@ -1335,7 +1359,7 @@
13361360 req_param += 'urid=' + mw.version;
13371361 }
13381362
1339 - // Add the language param:
 1363+ // Add the language param if present:
13401364 var langKey = mw.parseUri( mwEmbedSrc ).queryKey['uselang'];
13411365 if ( langKey )
13421366 req_param += '&uselang=' + langKey;
@@ -1545,17 +1569,16 @@
15461570 } );
15471571
15481572 /**
1549 -* libEmbedPlayer Depenency Module Loader:
 1573+* libEmbedPlayer Dependency Module Loader:
15501574 *
15511575 * NOTE: this code block could eventually be put in:
15521576 * "libEmbedPlayer/loader.js"
15531577 *
1554 -* That it could be dynamically inserted into mwEmbed requests
1555 -* at poit of release or at runtime via the script-loader.
 1578+* Then it could be dynamically inserted into mwEmbed requests
 1579+* at point of release or at runtime via the script-loader.
15561580 *
1557 -* A per module loader enables a dynamic set of modules with only minimal
 1581+* Per module loader enables a dynamic set of modules with only minimal
15581582 * loader code per module in the core mwEmbed included js
1559 -*
15601583 */
15611584 // Add class file paths:
15621585 mw.addClassFilePaths( {
@@ -1567,16 +1590,15 @@
15681591 "javaEmbed" : "libEmbedPlayer/javaEmbed.js",
15691592 "nativeEmbed" : "libEmbedPlayer/nativeEmbed.js",
15701593 "quicktimeEmbed" : "libEmbedPlayer/quicktimeEmbed.js",
1571 - "vlcEmbed" : "libEmbedPlayer/vlcEmbed.js",
 1594+ "vlcEmbed" : "libEmbedPlayer/vlcEmbed.js"
15721595
15731596 } );
1574 -
15751597 // Add the module loader function:
1576 -mw.addModuleLoader( 'player', function(){
 1598+mw.addModuleLoader( 'player', function( callback ){
15771599 var _this = this;
15781600 js_log( 'loadModule: player :' );
15791601
1580 - // Set module specifc class videonojs to loading:
 1602+ // Set module specific class videonojs to loading:
15811603 $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) );
15821604
15831605 // Set up the embed video player class request: (include the skin js as well)
@@ -1594,43 +1616,47 @@
15951617
15961618 // Get any other skins that we need to load
15971619 // That way skin js can be part of the single script-loader request:
1598 -
1599 - var sn = e[j][k].getAttribute('class');
1600 - if( sn && sn != ''){
1601 - for(var n=0;n< $mw.valid_skins.length;n++){
1602 - if( sn.indexOf($mw.valid_skins[n]) !== -1){
1603 - $mw.skin_list.push( $mw.valid_skins[n] );
1604 - }
 1620+ var playerElements = mw.getPlayerTagElements();
 1621+ $j.each( playerElements, function(na, playerElem ){
 1622+ var cName = $j( playerElem ).attr( 'class' );
 1623+ for( var n=0; n < mw.valid_skins.length ; n++ ){
 1624+ if( cName.indexOf( mw.valid_skins[ n ] ) !== -1){
 1625+ mw.skin_list.push( mw.valid_skins[n] );
16051626 }
1606 - }
1607 - // Add any requested skins (supports multiple skins per single page)
 1627+ }
 1628+ } );
 1629+
 1630+ // Add any page specific requested skins js ( supports multiple skins per single page )
16081631 if ( mw.skin_list ) {
16091632 for ( var i in mw.skin_list ) {
1610 - depReq[0].push( mw.skin_list[i] + 'Config' );
 1633+ dependencyRequest[0].push( mw.skin_list[i] + 'Config' );
16111634 }
16121635 }
16131636
16141637 // Add PNG fix if needed:
16151638 if ( $j.browser.msie || $j.browser.version < 7 )
1616 - depReq[0].push( '$j.fn.pngFix' );
 1639+ dependencyRequest[0].push( '$j.fn.pngFix' );
16171640
16181641 // Load the video libs:
1619 - _this.doLoadDepMode( depReq, function() {
 1642+ mw.load( dependencyRequest, function() {
 1643+
 1644+ // Detect what players are supported:
16201645 embedTypes.init();
1621 - callback();
 1646+
 1647+ // Remove no video html elements:
16221648 $j( '.videonojs' ).remove();
 1649+
 1650+ //Run the callback
 1651+ callback();
16231652 } );
16241653
1625 -} );
 1654+} ); // done with embedPlayer loader.js
16261655
16271656
16281657
16291658
16301659
16311660
1632 -
1633 -
1634 -
16351661 // Add the core mvEmbed Messages ( will be localized by script server )
16361662 mw.addMessages( {
16371663 "mwe-loading_txt" : "Loading ...",
@@ -1675,17 +1701,6 @@
16761702
16771703
16781704
1679 -
1680 -
1681 -
1682 -
1683 -
1684 -
1685 -
1686 -
1687 -
1688 -
1689 -
16901705 // Get the loading image
16911706 function mv_get_loading_img( style, class_attr ) {
16921707 var style_txt = ( style ) ? style:'';
@@ -2292,6 +2307,9 @@
22932308 $.addDialog( msg_txt, msg_txt + '<br>' + mv_get_loading_img() );
22942309 }
22952310
 2311+ /**
 2312+ * shortcut jquery binding to add a dialog window:
 2313+ */
22962314 $.addDialog = function ( title, msg_txt, btn ) {
22972315 $( '#mwe_tmp_loader' ).remove();
22982316 // append the style free loader ontop:
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html
@@ -2,8 +2,8 @@
33 <html><head>
44 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
55 <title>Firefogg - Make Ogg Video in your Browser</title>
6 - <script type="text/javascript" src="../jsScriptLoader.php?urid=r58125&class=mwEmbed,window.jQuery,mvBaseUploadInterface,mvFirefogg,mvAdvFirefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.cookie,$j.ui.accordion,$j.ui.slider,$j.ui.datepicker,$j.ui.draggable"></script>
7 - <!-- <script type="text/javascript" src="../mwEmbed.js"></script> -->
 6+ <!-- <script type="text/javascript" src="../jsScriptLoader.php?urid=r58125&class=mwEmbed,window.jQuery,mvBaseUploadInterface,mvFirefogg,mvAdvFirefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.cookie,$j.ui.accordion,$j.ui.slider,$j.ui.datepicker,$j.ui.draggable"></script> -->
 7+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
88 <style type="text/css" media="all">body {
99 margin: 0;
1010 padding: 0;
@@ -66,10 +66,10 @@
6767 }
6868 </style>
6969 <script type="text/javascript">
70 -mwAddOnloadHook(function(){
 70+mw.addOnloadHook(function(){
7171 $j('#firefogg_app').firefogg({
72 - 'encoder_interface' : true,
73 - 'encode_local' : true
 72+ 'encoder_interface' : true,
 73+ 'encode_local' : true
7474 },function(){
7575 $j('#loadFogg').hide();
7676 });
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js
@@ -154,7 +154,7 @@
155155 if ( !source ) {
156156 js_error( 'Error::could not find source: ' + resource.pSobj.provider.stream_import_key );
157157 } else {
158 - resource['src'] = source.getURI();
 158+ resource['src'] = source.getSrc();
159159 js_log( "g src_key: " + resource.pSobj.provider.stream_import_key + ' src:' + resource['src'] ) ;
160160 return true;
161161 }
@@ -190,9 +190,9 @@
191191 resource.other_versions = '*[' + resource['roe_url'] + ' XML of all Video Formats and Timed Text]' + "\n";
192192 for ( var i in sources ) {
193193 var cur_source = sources[i];
194 - // resource.other_versions += '*['+cur_source.getURI() +' ' + cur_source.title +']' + "\n";
 194+ // resource.other_versions += '*['+cur_source.getSrc() +' ' + cur_source.title +']' + "\n";
195195 if ( cur_source.id == this.provider.target_source_id )
196 - resource['url'] = cur_source.getURI();
 196+ resource['url'] = cur_source.getSrc();
197197 }
198198 // js_log('set url to: ' + resource['url']);
199199 return resource;
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js
@@ -724,8 +724,10 @@
725725 */
726726 getEncoderSettings: function() {
727727 if ( this.current_encoder_settings == null ) {
 728+
728729 // Clone the default settings
729 - var settings = $j.extend( { }, this.default_encoder_settings) ;
 730+ var settings = $j.extend( { }, this.default_encoder_settings) ;
 731+
730732 // Grab the extension
731733 var sf = this.fogg.sourceFilename;
732734 if ( !sf ) {
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js
@@ -1,4 +1,4 @@
2 -/*
 2+/**
33 * embedPlayer is the base class for html5 video tag javascript abstraction library
44 * embedPlayer include a few subclasses:
55 *
@@ -53,7 +53,7 @@
5454 "mwe-generic_missing_plugin" : "You browser does not appear to support the following playback type: <b>$1<\/b><br \/>Visit the <a href=\"http:\/\/commons.wikimedia.org\/wiki\/Commons:Media_help\">Playback Methods<\/a> page to download a player.<br \/>",
5555 "mwe-for_best_experience" : "For a better video playback experience we recommend:<br \/><b><a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/upgrade.html?from=mwEmbed\">Firefox 3.5<\/a>.<\/b>",
5656 "mwe-do_not_warn_again" : "Dismiss for now.",
57 - "mwe-playerselect" : "Players",
 57+ "mwe-playerSelect" : "Players",
5858 "mwe-read_before_embed" : "<a href=\"http:\/\/mediawiki.org\/wiki\/Security_Notes_on_Remote_Embedding\" target=\"_new\">Read this<\/a> before embedding.",
5959 "mwe-embed_site_or_blog" : "Embed on a page",
6060 "mwe-related_videos" : "Related videos",
@@ -343,7 +343,9 @@
344344 // Make sure we have the necessary playlist libs loaded:
345345 mw.load( [
346346 'mvPlayList',
347 - '$j.ui', // Include dialog for pop-ing up things
 347+
 348+ // Include dialog:
 349+ '$j.ui',
348350 '$j.ui.dialog'
349351 ], function() {
350352 // Create playlist player interface
@@ -596,7 +598,7 @@
597599 * @param {Number} seek_time_sec Int: Used to adjust the URI for url based seeks)
598600 * @return {String} the URI of the source.
599601 */
600 - getURI : function( seek_time_sec ) {
 602+ getSrc : function( seek_time_sec ) {
601603 if ( !seek_time_sec || !this.URLTimeEncoding ) {
602604 return this.src;
603605 }
@@ -762,7 +764,7 @@
763765
764766 if ( $j( video_element ).attr( 'durationHint' ) ) {
765767 this.durationHint = $j( video_element ).attr( 'durationHint' );
766 - // convert duration hint if needed:
 768+ // Convert duration hint if needed:
767769 this.duration = npt2seconds( this.durationHint );
768770 }
769771
@@ -839,15 +841,14 @@
840842 *
841843 * @param {Number} index Index of source element to set as selected_source
842844 */
843 - selectSource:function( index )
844 - {
 845+ selectSource:function( index ) {
845846 js_log( 'f:selectSource:' + index );
846847 var playable_sources = this.getPlayableSources();
847848 for ( var i = 0; i < playable_sources.length; i++ ) {
848849 if ( i == index ) {
849850 this.selected_source = playable_sources[i];
850851 // Update the user selected format:
851 - embedTypes.players.userSelectFormat( playable_sources[i].mime_type );
 852+ embedTypes.players.setFormatPreference( playable_sources[i].mime_type );
852853 break;
853854 }
854855 }
@@ -870,7 +871,7 @@
871872 return true;
872873 }
873874 // Set via user-preference
874 - if ( embedTypes.players.preference['format_prefrence'] == mime_type ) {
 875+ if ( embedTypes.players.preference['format_preference'] == mime_type ) {
875876 js_log( 'set via preference: ' + playable_sources[source].mime_type );
876877 this.selected_source = playable_sources[source];
877878 return true;
@@ -926,8 +927,7 @@
927928 * Returns the thumbnail URL for the media element.
928929 * @returns {String} thumbnail URL
929930 */
930 - getThumbnailURL:function()
931 - {
 931+ getThumbnailURL: function( ) {
932932 return this.thumbnail;
933933 },
934934
@@ -963,15 +963,14 @@
964964 * the element has a 'src' attribute.
965965 * @param {Element} element <video>, <source> or <mediaSource> <text> element.
966966 */
967 - tryAddSource:function( element )
968 - {
 967+ tryAddSource: function( element ) {
969968 js_log( 'f:tryAddSource:' + $j( element ).attr( "src" ) );
970969 if ( $j( element ).attr( "src" ) ) {
971970 var new_src = $j( element ).attr( 'src' );
972971 // make sure an existing element with the same src does not already exist:
973972 for ( var i = 0; i < this.sources.length; i++ ) {
974973 if ( this.sources[i].src == new_src ) {
975 - // js_log('checking existing: '+this.sources[i].getURI() + ' != '+ new_src);
 974+ // js_log('checking existing: '+this.sources[i].getSrc() + ' != '+ new_src);
976975 // can't add it all but try to update any additional attr:
977976 this.sources[i].updateSource( element );
978977 }
@@ -985,9 +984,8 @@
986985 if ( !source.startOffset && this.startOffset )
987986 source.startOffset = this.startOffset;
988987
989 -
990 - this.sources.push( source );
991988 js_log( 'pushed source to stack' + source + 'sl:' + this.sources.length );
 989+ this.sources.push( source );
992990 },
993991
994992 /**
@@ -1097,6 +1095,9 @@
10981096 // Percent of the clip buffered:
10991097 'bufferedPercent' : 0,
11001098
 1099+ // Holds the timmer interval function
 1100+ 'monitorTimerId' : null,
 1101+
11011102 /**
11021103 * embedPlayer constructor
11031104 *
@@ -1176,18 +1177,23 @@
11771178
11781179 /**
11791180 * Set width or height from css style attribute, html element attribute, or by default value
 1181+ * @param {Element} element Source element to grab size from
 1182+ * @param {String} dimension "height" or "width"
11801183 */
1181 - setDimSize:function( element, dim ){
1182 - var dcss = parseInt( $j(element).css( dim ).replace( 'px' , '' ) );
1183 - var dattr = parseInt( $j(element).attr( dim ) );
1184 - this[ dim ] = ( dcss )? dcss : dattr;
1185 - if( !this[ dim ] ){
 1184+ setDimSize:function( element, dimension ){
 1185+ var dcss = parseInt( $j(element).css( dimension ).replace( 'px' , '' ) );
 1186+ var dattr = parseInt( $j(element).attr( dimension ) );
 1187+
 1188+ this[ dimension ] = ( dcss )? dcss : dattr;
 1189+
 1190+ // On load sometimes attr is temporarlly -1
 1191+ if( ! this[ dimension ] || this[ dimension ] == -1 ){
11861192 //special height default for audio tag:
1187 - if( element.tagName.toLowerCase() == 'audio' && dim == 'height' )
1188 - return this[ dim ] = 0;
 1193+ if( element.tagName.toLowerCase() == 'audio' && dimension == 'height' )
 1194+ return this[ dimension ] = 0;
11891195 // Grab width/height from default value (for video)
11901196 var dwh = mw.getConfig( 'video_size' ).split( 'x' );
1191 - this[ dim ] = ( dim == 'width' )? dwh[0] : dwh[1];
 1197+ this[ dimension ] = ( dimension == 'width' )? dwh[0] : dwh[1];
11921198 }
11931199 },
11941200
@@ -1315,8 +1321,7 @@
13161322 var _this = this;
13171323
13181324 // Load the selected player
1319 - this.selected_player.load( function() {
1320 -
 1325+ this.selected_player.load( function() {
13211326 // Get the selected Player embed interface
13221327 eval( 'var embedPlayer = ' + _this.selected_player.library + 'Embed;' );
13231328
@@ -1325,13 +1330,13 @@
13261331 _this['parent_' + method] = _this[method];
13271332 _this[method] = embedPlayer[method];
13281333 }
1329 -
 1334+
13301335 _this.ready_to_play = true;
13311336 _this.getDuration();
1332 - _this.getHTML();
 1337+ _this.showPlayer();
13331338
13341339 // Run the callback if provided
1335 - if ( callback )
 1340+ if ( typeof callback == 'function' )
13361341 callback();
13371342 } );
13381343 },
@@ -1342,13 +1347,13 @@
13431348 * @param {Object} player Player playback system to be selected
13441349 * player playback system include vlc, native, java etc.
13451350 */
1346 - selectPlayer:function( player ) {
 1351+ selectPlayer: function( player ) {
13471352 var _this = this;
13481353 if ( this.selected_player.id != player.id ) {
13491354 this.selected_player = player;
13501355 this.inheritEmbedPlayer( function(){
13511356 // Update the controls for the new selected player
1352 - this.refreshControlsHTML();
 1357+ this.refreshControls();
13531358 });
13541359 }
13551360 },
@@ -1357,7 +1362,7 @@
13581363 * Issue a warning to non-native playback systems
13591364 * that they could improve the playback experience with a different browser
13601365 */
1361 - doNativeWarningCheck:function() {
 1366+ doNativeWarningCheck: function( ) {
13621367 if ( $j.cookie( 'dismissNativeWarn' ) && $j.cookie( 'dismissNativeWarn' ) === true ) {
13631368 return false;
13641369 }
@@ -1443,7 +1448,7 @@
14441449 return 'Error: function getEmbedHTML should be implemented by embed player interface ';
14451450 },
14461451
1447 - /*
 1452+ /**
14481453 * Seek function (should be implemented by embed player interface )
14491454 */
14501455 doSeek : function( percent ) {
@@ -1455,13 +1460,14 @@
14561461 this.stop();
14571462 this.didSeekJump = true;
14581463 // Update the slider
1459 - this.setSliderValue( percent );
 1464+ this.updatePlayHead( percent );
14601465 }
14611466 // Do play request in 100ms ( give the dom time to swap out the embed player )
14621467 setTimeout( function(){
14631468 _this.play()
14641469 }, 100 );
14651470 },
 1471+
14661472 /**
14671473 * Seeks to the requested time and issues a callback when ready
14681474 * (should be overwritten by client that supports frame serving)
@@ -1470,27 +1476,33 @@
14711477 js_log( 'Error: base embed setCurrentTime can not frame serve (override via plugin)' );
14721478 },
14731479
1474 - doEmbedHTML:function() {
1475 - js_log( 'f:doEmbedHTML' );
 1480+ /**
 1481+ * Setup the embed player
 1482+ * issues a loading request
 1483+ */
 1484+ setupEmbedPlayer:function() {
 1485+ js_log( 'f:setupEmbedPlayer' );
14761486 js_log( 'thum disp:' + this.thumbnail_disp );
1477 - var _this = this;
1478 - this.closeDisplayedHTML();
 1487+ var _this = this;
14791488
1480 - // Set "loading" here
 1489+ // Set "loading" here:
14811490 $j( '#mv_embedded_player_' + _this.id ).html( '' +
14821491 '<div style="color:black;width:' + this.width + 'px;height:' + this.height + 'px;">' +
14831492 gM( 'mwe-loading_plugin' ) +
14841493 '</div>'
14851494 );
1486 - // Schedule embedding after player library is loaded:
1487 - this.selected_player.load( function() {
1488 - js_log( 'performing embed for ' + _this.id );
1489 - var embed_code = _this.getEmbedHTML();
1490 - // js_log('shopuld embed:' + embed_code);
1491 - $j( '#mv_embedded_player_' + _this.id ).html( embed_code );
1492 - } );
 1495+
 1496+ // Make sure the player is
 1497+ js_log( 'performing embed for ' + _this.id );
 1498+ var embed_code = _this.getEmbedHTML();
 1499+ // js_log('shopuld embed:' + embed_code);
 1500+ $j( '#mv_embedded_player_' + _this.id ).html( embed_code );
14931501 },
1494 - relatedTitleKeySearch:function() {
 1502+
 1503+ /**
 1504+ * Searches for related clipes from titleKey
 1505+ */
 1506+ getRelatedFromTitleKey:function() {
14951507 var _this = this;
14961508 var reqObj = {
14971509 'action' : 'query',
@@ -1511,20 +1523,26 @@
15121524 }
15131525 _this.getRelatedFromCat( req_categories );
15141526 } else {
1515 - _this.doThumbnailHTML();
 1527+ _this.showThumbnail();
15161528 }
15171529 } );
15181530 },
1519 - getRelatedFromCat:function( catAry ) {
 1531+
 1532+ /**
 1533+ * Get Related Clips from a category list
 1534+ *
 1535+ * @parma {Object} catlist List of categories
 1536+ */
 1537+ getRelatedFromCat:function( catlist ) {
15201538 js_log( 'getRelatedFromCat' );
15211539 var _this = this;
1522 - for ( var i = 0 ; i <= catAry.length ; i++ ) {
1523 - if ( !catAry[i] )
 1540+ for ( var i = 0 ; i <= catlist.length ; i++ ) {
 1541+ if ( !catlist[i] )
15241542 continue;
15251543 var reqObj = {
15261544 'action' : 'query',
15271545 'generator' : 'categorymembers' ,
1528 - 'gcmtitle' : catAry[i],
 1546+ 'gcmtitle' : catlist[i],
15291547 'prop' : 'imageinfo',
15301548 'iiprop' : 'url',
15311549 'iiurlwidth': '80'
@@ -1563,12 +1581,16 @@
15641582 } ); // end do_api_req
15651583 };
15661584 },
 1585+
 1586+ /**
 1587+ * On clip done action. Called once a clip is done playing
 1588+ */
15671589 onClipDone:function() {
15681590 js_log( 'base:onClipDone' );
15691591 // stop the clip (load the thumbnail etc)
15701592 this.stop();
15711593 this.seek_time_sec = 0;
1572 - this.setSliderValue( 0 );
 1594+ this.updatePlayHead( 0 );
15731595 var _this = this;
15741596
15751597 if ( this.width < 300 ) {
@@ -1599,12 +1621,17 @@
16001622 '</div>' );
16011623 $j( '#img_thumb_' + this.id ).fadeOut( "fast" );
16021624 $j( '#dc_' + _this.id + ' .related_vids ul' ).html( gM( 'mwe-loading_txt' ) );
1603 - this.relatedTitleKeySearch();
 1625+ this.getRelatedFromTitleKey();
16041626 } else {
1605 - this.onClipDoneDisp();
 1627+ this.showNearbyClips();
16061628 }
16071629 },
1608 - onClipDoneDisp:function() {
 1630+
 1631+ /**
 1632+ * Shows nearby clips based on "roe" xml
 1633+ * Mostly metavid specific ( should be factored into a seperate module )
 1634+ */
 1635+ showNearbyClips: function() {
16091636 var _this = this;
16101637 // add the liks_info_div black back
16111638 $j( '#dc_' + this.id ).append( '<div id="liks_info_' + this.id + '" ' +
@@ -1638,11 +1665,15 @@
16391666 _this.getNextPrevLinks();
16401667 } );
16411668 } else {
1642 - this.getNextPrevLinks();
 1669+ this.getNearbyClipLinks();
16431670 }
16441671 },
1645 - // @@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them.
1646 - getNextPrevLinks:function() {
 1672+
 1673+ /**
 1674+ * Gets nearby Clip links
 1675+ * Mostly metavid specific ( should be factored into a seperate module )
 1676+ */
 1677+ getNearbyClipLinks:function() {
16471678 js_log( 'f:getNextPrevLinks' );
16481679 var anno_track_url = null;
16491680 var _this = this;
@@ -1658,7 +1689,7 @@
16591690 if ( !anno_track_url ) {
16601691 js_log( 'no annotative track url found' );
16611692 // $j('#liks_info_'+this.id).html('no metadata found for related links');
1662 - _this.doThumbnailHTML();
 1693+ _this.showThumbnail();
16631694 return ;
16641695 }
16651696
@@ -1717,7 +1748,12 @@
17181749 }
17191750 // query current request time +|- 60s to get prev next speech links.
17201751 },
1721 - showNextPrevLinks:function() {
 1752+
 1753+ /**
 1754+ * Display the nearby clip links
 1755+ * Mostly metavid specific ( should be factored into a seperate module )
 1756+ */
 1757+ showNearbyClipLinks:function() {
17221758 // js_log('f:showNextPrevLinks');
17231759 // int requested links:
17241760 var link = {
@@ -1776,8 +1812,7 @@
17771813 if ( regTimeCheck.test( this.media_element.linkback ) ) {
17781814 html += ' href="' + this.media_element.linkback.replace( regTimeCheck, time_req ) + '" ';
17791815 } else {
1780 - html += ' href="#" onClick="$j(\'#' + this.id + '\').get(0).playByTimeReq(\'' +
1781 - time_req + '\'); return false; "';
 1816+ html += ' href="#" class="playtimerequest" ';
17821817 }
17831818 html += ' title="' + title_msg + '">' +
17841819 gM( 'mwe-' + link_type + '_clip_msg' ) +
@@ -1786,38 +1821,59 @@
17871822 }
17881823 }
17891824 // js_og("should set html:"+ html);
1790 - $j( '#liks_info_' + this.id ).html( html );
 1825+ $j( '#liks_info_' + this.id )
 1826+ .html( html )
 1827+ //Do bindings:
 1828+ .children( '.playtimerequest' )
 1829+ .click( function(){
 1830+ _this.stop();
 1831+ _this.updateVideoTimeReq( time_req );
 1832+ _this.play();
 1833+ } );
 1834+
17911835 },
1792 - playByTimeReq: function( time_req ) {
1793 - js_log( 'f:playByTimeReq: ' + time_req );
1794 - this.stop();
1795 - this.updateVideoTimeReq( time_req );
1796 - this.play();
1797 - },
1798 - doThumbnailHTML:function() {
 1836+
 1837+ /**
 1838+ * Shows the video Thumbnail, updates pause state
 1839+ */
 1840+ showThumbnail: function() {
17991841 var _this = this;
1800 - js_log( 'f:doThumbnailHTML' + this.thumbnail_disp );
 1842+ js_log( 'f:showThumbnail' + this.thumbnail_disp );
18011843 this.closeDisplayedHTML();
18021844 $j( '#mv_embedded_player_' + this.id ).html( this.getThumbnailHTML() );
18031845 this.paused = true;
18041846 this.thumbnail_disp = true;
1805 - // make sure the ctrlBuilder remain active:
 1847+ // Make sure the ctrlBuilder bindings are up-to-date
18061848 this.ctrlBuilder.addControlHooks();
18071849 },
1808 - refreshControlsHTML:function() {
 1850+
 1851+ /**
 1852+ * Refresh the player Controls
 1853+ * Usefull for updating for when new playback system is selected
 1854+ */
 1855+ refreshControls:function() {
18091856 if ( $j( '#' + this.id + ' .control-bar' ).length == 0 ) {
1810 - js_log( 'refreshControlsHTML::control-bar not present, no refresh' );
 1857+ js_log( 'refreshControls::control-bar not present, no refresh' );
18111858 return ;
18121859 }
18131860 // Do update controls:
1814 - $j( '#' + this.id + ' .control-bar' ).html( this.getControlsHTML() );
 1861+ $j( '#' + this.id + ' .control-bar' ).html( this.getControls() );
18151862 this.ctrlBuilder.addControlHooks();
18161863
18171864 },
1818 - getControlsHTML:function() {
 1865+
 1866+ /**
 1867+ * Maps the getControls request to the ctrl Builder
 1868+ * requires this.ctrlBuilder to be setup
 1869+ */
 1870+ getControls: function() {
18191871 return this.ctrlBuilder.getControls( this );
18201872 },
1821 - getHTML : function () {
 1873+
 1874+ /**
 1875+ *
 1876+ */
 1877+ showPlayer : function () {
18221878 // set-up the local ctrlBuilder instance:
18231879 this.ctrlBuilder = new ctrlBuilder( this );
18241880
@@ -1828,12 +1884,11 @@
18291885 html_code += '<div style="width:' + parseInt( this.width ) + 'px;height:' + parseInt( this.height ) + 'px;" id="mv_embedded_player_' + this.id + '">' +
18301886 this.getThumbnailHTML() +
18311887 '</div>';
1832 -
1833 - // js_log("mvEmbed:controls "+ typeof this.controls);
 1888+
18341889 if ( this.controls ) {
1835 - js_log( "f:getHTML:AddControls" );
 1890+ js_log( "f:showPlayer:AddControls" );
18361891 html_code += '<div class="ui-state-default ui-widget-header ui-helper-clearfix control-bar" >';
1837 - html_code += this.getControlsHTML();
 1892+ html_code += this.getControls();
18381893 html_code += '</div>';
18391894 // block out some space by encapsulating the top level div
18401895 $j( this ).wrap( '<div style="width:' + parseInt( this.width ) + 'px;height:'
@@ -1850,7 +1905,7 @@
18511906
18521907
18531908 if ( this.autoplay ) {
1854 - js_log( 'getHTML::activating autoplay' );
 1909+ js_log( 'showPlayer::activating autoplay' );
18551910 this.play();
18561911 }
18571912 },
@@ -1889,7 +1944,7 @@
18901945 this.setStatus( start_npt + '/' + end_npt );
18911946
18921947 // reset slider
1893 - this.setSliderValue( 0 );
 1948+ this.updatePlayHead( 0 );
18941949
18951950 // reset seek_offset:
18961951 if ( this.media_element.selected_source.URLTimeEncoding )
@@ -2204,14 +2259,19 @@
22052260 * Close the custom HTML displayed using displayHTML and restores the
22062261 * regular mwEmbed display.
22072262 */
2208 - closeDisplayedHTML:function() {
 2263+ closeDisplayedHTML: function() {
22092264 var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id;
22102265 $j( '#blackbg_' + sel_id ).fadeOut( "slow", function() {
22112266 $j( '#blackbg_' + sel_id ).remove();
22122267 } );
22132268 return false; // onclick action return false
22142269 },
2215 - showPlayerselect:function( $target ) {
 2270+
 2271+ /**
 2272+ * Shows the Player Select interface
 2273+ * @param {Object} $target jQuery target to output to
 2274+ */
 2275+ showPlayerSelect: function( $target ) {
22162276 // Get id (in case where we have a parent container)
22172277 var this_id = ( this.pc != null ) ? this.pc.pp.id:this.id;
22182278 var _this = this;
@@ -2263,7 +2323,7 @@
22642324 $j( '#' + this_id ).get( 0 ).closeDisplayedHTML();
22652325 $j( '#' + _this.id ).get( 0 ).media_element.selectSource( source_id );
22662326
2267 - embedTypes.players.userSelectPlayer( default_player_id,
 2327+ embedTypes.players.setPlayerPreference( default_player_id,
22682328 _this.media_element.sources[ source_id ].getMIMEType() );
22692329
22702330 // Issue a stop
@@ -2274,6 +2334,11 @@
22752335 } );
22762336 } );
22772337 },
 2338+
 2339+ /**
 2340+ * Shows the download interface
 2341+ * @param {Object} $target jQuery target to output to
 2342+ */
22782343 showDownload:function( $target ) {
22792344 var _this = this;
22802345 // Load the roe if available (to populate out download options:
@@ -2282,9 +2347,9 @@
22832348 var dl_list = '';
22842349 var dl_txt_list = '';
22852350 $j.each( _this.media_element.getSources(), function( index, source ) {
2286 - var dl_line = '<li>' + '<a style="color:white" href="' + source.getURI() + '"> '
 2351+ var dl_line = '<li>' + '<a style="color:white" href="' + source.getSrc() + '"> '
22872352 + source.getTitle() + '</a> ' + '</li>' + "\n";
2288 - if ( source.getURI().indexOf( '?t=' ) !== -1 ) {
 2353+ if ( source.getSrc().indexOf( '?t=' ) !== -1 ) {
22892354 out += dl_line;
22902355 } else if ( this.getMIMEType() == "text/cmml" || this.getMIMEType() == "text/x-srt" ) {
22912356 dl_txt_list += dl_line;
@@ -2312,10 +2377,19 @@
23132378 $target.html( getShowVideoDownload() );
23142379 }
23152380 },
2316 - /*
2317 - * Base embed controls
2318 - * The Play Action:
 2381+
 2382+ /**
 2383+ * Base Embed Controls
23192384 */
 2385+
 2386+ /**
 2387+ * The Play Action
 2388+ *
 2389+ * Handles play requests, updates relevet states:
 2390+ * seeking =false
 2391+ * paused = false
 2392+ * Updates pause button
 2393+ */
23202394 play : function() {
23212395 var eid = ( this.pc != null ) ? this.pc.pp.id:this.id;
23222396
@@ -2326,7 +2400,7 @@
23272401 // this.innerHTML = this.getPluginMissingHTML();
23282402 $j( '#' + this.id ).html( this.getPluginMissingHTML() );
23292403 } else {
2330 - this.doEmbedHTML();
 2404+ this.setupEmbedPlayer();
23312405 this.paused = false;
23322406 this.thumbnail_disp = false;
23332407 }
@@ -2342,18 +2416,23 @@
23432417 } ).attr( 'title', gM( 'mwe-pause_clip' ) );
23442418
23452419 },
 2420+
 2421+ /**
 2422+ * Maps the html5 load request.
 2423+ * There is no genneral way to "load" clips so underling plugin-player libs should overide.
 2424+ */
23462425 load:function() {
23472426 // should be done by child (no base way to pre-buffer video)
23482427 js_log( 'baseEmbed:load call' );
2349 - },
2350 - getSrc:function() {
2351 - return this.media_element.selected_source.getURI( this.seek_time_sec );
2352 - },
2353 - /*
2354 - * Base embed pause
2355 - * there is no general way to pause the video
2356 - * must be overwritten by embed object to support this functionality.
2357 - */
 2428+ },
 2429+
 2430+ /**
 2431+ * Base embed pause
 2432+ * Updaets the play/pause button state.
 2433+ *
 2434+ * There is no general way to pause the video
 2435+ * must be overwritten by embed object to support this functionality.
 2436+ */
23582437 pause: function() {
23592438 var _this = this;
23602439 var eid = ( this.pc != null ) ? this.pc.pp.id:this.id;
@@ -2367,9 +2446,16 @@
23682447 _this.play();
23692448 } ).attr( 'title', gM( 'mwe-play_clip' ) );
23702449 },
 2450+
23712451 /**
2372 - * Base embed stop (can be overwritten by the plugin)
2373 - */
 2452+ * Base embed stop
 2453+ *
 2454+ * Updates the player to the stop state
 2455+ * shows Thumbnail
 2456+ * resets Buffer
 2457+ * resets Playhead slider
 2458+ * resets Status
 2459+ */
23742460 stop: function() {
23752461 var _this = this;
23762462 js_log( 'mvEmbed:stop:' + this.id );
@@ -2392,9 +2478,9 @@
23932479 js_log( 'already in stopped state' );
23942480 } else {
23952481 // rewrite the html to thumbnail disp
2396 - this.doThumbnailHTML();
 2482+ this.showThumbnail();
23972483 this.bufferedPercent = 0; // reset buffer state
2398 - this.setSliderValue( 0 );
 2484+ this.updatePlayHead( 0 );
23992485 this.setStatus( this.getTimeRange() );
24002486 }
24012487
@@ -2409,6 +2495,13 @@
24102496 this.update_interval = null;
24112497 }
24122498 },
 2499+
 2500+ /**
 2501+ * Base Embed mute
 2502+ *
 2503+ * Handles interface updates for toggling mute.
 2504+ * Plug-in / player interface must handle updateing the actual media player
 2505+ */
24132506 toggleMute:function() {
24142507 var eid = ( this.pc != null ) ? this.pc.pp.id:this.id;
24152508 if ( this.muted ) {
@@ -2422,15 +2515,37 @@
24232516 }
24242517 js_log( 'f:toggleMute::' + this.muted );
24252518 },
 2519+
 2520+ /**
 2521+ * Abstract Update volumen Method must be overided by plug-in / player interface
 2522+ */
24262523 updateVolumen:function( perc ) {
24272524 js_log( 'update volume not supported with current playback type' );
 2525+ return ;
24282526 },
 2527+
 2528+ /**
 2529+ * Abstract fullscreen Method must be overided by plug-in / player interface
 2530+ */
24292531 fullscreen:function() {
24302532 js_log( 'fullscreen not supported with current playback type' );
 2533+ return ;
24312534 },
 2535+
24322536 /**
2433 - * returns bool true if playing or paused, false if stooped
 2537+ * Abstract method to be run post embeding the player
 2538+ * Generally should be overwiten by the plug-in / player
24342539 */
 2540+ postEmbedJS:function() {
 2541+ return ;
 2542+ },
 2543+
 2544+ /**
 2545+ * Checks the player state based on thumbnail display & paused state
 2546+ * @return {Boolean}
 2547+ * true if playing
 2548+ * false if not playing
 2549+ */
24352550 isPlaying : function() {
24362551 if ( this.thumbnail_disp ) {
24372552 // in stoped state
@@ -2442,20 +2557,29 @@
24432558 return true;
24442559 }
24452560 },
 2561+
 2562+ /**
 2563+ * Getter for paused state
 2564+ * @return {Boolean}
 2565+ * true if playing
 2566+ * false if not playing
 2567+ */
24462568 isPaused : function() {
24472569 return this.isPlaying() && this.paused;
24482570 },
 2571+
 2572+ /**
 2573+ * Getter for Stoped state
 2574+ * @return {Boolean}
 2575+ * true if playing
 2576+ * false if not playing
 2577+ */
24492578 isStoped : function() {
24502579 return this.thumbnail_disp;
24512580 },
2452 - playlistSupport:function() {
2453 - // by default not supported (implemented in js)
2454 - return false;
2455 - },
2456 - postEmbedJS:function() {
2457 - return '';
2458 - },
2459 - /*
 2581+
 2582+
 2583+ /**
24602584 * Monitor playback and update interface components.
24612585 * underling plugin objects are responsible for updating currentTime
24622586 */
@@ -2466,11 +2590,11 @@
24672591 if ( !this.userSlide && !this.seeking ) {
24682592 if ( this.start_offset ) {
24692593 // If start offset include that calculation
2470 - this.setSliderValue( ( this.currentTime - this.start_offset ) / this.duration );
 2594+ this.updatePlayHead( ( this.currentTime - this.start_offset ) / this.duration );
24712595 var et = ( this.ctrlBuilder.long_time_disp ) ? '/' + seconds2npt( parseFloat( this.start_offset ) + parseFloat( this.duration ) ) : '';
24722596 this.setStatus( seconds2npt( this.currentTime ) + et );
24732597 } else {
2474 - this.setSliderValue( this.currentTime / this.duration );
 2598+ this.updatePlayHead( this.currentTime / this.duration );
24752599 var et = ( this.ctrlBuilder.long_time_disp ) ? '/' + seconds2npt( this.duration ):'';
24762600 this.setStatus( seconds2npt( this.currentTime ) + et );
24772601 }
@@ -2478,7 +2602,7 @@
24792603 // Check if we are "done"
24802604 var end_presentation_time = parseFloat( this.startOffset) + parseFloat( this.duration ) ;
24812605 if ( this.currentTime > end_presentation_time ) {
2482 - js_log( "should run clip done ct:: " + this.currentTime + ' > ' + end_presentation_time );
 2606+ js_log( "should run clip done :: " + this.currentTime + ' > ' + end_presentation_time );
24832607 this.onClipDone();
24842608 }
24852609 } else {
@@ -2497,8 +2621,10 @@
24982622 this.setStatus( this.getTimeRange() );
24992623 }
25002624 }
 2625+
25012626 // Update buffer information
25022627 this.updateBufferStatus();
 2628+
25032629 // Update monitorTimerId to call child monitor
25042630 if ( ! this.monitorTimerId ) {
25052631 // Make sure an instance of this.id exists:
@@ -2511,13 +2637,20 @@
25122638 }
25132639 }
25142640 },
 2641+
 2642+ /**
 2643+ * Stop the playback monitor
 2644+ */
25152645 stopMonitor:function() {
2516 - if ( this.monitorTimerId != 0 )
2517 - {
 2646+ if ( this.monitorTimerId != 0 ){
25182647 clearInterval( this.monitorTimerId );
25192648 this.monitorTimerId = 0;
25202649 }
25212650 },
 2651+
 2652+ /**
 2653+ * Update the buffer status based on the local bufferedPercent var
 2654+ */
25222655 updateBufferStatus: function() {
25232656
25242657 // Build the buffer target based for playlist vs clip
@@ -2536,27 +2669,13 @@
25372670 $j( buffer_select ).css( "width", '0px' );
25382671 }
25392672 },
2540 - relativeCurrentTime: function() {
2541 - if ( !this.start_offset )
2542 - this.start_offset = 0;
2543 - var rt = this.currentTime - this.start_offset;
2544 - if ( rt < 0 ) // should not happen but does.
2545 - return 0;
2546 - return rt;
2547 - },
2548 - getPluginEmbed : function() {
2549 - if ( window.document[this.pid] ) {
2550 - return window.document[this.pid];
2551 - }
2552 - if ( $j.browser.msie ) {
2553 - return document.getElementById( this.pid );
2554 - } else {
2555 - if ( document.embeds && document.embeds[this.pid] )
2556 - return document.embeds[this.pid];
2557 - }
2558 - return null;
2559 - },
2560 - setSliderValue: function( perc, hide_progress ) {
 2673+
 2674+ /**
 2675+ * Update the player playhead
 2676+ *
 2677+ * @param {Float} perc Value between 0 and 1 for position of playhead
 2678+ */
 2679+ updatePlayHead: function( perc ) {
25612680 var eid = ( this.pc ) ? this.pc.pp.id:this.id;
25622681 if ( this.controls && $j( '#' + eid + ' .play_head' ).length != 0 ) {
25632682 var val = parseInt( perc * 1000 );
@@ -2565,11 +2684,17 @@
25662685 // js_log('set#mv_seeker_slider_'+eid + ' perc in: ' + perc + ' * ' + $j('#mv_seeker_'+eid).width() + ' = set to: '+ val + ' - '+ Math.round(this.mv_seeker_width*perc) );
25672686 // js_log('op:' + offset_perc + ' *('+perc+' * ' + $j('#slider_'+id).width() + ')');
25682687 },
 2688+
 2689+ /**
 2690+ * Highligh a section of video on the playhead
 2691+ * ~ probably could be moved to a seperate module ~
 2692+ *
 2693+ * @param {Object} options Provides "start" time & "end" time to highlight
 2694+ */
25692695 highlightPlaySection:function( options ) {
25702696 js_log( 'highlightPlaySection' );
25712697 var eid = ( this.pc ) ? this.pc.pp.id:this.id;
25722698 var dur = this.getDuration();
2573 - var hide_progress = true;
25742699 // set the left percet and update the slider:
25752700 rel_start_sec = npt2seconds( options['start'] );
25762701 // remove the start_offset if relevent:
@@ -2581,7 +2706,7 @@
25822707 left_perc = 0;
25832708 options['start'] = seconds2npt( this.start_offset );
25842709 rel_start_sec = 0;
2585 - this.setSliderValue( 0 , hide_progress );
 2710+ this.updatePlayHead( 0 );
25862711 } else {
25872712 left_perc = parseInt( ( rel_start_sec / dur ) * 100 ) ;
25882713 slider_perc = ( left_perc / 100 );
@@ -2589,7 +2714,7 @@
25902715
25912716 js_log( "slider perc:" + slider_perc );
25922717 if ( ! this.isPlaying() ) {
2593 - this.setSliderValue( slider_perc , hide_progress );
 2718+ this.updatePlayHead( slider_perc );
25942719 }
25952720
25962721 width_perc = parseInt( ( ( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur ) * 100 ) ;
@@ -2609,26 +2734,48 @@
26102735 js_log( 'DO update: ' + this.jump_time );
26112736 this.updateThumbTime( rel_start_sec );
26122737 },
 2738+
 2739+ /**
 2740+ * Hides the playhead highlight
 2741+ */
26132742 hideHighlight:function() {
26142743 var eid = ( this.pc ) ? this.pc.pp.id:this.id;
26152744 $j( '#mv_seeker_' + eid + ' .mv_highlight' ).hide();
26162745 this.setStatus( this.getTimeReq() );
26172746 thigetTimeRangerValue( 0 );
26182747 },
 2748+
 2749+ /**
 2750+ * Updates the player status that displays short text msgs and the play clock
 2751+ */
26192752 setStatus:function( value ) {
26202753 var eid = ( this.pc ) ? this.pc.pp.id:this.id;
26212754 // update status:
26222755 $j( '#' + eid + ' .time-disp' ).html( value );
26232756 },
 2757+
 2758+
 2759+
26242760 /**
26252761 * Helper Functions for selected source
26262762 */
2627 - /*
2628 - * returns the selected source url for players to play
 2763+
 2764+ /**
 2765+ * Gets the current selected media source
 2766+ *
 2767+ * @return src url
26292768 */
2630 - getURI : function( seek_time_sec ) {
2631 - return this.media_element.selected_source.getURI( this.seek_time_sec );
 2769+ getSrc: function() {
 2770+ return this.media_element.selected_source.getSrc( this.seek_time_sec );
26322771 },
 2772+
 2773+ /**
 2774+ * If the selected src supports URL time encoding
 2775+ *
 2776+ * @return {Boolean}
 2777+ * ture if the src supports url time requests
 2778+ * false if the src does not support url time requests
 2779+ */
26332780 supportsURLTimeEncoding: function() {
26342781 // do head request if on the same domain
26352782 return this.media_element.selected_source.URLTimeEncoding;
@@ -2639,9 +2786,10 @@
26402787
26412788 /**
26422789 * mediaPlayer represents a media player plugin.
 2790+
26432791 * @param {String} id id used for the plugin.
26442792 * @param {Array<String>} supported_types n array of supported MIME types.
2645 - * @param {String} library external script containing the plugin interface code. (mv_<library>Embed.js)
 2793+ * @param {String} library external script containing the plugin interface code.
26462794 * @constructor
26472795 */
26482796 function mediaPlayer( id, supported_types, library )
@@ -2653,62 +2801,88 @@
26542802 this.loading_callbacks = new Array();
26552803 return this;
26562804 }
2657 -mediaPlayer.prototype =
2658 -{
 2805+mediaPlayer.prototype = {
 2806+ // Id of the mediaPlayer
26592807 id:null,
 2808+
 2809+ // Mime types supported by this player
26602810 supported_types:null,
 2811+
 2812+ // Player library ie: native, vlc, java etc.
26612813 library:null,
 2814+
 2815+ // Flag stores the mediaPlayer load state
26622816 loaded:false,
2663 - loading_callbacks:null,
2664 - supportsMIMEType: function( type )
2665 - {
2666 - for ( var i = 0; i < this.supported_types.length; i++ )
 2817+
 2818+ /**
 2819+ * Checks support for a given MIME type
 2820+ *
 2821+ * @param {String} type Mime type to check against supported_types
 2822+ * @return {Boolean}
 2823+ * true if mime type is supported
 2824+ * false if mime type is unsupported
 2825+ */
 2826+ supportsMIMEType: function( type ) {
 2827+ for ( var i = 0; i < this.supported_types.length; i++ ){
26672828 if ( this.supported_types[i] == type )
26682829 return true;
 2830+ }
26692831 return false;
26702832 },
2671 - getName: function()
2672 - {
 2833+
 2834+ /**
 2835+ * Get the "name" of the player from a predictable msg key
 2836+ */
 2837+ getName: function() {
26732838 return gM( 'mwe-ogg-player-' + this.id );
26742839 },
 2840+
 2841+ /**
 2842+ * Loads the player library and then calls the callback.
 2843+ *
 2844+ * @param {Function} callback Function to be called once player library is loaded.
 2845+ */
26752846 load: function( callback ) {
2676 - debugger;
26772847 mw.load( [
26782848 this.library + 'Embed'
2679 - ], function() {
2680 - var cat = nativeEmbed;
 2849+ ], function() {
26812850 callback();
26822851 } );
26832852 }
26842853 }
2685 -/* players and supported mime types
2686 -@@note ideally we query the plugin to get what mime types it supports in practice not always reliable/avaliable
 2854+
 2855+/**
 2856+* players and supported mime types
 2857+* In an ideal world we would query the plugin to get what mime
 2858+* types it supports in practice not always reliable/avaliable
26872859 */
 2860+
 2861+//Flash based players:
26882862 //var flowPlayer = new mediaPlayer( 'flowplayer', ['video/x-flv', 'video/h264'], 'flowplayer' );
26892863 var kplayer = new mediaPlayer('kplayer', ['video/x-flv', 'video/h264'], 'kplayer');
2690 -
26912864 var omtkPlayer = new mediaPlayer( 'omtkplayer', ['audio/ogg'], 'omtk' );
26922865
 2866+//Java based player
26932867 var cortadoPlayer = new mediaPlayer( 'cortado', ['video/ogg', 'audio/ogg'], 'java' );
 2868+
 2869+//Native html5 player
26942870 var videoElementPlayer = new mediaPlayer( 'videoElement', ['video/ogg', 'audio/ogg'], 'native' );
26952871
 2872+//VLC player
26962873 var vlcMineList = ['video/ogg', 'audio/ogg', 'video/x-flv', 'video/mp4', 'video/h264'];
26972874 var vlcPlayer = new mediaPlayer( 'vlc-player', vlcMineList, 'vlc' );
26982875
2699 -// add generic
 2876+//Generic plugin
27002877 var oggPluginPlayer = new mediaPlayer( 'oggPlugin', ['video/ogg'], 'generic' );
27012878
2702 -// depricate quicktime in favor of safari native
2703 -// var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime');
2704 -// var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime');
2705 -
 2879+//HTML player for timed display of html contnet ( used in sequencer )
27062880 var htmlPlayer = new mediaPlayer( 'html', ['text/html', 'image/jpeg', 'image/png', 'image/svg'], 'html' );
27072881
 2882+
27082883 /**
2709 - * mediaPlayers is a collection of mediaPlayer objects supported by the client.
2710 - * It could be merged with embedTypes, since there is one embedTypes per script
2711 - * and one mediaPlayers per embedTypes.
2712 - */
 2884+ * mediaPlayers is a collection of mediaPlayer objects supported by the client.
 2885+ * @constructor
 2886+ */
27132887 function mediaPlayers()
27142888 {
27152889 this.init();
@@ -2716,9 +2890,19 @@
27172891
27182892 mediaPlayers.prototype =
27192893 {
 2894+ // The list of players supported
27202895 players : null,
 2896+
 2897+ // Store per mime-type prefrences for players
27212898 preference : null,
 2899+
 2900+ // Stores the default set of players for a given mime type
27222901 default_players : { },
 2902+
 2903+ /**
 2904+ * Initializartion function defiens the default order for players for
 2905+ * a given mime type
 2906+ */
27232907 init : function() {
27242908 this.players = new Array();
27252909 this.loadPreferences();
@@ -2738,30 +2922,31 @@
27392923 this.default_players['image/svg'] = ['html'];
27402924
27412925 },
2742 - addPlayer : function( player, mime_type ) {
 2926+
 2927+ /**
 2928+ * Adds a Player to the player list
 2929+ *
 2930+ * @param {Object} player Player object to be added
 2931+ */
 2932+ addPlayer: function( player ) {
27432933 for ( var i = 0; i < this.players.length; i++ ) {
27442934 if ( this.players[i].id == player.id ) {
2745 - if ( mime_type != null ) {
2746 - // make sure the mime_type is not already there:
2747 - var add_mime = true;
2748 - for ( var j = 0; j < this.players[i].supported_types.length; j++ ) {
2749 - if ( this.players[i].supported_types[j] == mime_type )
2750 - add_mime = false;
2751 - }
2752 - if ( add_mime )
2753 - this.players[i].supported_types.push( mime_type );
2754 - }
 2935+ // Player already found
27552936 return ;
27562937 }
27572938 }
2758 - // Player not found:
2759 - if ( mime_type != null )
2760 - player.supported_types.push( mime_type );
2761 -
2762 - js_log( 'Adding ' + player.id + ' with mime_type ' + mime_type );
 2939+ // Add the player:
27632940 this.players.push( player );
27642941 },
2765 - getMIMETypePlayers : function( mime_type ) {
 2942+
 2943+ /**
 2944+ * get players that support a given mime_type
 2945+ *
 2946+ * @param {String} mime_type Mime type of player set
 2947+ * @return {Array}
 2948+ * Array of players that support a the requested mime type
 2949+ */
 2950+ getMIMETypePlayers: function( mime_type ) {
27662951 var mime_players = new Array();
27672952 var _this = this;
27682953 var inx = 0;
@@ -2778,6 +2963,15 @@
27792964 }
27802965 return mime_players;
27812966 },
 2967+
 2968+ /**
 2969+ * Default player for a given mime type
 2970+ *
 2971+ * @param {String} mime_type Mime type of the requested player
 2972+ * @return
 2973+ * Player for mime type
 2974+ * null if no player found
 2975+ */
27822976 defaultPlayer : function( mime_type ) {
27832977 js_log( "get defaultPlayer for " + mime_type );
27842978 var mime_players = this.getMIMETypePlayers( mime_type );
@@ -2795,11 +2989,24 @@
27962990 js_log( 'No default player found for ' + mime_type );
27972991 return null;
27982992 },
2799 - userSelectFormat : function ( mime_format ) {
2800 - this.preference['format_prefrence'] = mime_format;
 2993+
 2994+ /**
 2995+ * Sets the format preference.
 2996+ *
 2997+ * @param {String} mime_format Prefered format
 2998+ */
 2999+ setFormatPreference : function ( mime_format ) {
 3000+ this.preference['format_preference'] = mime_format;
28013001 this.savePreferences();
28023002 },
2803 - userSelectPlayer : function( player_id, mime_type ) {
 3003+
 3004+ /**
 3005+ * Sets the player preference
 3006+ *
 3007+ * @param {String} player_id Prefered player id
 3008+ * @param {String} mime_type Mime type for the associated player stream
 3009+ */
 3010+ setPlayerPreference : function( player_id, mime_type ) {
28043011 var selected_player = null;
28053012 for ( var i = 0; i < this.players.length; i++ ) {
28063013 if ( this.players[i].id == player_id ) {
@@ -2821,8 +3028,11 @@
28223029 }
28233030 }
28243031 },
2825 - loadPreferences : function()
2826 - {
 3032+
 3033+ /**
 3034+ * Loads the user preference settings from a cookie
 3035+ */
 3036+ loadPreferences : function ( ) {
28273037 this.preference = new Object();
28283038 // see if we have a cookie set to a clientSupported type:
28293039 var cookieVal = $j.cookie( 'ogg_player_exp' );
@@ -2836,6 +3046,10 @@
28373047 }
28383048 }
28393049 },
 3050+
 3051+ /**
 3052+ * Saves the user preference settings to a cookie
 3053+ */
28403054 savePreferences : function() {
28413055 var cookieVal = '';
28423056 for ( var i in this.preference )
@@ -2847,21 +3061,34 @@
28483062 }
28493063 };
28503064
2851 -/*
 3065+/**
28523066 * embedTypes object handles setting and getting of supported embed types:
28533067 * closely mirrors OggHandler so that its easier to share efforts in this area:
28543068 * http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/OggHandler/OggPlayer.js
28553069 */
28563070 var embedTypes = {
2857 - // List of players
 3071+
 3072+ // List of players supported
28583073 players: null,
 3074+
 3075+ // Detect flag for completion
28593076 detect_done:false,
 3077+
 3078+ /**
 3079+ * Runs the detect method and update the detect_done flag
 3080+ * @constructor
 3081+ */
28603082 init: function() {
28613083 // detect supported types
28623084 this.detect();
28633085 this.detect_done = true;
28643086 },
2865 - clientSupports: { 'thumbnail' : true },
 3087+
 3088+ /**
 3089+ * If the browsers supports a given mimetype
 3090+ *
 3091+ * @param {String} mimetype Mime type for browser plug-in check
 3092+ */
28663093 supportedMimeType: function( mimetype ) {
28673094 for ( var i = navigator.plugins.length; i-- > 0; ) {
28683095 var plugin = navigator.plugins[i];
@@ -2870,8 +3097,11 @@
28713098 }
28723099 return false;
28733100 },
2874 -
2875 - detect: function() {
 3101+
 3102+ /**
 3103+ * Detects what plug-ins the client supports
 3104+ */
 3105+ detect: function() {
28763106 js_log( "running detect" );
28773107 this.players = new mediaPlayers();
28783108 // every browser supports html rendering:
@@ -2962,7 +3192,7 @@
29633193 pluginName = '';
29643194 }
29653195 if ( pluginName.toLowerCase() == 'vlc multimedia plugin' || pluginName.toLowerCase() == 'vlc multimedia plug-in' ) {
2966 - this.players.addPlayer( vlcPlayer, type );
 3196+ this.players.addPlayer( vlcPlayer );
29673197 continue;
29683198 }
29693199
@@ -2973,7 +3203,7 @@
29743204
29753205 if ( type == 'application/ogg' ) {
29763206 if ( pluginName.toLowerCase() == 'vlc multimedia plugin' ) {
2977 - this.players.addPlayer( vlcMozillaPlayer, type );
 3207+ this.players.addPlayer( vlcMozillaPlayer );
29783208 // else if ( pluginName.indexOf( 'QuickTime' ) > -1 )
29793209 // this.players.addPlayer(quicktimeMozillaPlayer);
29803210 } else {
@@ -2982,7 +3212,7 @@
29833213 continue;
29843214 } else if ( uniqueMimesOnly ) {
29853215 if ( type == 'application/x-vlc-player' ) {
2986 - this.players.addPlayer( vlcMozillaPlayer, type );
 3216+ this.players.addPlayer( vlcMozillaPlayer );
29873217 continue;
29883218 } else if ( type == 'video/quicktime' ) {
29893219 // this.players.addPlayer(quicktimeMozillaPlayer);
@@ -2990,10 +3220,6 @@
29913221 }
29923222 }
29933223
2994 - /*if ( type == 'video/quicktime' ) {
2995 - this.players.addPlayer(vlcMozillaPlayer, type);
2996 - continue;
2997 - }*/
29983224 if ( type == 'application/x-shockwave-flash' ) {
29993225
30003226 this.players.addPlayer( kplayer );
@@ -3011,12 +3237,14 @@
30123238 continue;
30133239 }
30143240 }
3015 - }
3016 - // @@The xiph quicktime component does not work well with annodex streams (temporarly disable)
3017 - // this.clientSupports['quicktime-mozilla'] = false;
3018 - // this.clientSupports['quicktime-activex'] = false;
3019 - // js_log(this.clientSupports);
 3241+ }
30203242 },
 3243+
 3244+ /**
 3245+ * Test IE for activeX by name
 3246+ *
 3247+ * @param {String} name Name of ActiveXObject to look for
 3248+ */
30213249 testActiveX : function ( name ) {
30223250 var hasObj = true;
30233251 try {
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/genericEmbed.js
@@ -1,6 +1,9 @@
2 -/* the most simple implementation used for unknown application/ogg plugin */
 2+/*
 3+* Simple embed object for unknown application/ogg plugin
 4+*/
35 var genericEmbed = {
4 - supports: {
 6+ // List of supported features of the generic plugin
 7+ supports: {
58 'play_head':false,
69 'pause':false,
710 'stop':true,
@@ -8,10 +11,17 @@
912 'time_display':false,
1013 'volume_control':false
1114 },
 15+ // Instance name:
1216 instanceOf:'genericEmbed',
 17+ /*
 18+ * Generic embed html
 19+ *
 20+ * @return {String}
 21+ * embed code for genneric ogg plugin
 22+ */
1323 getEmbedHTML:function() {
1424 return '<object type="application/ogg" ' +
1525 'width="' + this.width + '" height="' + this.height + '" ' +
16 - 'data="' + this.getURI( this.seek_time_sec ) + '"></object>';
 26+ 'data="' + this.getSrc( this.seek_time_sec ) + '"></object>';
1727 }
1828 };
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/javaEmbed.js
@@ -1,3 +1,6 @@
 2+/*
 3+* List of domains and hosted location of cortado. Lets clients avoid the security warning for cross domain cortado
 4+*/
25 window.cortadoDomainLocations = {
36 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar',
47 'tinyvid.tv' : 'http://tinyvid.tv/static/cortado.jar',
@@ -5,9 +8,11 @@
69 }
710
811 var javaEmbed = {
 12+
 13+ // instance name:
914 instanceOf:'javaEmbed',
10 - iframe_src:'',
11 - logged_domain_error:false,
 15+
 16+ // Supported feature set of the cortado applet:
1217 supports: {
1318 'play_head':true,
1419 'pause':true,
@@ -16,15 +21,23 @@
1722 'time_display':true,
1823 'volume_control':false
1924 },
20 - getEmbedHTML : function () {
 25+
 26+ /**
 27+ * Wraps the embed object html output:
 28+ */
 29+ getEmbedHTML: function () {
2130 // big delay on embed html cuz its just for status updates and ie6 is crazy.
2231 if ( this.controls )
2332 setTimeout( 'document.getElementById(\'' + this.id + '\').postEmbedJS()', 500 );
2433 // set a default duration of 30 seconds: cortao should detect duration.
2534 return this.wrapEmebedContainer( this.getEmbedObj() );
2635 },
27 - getEmbedObj:function() {
28 - js_log( "java play url:" + this.getURI( this.seek_time_sec ) );
 36+
 37+ /**
 38+ * Gets the embed html code:
 39+ */
 40+ getEmbedObj: function() {
 41+ js_log( "java play url:" + this.getSrc( this.seek_time_sec ) );
2942 // get the duration
3043 this.getDuration();
3144 // if still unset set to an arbitrary time 60 seconds:
@@ -77,22 +90,28 @@
7891 return appplet_code;
7992 }
8093 },
81 - postEmbedJS:function() {
82 - // reset logged domain error flag:
83 - this.logged_domain_error = false;
 94+
 95+ /**
 96+ * Once the applet has been embed start monitoring playback
 97+ */
 98+ postEmbedJS:function() {
8499 // start monitor:
85100 this.monitor();
86101 },
 102+
 103+ /**
 104+ * Monitor applet playback, and update currentTime
 105+ */
87106 monitor:function() {
88 - this.getJCE();
 107+ this.getPlayerElement();
89108 if ( this.isPlaying() ) {
90 - if ( this.jce && this.jce.getPlayPosition ) {
 109+ if ( this.playerElement && this.playerElement.getPlayPosition ) {
91110 try {
92111 // java reads ogg media time.. so no need to add the start or seek offset:
93 - // js_log(' ct: ' + this.jce.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
94 - this.currentTime = this.jce.getPlayPosition();
95 - if ( this.jce.getPlayPosition() < 0 ) {
96 - js_log( 'pp:' + this.jce.getPlayPosition() );
 112+ // js_log(' ct: ' + this.playerElement.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
 113+ this.currentTime = this.playerElement.getPlayPosition();
 114+ if ( this.playerElement.getPlayPosition() < 0 ) {
 115+ js_log( 'pp:' + this.playerElement.getPlayPosition() );
97116 // probably reached clip end
98117 this.onClipDone();
99118 }
@@ -104,35 +123,43 @@
105124 // once currentTime is updated call parent_monitor
106125 this.parent_monitor();
107126 },
108 - /*
109 - * (local cortado seek does not seem to work very well)
110 - */
111 - doSeek:function( perc ) {
112 - js_log( 'java:seek:p: ' + perc + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
113 - this.getJCE();
 127+
 128+ /**
 129+ * Seek in the ogg stream
 130+ * (Cortado seek does not seem to work very well)
 131+ * @param {Float} percentage Percentage to seek into the stream
 132+ */
 133+ doSeek:function( percentage ) {
 134+ js_log( 'java:seek:p: ' + percentage + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
 135+ this.getPlayerElement();
114136
115137 if ( this.supportsURLTimeEncoding() ) {
116 - this.parent_doSeek( perc );
117 - // this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() );
118 - // this.jce.setParam('url', this.getURI( this.seek_time_sec ))
119 - // this.jce.restart();
120 - } else if ( this.jce ) {
121 - // do a (genneraly broken) local seek:
122 - js_log( "cortado javascript seems to always fail ... but here we go... doSeek(" + ( perc * parseFloat( this.getDuration() ) ) );
123 - this.jce.doSeek( perc * parseFloat( this.getDuration() ) );
 138+ this.parent_doSeek( percentage );
 139+ // this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( percentage * this.getDuration() );
 140+ // this.playerElement.setParam('url', this.getSrc( this.seek_time_sec ))
 141+ // this.playerElement.restart();
 142+ } else if ( this.playerElement ) {
 143+ // do a (generally broken) local seek:
 144+ js_log( "cortado javascript seems to always fail ... but here we go... doSeek(" + ( percentage * parseFloat( this.getDuration() ) ) );
 145+ this.playerElement.doSeek( percentage * parseFloat( this.getDuration() ) );
124146 } else {
125 - this.doPlayThenSeek( perc );
 147+ this.doPlayThenSeek( percentage );
126148 }
127149 },
128 - doPlayThenSeek:function( perc ) {
129 - js_log( 'doPlayThenSeek Hack' );
 150+
 151+ /**
 152+ * Issue a play request then seek to a percentage point in the stream
 153+ * @param {Float} percentage Percentage to seek into the stream
 154+ */
 155+ doPlayThenSeek: function( percentage ) {
 156+ js_log( 'doPlayThenSeek' );
130157 var _this = this;
131158 this.play();
132159 var rfsCount = 0;
133160 var readyForSeek = function() {
134 - _this.getJCE();
 161+ _this.getPlayerElement();
135162 // if we have .jre ~in theory~ we can seek (but probably not)
136 - if ( _this.jce ) {
 163+ if ( _this.playerElement ) {
137164 _this.doSeek( perc );
138165 } else {
139166 // try to get player for 10 seconds:
@@ -146,32 +173,49 @@
147174 }
148175 readyForSeek();
149176 },
150 - // get java cortado embed object
151 - getJCE:function() {
 177+
 178+ /**
 179+ * Update the playerElement instance with a pointer to the embed object
 180+ */
 181+ getPlayerElement:function() {
152182 if ( embedTypes.mozilla ) {
153 - this.jce = window.frames['cframe_' + this.id ].document.getElementById( this.pid );
 183+ this.playerElement = window.frames['cframe_' + this.id ].document.getElementById( this.pid );
154184 } else {
155 - this.jce = $j( '#' + this.pid ).get( 0 );
 185+ this.playerElement = $j( '#' + this.pid ).get( 0 );
156186 }
157187 },
158 - doThumbnailHTML:function() {
 188+
 189+ /**
 190+ * Show the Thumbnail
 191+ */
 192+ showThumbnail:function() {
159193 // empty out player html (jquery with java applets does mix) :
160194 var pelm = document.getElementById( 'dc_' + this.id );
161195 if ( pelm ) {
162196 pelm.innerHTML = '';
163197 }
164 - this.parent_doThumbnailHTML();
 198+ this.parent_showThumbnail();
165199 },
 200+
 201+ /**
 202+ * Issue the doPlay request to the playerElement
 203+ * calls parent_play to update interface
 204+ */
166205 play:function() {
167 - this.getJCE();
 206+ this.getPlayerElement();
168207 this.parent_play();
169 - if ( this.jce )
170 - this.jce.doPlay();
 208+ if ( this.playerElement )
 209+ this.playerElement.doPlay();
171210 },
 211+
 212+ /**
 213+ * Pause playback
 214+ * calls parent_pause to update interface
 215+ */
172216 pause:function() {
173 - this.getJCE();
 217+ this.getPlayerElement();
174218 this.parent_pause();
175 - if ( this.jce )
176 - this.jce.doPause();
 219+ if ( this.playerElement )
 220+ this.playerElement.doPause();
177221 }
178222 };
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/flowplayerEmbed.js
@@ -1,6 +1,6 @@
22 /**
3 - * metavid: mv_flashEmbed builds off of flowplayer api (included first in this file)
4 - * THIS WILL BE DEPRECIATED SOON
 3+ * Builds off of flowplayer api (included first in this file)
 4+ * THIS WILL BE DEPRECIATED SOON AS WE KNOW USE "kplayer" for our flash fallback support
55 */
66
77 /**
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/htmlEmbed.js
@@ -1,13 +1,14 @@
22 /*
3 - * used to embed HTML as a movie clip
 3+ * Used to embed HTML as a movie clip
44 * for use with mv_playlist SMIL additions
5 - * (we make assumptions about this.pc (parent clip) being available)
65 */
76 var pcHtmlEmbedDefaults = {
87 'dur':4 // default duration of 4 seconds
98 }
109
1110 var htmlEmbed = {
 11+
 12+ // List of supported features
1213 supports: {
1314 'play_head':true,
1415 'pause':true,
@@ -16,13 +17,29 @@
1718 'volume_control':true,
1819
1920 'overlays':true,
20 - 'playlist_swap_loader':true // if the object supports playlist functions
 21+
 22+ // if the object supports playlist functions
 23+ 'playlist_swap_loader':true
2124 },
 25+
 26+ // If the player is "ready to play"
2227 ready_to_play:true,
 28+
 29+ // Pause time used to track player time between pauses
2330 pauseTime:0,
 31+
 32+ // currentTime updated via internal clockStartTime var
2433 currentTime:0,
 34+
 35+ // StartOffset support seeking into the virtual player
2536 start_offset:0,
26 - monitorTimerId:false,
 37+
 38+ // The local clock used to emulate playback time
 39+ clockStartTime: 0
 40+
 41+ /**
 42+ * Play function starts the v
 43+ */
2744 play:function() {
2845 // call the parent
2946 this.parent_play();
@@ -34,11 +51,18 @@
3552 // Start up monitor:
3653 this.monitor();
3754 },
 55+
 56+ /**
 57+ * Stops the playback
 58+ */
3859 stop:function() {
3960 this.currentTime = 0;
40 - this.pause();
41 - // window.clearInterval( this.monitorTimerId );
 61+ this.pause();
4262 },
 63+
 64+ /**
 65+ * Preserves the pause time across for timed playback
 66+ */
4367 pause:function() {
4468 js_log( 'f:pause: htmlEmbedWrapper' );
4569 var ct = new Date();
@@ -47,16 +71,32 @@
4872
4973 window.clearInterval( this.monitorTimerId );
5074 },
 75+
 76+ /**
 77+ * Seeks to a given percent and updates the pauseTime
 78+ *
 79+ * @param {Float} perc Pecentage to seek into the virtual player
 80+ */
5181 doSeek:function( perc ){
5282 this.pauseTime = perc * this.getDuration();
5383 this.play();
5484 },
 85+
 86+ /**
 87+ * Sets the current Time
 88+ *
 89+ * @param {Float} perc Pecentage to seek into the virtual player
 90+ * @param {Function} callback Function called once time has been updated
 91+ */
5592 setCurrentTime:function( perc, callback ){
5693 this.pauseTime = perc * this.getDuration();
5794 if( callback )
5895 callback();
5996 },
60 - // Monitor just needs to keep track of time
 97+
 98+ /**
 99+ * Monitor tracks of virtual player time
 100+ */
61101 monitor:function() {
62102 //js_log('html:monitor: '+ this.currentTime);
63103 var ct = new Date();
@@ -67,7 +107,10 @@
68108 // Once currentTime is updated call parent_monitor
69109 this.parent_monitor();
70110 },
71 - // set up minimal media_element emulation:
 111+
 112+ /**
 113+ * Minimal media_element emulation:
 114+ */
72115 media_element: {
73116 autoSelectSource:function() {
74117 return true;
@@ -82,9 +125,19 @@
83126 return false;
84127 }
85128 },
86 - inheritEmbedPlayer:function() {
 129+
 130+ /**
 131+ * HtmlEmbed supports virtual instances without inheriting the embedPlayer
 132+ */
 133+ inheritEmbedPlayer: function() {
87134 return true;
88135 },
 136+
 137+ /**
 138+ * Render out a Thumbnail representation for use in the sequencer
 139+ *
 140+ * @param {Object} options Thumbnail options
 141+ */
89142 renderTimelineThumbnail:function( options ) {
90143 js_log( "HTMLembed req w, height: " + options.width + ' ' + options.height );
91144 // generate a scaled down version _that_ we can clone if nessisary
@@ -93,10 +146,13 @@
94147
95148 var thumb_render_id = this.id + '_thumb_render_' + options.height;
96149 if ( $j( '#' + thumb_render_id ).length == 0 || do_refresh ) {
97 - // set the font scale down percentage: (kind of arbitrary)
 150+
 151+ // Set the font scale down percentage: (kind of arbitrary)
98152 var scale_perc = options.width / this.pc.pp.width;
 153+
99154 js_log( 'scale_perc:' + options.width + ' / ' + $j( this ).width() + ' = ' + scale_perc );
100 - // min scale font percent of 70 (overflow is hidden)
 155+
 156+ // Min scale font percent of 70 (overflow is hidden)
101157 var font_perc = ( Math.round( scale_perc * 100 ) < 80 ) ? 80 : Math.round( scale_perc * 100 );
102158 var thumb_class = ( typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : '';
103159 $j( 'body' ).append( '<div id="' + thumb_render_id + '" style="display:none">' +
@@ -109,15 +165,16 @@
110166 '</div>' +
111167 '</div>'
112168 );
113 - // scale down the fonts:
 169+
 170+ // Scale down the fonts:
114171 $j( '#' + thumb_render_id + ' *' ).filter( 'span,div,p,h,h1,h2,h3,h4,h5,h6' ).css( 'font-size', font_perc + '%' )
115172
116 - // replace out links:
 173+ // Replace out links:
117174 $j( '#' + thumb_render_id + ' a' ).each( function() {
118175 $j( this ).replaceWith( "<span>" + $j( this ).html() + "</span>" );
119176 } );
120177
121 - // scale images that have width or height:
 178+ // Scale images that have width or height:
122179 $j( '#' + thumb_render_id + ' img' ).filter( '[width]' ).each( function() {
123180 $j( this ).attr( {
124181 'width': Math.round( $j( this ).attr( 'width' ) * scale_perc ),
@@ -128,11 +185,17 @@
129186 }
130187 return $j( '#' + thumb_render_id ).html();
131188 },
132 - // nothing to update in static html display: (return a static representation)
133 - // @@todo render out a mini text "preview"
 189+ /*
 190+ * updates the ThumbTime
 191+ * (does nothings since we display a single renderd html page)
 192+ */
134193 updateThumbTime:function( float_time ) {
135194 return ;
136195 },
 196+
 197+ /**
 198+ * gets the "embed" html for the html player
 199+ */
137200 getEmbedHTML:function() {
138201 js_log( 'f:html:getEmbedHTML: ' + this.id );
139202 // set up the css for our parent div:
@@ -146,6 +209,11 @@
147210 // wrap output in videoPlayer_ div:
148211 $j( this ).html( '<div id="videoPlayer_' + this.id + '">' + this.getThumbnailHTML() + '</div>' );
149212 },
 213+
 214+ /**
 215+ * gets the ThumbnailHTML
 216+ * ThumbnailHTML is used for both the "paused and playing states of the htmlEmbed player
 217+ */
150218 getThumbnailHTML:function( opt ) {
151219 var out = '';
152220 if ( !opt )
@@ -162,15 +230,26 @@
163231 // js_log('f:getThumbnailHTML: got thumb: '+out);
164232 return out;
165233 },
166 - doThumbnailHTML:function() {
167 - js_log( 'htmlEmbed:doThumbnailHTML()' );
 234+
 235+ /**
 236+ * re-show the Thumbnail
 237+ */
 238+ showThumbnail:function() {
 239+ js_log( 'htmlEmbed:showThumbnail()' );
168240 this.getEmbedHTML();
169241 },
170 - /* since its just html display get the "embed" right away */
 242+
 243+ /**
 244+ * Display the "embed" html right away
 245+ */
171246 getHTML:function() {
172247 js_log( 'htmlEmbed::getHTML() ' + this.id );
173248 this.getEmbedHTML();
174249 },
 250+
 251+ /**
 252+ * Gets the media duration
 253+ */
175254 getDuration:function() {
176255 if( !this.duration ){
177256 if( this.pc.dur ){
@@ -181,13 +260,21 @@
182261 }
183262 return this.parent_getDuration();
184263 },
185 - updateVideoTime:function( start_ntp, end_ntp ) {
 264+
 265+ /**
 266+ * Updates the Video time
 267+ * @param {String} start_npt Start time for update
 268+ * @param {String} end_npt End time for update
 269+ */
 270+ updateVideoTime:function( start_npt, end_npt ) {
186271 // since we don't really have timeline for html elements just take the delta and set it as the duration
187272 this.pc.dur = npt2seconds( end_ntp ) - npt2seconds( start_ntp );
188273 },
189 - // gives a chance to make any nesseary external requests
190 - // @@todo we can "start loading images" if we want
191 - on_dom_swap:function() {
 274+
 275+ /**
 276+ * Local implementation of swapPlayerElement
 277+ */
 278+ swapPlayerElement:function() {
192279 this.loading_external_data = false
193280 this.ready_to_play = true;
194281 return ;
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/vlcEmbed.js
@@ -292,6 +292,6 @@
293293 },
294294 // get the embed vlc object
295295 getVLC : function() {
296 - this.vlc = this.getPluginEmbed();
 296+ this.vlc = $j('#' + this.pid ).get(0);
297297 }
298298 };
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js
@@ -5,13 +5,28 @@
66 * Enables embedPlayer support for native html5 browser playback system
77 */
88 var nativeEmbed = {
 9+
 10+ //Instance Name
911 instanceOf:'nativeEmbed',
10 - canPlayThrough:false,
 12+
 13+ // Counts the number of times we tried to access the video element
1114 grab_try_count:0,
 15+
 16+ // Flag to only load the video ( not play it )
1217 onlyLoadFlag:false,
13 - onLoadedCallback : new Array(),
 18+
 19+ //Callback fired once video is "loaded"
 20+ onLoadedCallback: null,
 21+
 22+ //For retrying a player embed with a distinct url
 23+ // NOTE: this bug workaround may no longer be applicable
1424 urlAppend:'',
 25+
 26+ // The previus "currentTime" to snif seek actions
 27+ // NOTE the bug where onSeeked does not seem fire consistently may no longer be applicable
1528 prevCurrentTime: -1,
 29+
 30+ // Native player supported feature set
1631 supports: {
1732 'play_head':true,
1833 'pause':true,
@@ -21,15 +36,22 @@
2237
2338 'overlays':true,
2439 'playlist_swap_loader':true // if the object supports playlist functions
25 - },
 40+ },
 41+ /**
 42+ * Wraps the embed object and returns the output
 43+ */
2644 getEmbedHTML : function () {
2745 var embed_code = this.getEmbedObj();
2846 js_log( "embed code: " + embed_code )
2947 setTimeout( '$j(\'#' + this.id + '\').get(0).postEmbedJS()', 150 );
3048 return this.wrapEmebedContainer( embed_code );
3149 },
 50+
 51+ /**
 52+ * Get the native embeed code
 53+ */
3254 getEmbedObj:function() {
33 - // we want to let mwEmbed handle the controls so notice the absence of control attribute
 55+ // We want to let mwEmbed handle the controls so notice the absence of control attribute
3456 // controls=false results in controls being displayed:
3557 // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-August/016159.html
3658 js_log( "native play url:" + this.getSrc() + ' start_offset: ' + this.start_ntp + ' end: ' + this.end_ntp );
@@ -37,96 +59,113 @@
3860 'id="' + this.pid + '" ' +
3961 'style="width:' + this.width + 'px;height:' + this.height + 'px;" ' +
4062 'width="' + this.width + '" height="' + this.height + '" ' +
41 - 'src="' + this.getSrc() + '" ';
42 -
43 - /*if(!this.onlyLoadFlag)
44 - eb+='autoplay="true" ';*/
45 -
46 - // continue with the other attr:
47 - // NOTE: could be binded in "post embed js"
48 - eb += 'oncanplaythrough="$j(\'#' + this.id + '\').get(0).oncanplaythrough();return false;" ' +
49 - 'onloadedmetadata="$j(\'#' + this.id + '\').get(0).onloadedmetadata();return false;" ' +
50 - 'loadedmetadata="$j(\'#' + this.id + '\').get(0).onloadedmetadata();return false;" ' +
51 - 'onprogress="$j(\'#' + this.id + '\').get(0).onprogress( event );return false;" ' +
52 - 'onended="$j(\'#' + this.id + '\').get(0).onended();return false;" ' +
53 - 'onseeking="$j(\'#' + this.id + '\').get(0).onseeking();" ' +
54 - 'onseeked="$j(\'#' + this.id + '\').get(0).onseeked();" >' +
55 - '</video>';
 63+ 'src="' + this.getSrc() + '" ' +
 64+ '</video>';
5665 return eb;
57 - },
58 - // @@todo : loading progress
 66+ },
 67+ /**
 68+ * Post element javascript, binds event listeners and starts monitor
 69+ */
5970 postEmbedJS:function() {
6071 var _this = this;
6172 js_log( "f:native:postEmbedJS:" );
62 - this.getVID();
63 - if ( typeof this.vid != 'undefined' ) {
64 - // always load the media:
 73+ this.getPlayerElement();
 74+ if ( typeof this.playerElement != 'undefined' ) {
 75+
 76+ // Setup some bindings:
 77+ var vid = $j( this.playerElement ).get(0);
 78+ var wtf = function(){
 79+ alert("wtf");
 80+ }
 81+ // Bind events to local js methods:
 82+ vid.addEventListener( 'canplaythrough', function(){ _this.canplaythrough }, true);
 83+ vid.addEventListener( 'loadedmetadata', function(){ _this.onloadedmetadata() }, true);
 84+ vid.addEventListener( 'progress', function( e ){ _this.onprogress( e ) }, true);
 85+ vid.addEventListener( 'ended', function(){ _this.onended() }, true);
 86+ vid.addEventListener( 'seeking', function(){ _this.onseeking() }, true);
 87+ vid.addEventListener( 'seeked', function(){ _this.onseeked() }, true);
 88+
 89+ // Always load the media:
6590 if ( this.onlyLoadFlag ) {
66 - this.vid.load();
 91+ this.playerElement.load();
6792 } else {
68 - // issue play request
69 - this.vid.play();
 93+ // Issue play request
 94+ this.playerElement.play();
7095 }
71 - setTimeout( '$j(\'#' + this.id + '\').get(0).monitor()', 100 );
72 - } else {
73 - js_log( 'could not grab vid obj trying again:' + typeof this.vid );
 96+ setTimeout( function(){
 97+ _this.monitor();
 98+ }, 100 );
 99+
 100+ } else {
 101+ // False inserts don't seem to be as much of a problem as before:
 102+ js_log( 'Could not grab vid obj trying again:' + typeof this.playerElement );
74103 this.grab_try_count++;
75104 if ( this.grab_count == 20 ) {
76 - js_log( ' could not get vid object after 20 tries re-run: getEmbedObj() ?' ) ;
 105+ js_log( 'Could not get vid object after 20 tries re-run: getEmbedObj() ?' ) ;
77106 } else {
78107 setTimeout( function(){
79108 _this.postEmbedJS();
80109 }, 200 );
81110 }
 111+
82112 }
83 - },
84 - onseeking:function() {
85 - js_log( "onseeking" );
86 - this.seeking = true;
87 - this.setStatus( gM( 'mwe-seeking' ) );
88 - },
89 - onseeked: function() {
90 - js_log("onseeked");
91 - this.seeking = false;
92 - },
93 - doSeek:function( perc ) {
94 - js_log( 'native:seek:p: ' + perc + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
 113+ },
 114+
 115+ /**
 116+ * Issue a seeking request.
 117+ *
 118+ * @param {Float} percentage
 119+ */
 120+ doSeek:function( percentage ) {
 121+ js_log( 'native:seek:p: ' + percentage + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
95122 // @@todo check if the clip is loaded here (if so we can do a local seek)
96123 if ( this.supportsURLTimeEncoding() ) {
97124 // Make sure we could not do a local seek instead:
98 - if ( perc < this.bufferedPercent && this.vid.duration && !this.didSeekJump ) {
99 - js_log( "do local seek " + perc + ' is already buffered < ' + this.bufferedPercent );
100 - this.doNativeSeek( perc );
 125+ if ( percentage < this.bufferedPercent && this.playerElement.duration && !this.didSeekJump ) {
 126+ js_log( "do local seek " + percentage + ' is already buffered < ' + this.bufferedPercent );
 127+ this.doNativeSeek( percentage );
101128 } else {
102129 // We support URLTimeEncoding call parent seek:
103 - this.parent_doSeek( perc );
 130+ this.parent_doSeek( percentage );
104131 }
105 - } else if ( this.vid && this.vid.duration ) {
106 - // (could also check bufferedPercent > perc seek (and issue oggz_chop request or not)
107 - this.doNativeSeek( perc );
 132+ } else if ( this.playerElement && this.playerElement.duration ) {
 133+ // (could also check bufferedPercent > percentage seek (and issue oggz_chop request or not)
 134+ this.doNativeSeek( percentage );
108135 } else {
109136 // try to do a play then seek:
110 - this.doPlayThenSeek( perc )
 137+ this.doPlayThenSeek( percentage )
111138 }
112139 },
113 - doNativeSeek:function( perc ) {
114 - js_log( 'native::doNativeSeek::' + perc );
 140+
 141+ /**
 142+ * Do a native seek by updating the currentTime
 143+ */
 144+ doNativeSeek:function( percentage ) {
 145+ js_log( 'native::doNativeSeek::' + percentage );
115146 this.seek_time_sec = 0;
116 - this.vid.currentTime = perc * this.duration;
 147+ this.playerElement.currentTime = percentage * this.duration;
117148 this.monitor();
118149 },
119 - doPlayThenSeek:function( perc ) {
 150+
 151+ /**
 152+ * Do a play request
 153+ * then check if the video is ready to play
 154+ * then seek
 155+ *
 156+ * @param {Float} percentage Percentage of the stream to seek to between 0 and 1
 157+ */
 158+ doPlayThenSeek:function( percentage ) {
120159 js_log( 'native::doPlayThenSeek::' );
121160 var _this = this;
122161 this.play();
123162 var rfsCount = 0;
124163 var readyForSeek = function() {
125 - _this.getVID();
126 - if ( _this.vid )
127 - js_log( 'readyForSeek looking::' + _this.vid.duration );
 164+ _this.getPlayerElement();
 165+ if ( _this.playerElement )
 166+ js_log( 'readyForSeek looking::' + _this.playerElement.duration );
128167 // if we have duration then we are ready to do the seek
129 - if ( _this.vid && _this.vid.duration ) {
130 - _this.doNativeSeek( perc );
 168+ if ( _this.playerElement && _this.playerElement.duration ) {
 169+ _this.doNativeSeek( percentage );
131170 } else {
132171 // Try to get player for 40 seconds:
133172 // (it would be nice if the onmetadata type callbacks where fired consistently)
@@ -140,33 +179,44 @@
141180 }
142181 readyForSeek();
143182 },
144 - setCurrentTime: function( pos, callback ) {
 183+
 184+ /**
 185+ * Set the current time with a callback
 186+ */
 187+ setCurrentTime: function( position , callback ) {
145188 var _this = this;
146 - js_log( 'native:setCurrentTime::: ' + pos + ' : dur: ' + _this.getDuration() );
147 - this.getVID();
148 - if ( !this.vid ) {
 189+ js_log( 'native:setCurrentTime::: ' + position + ' : dur: ' + _this.getDuration() );
 190+ this.getPlayerElement();
 191+ if ( !this.playerElement ) {
149192 this.load( function() {
150 - _this.doSeekedCb( pos, callback );
 193+ _this.doSeekedCb( position, callback );
151194 } );
152195 } else {
153 - _this.doSeekedCb( pos, callback );
 196+ _this.doSeekedCb( position, callback );
154197 }
155198 },
156 - doSeekedCb : function( pos, cb ){
 199+ /**
 200+ * Do the seek request with a callback
 201+ */
 202+ doSeekedCallback : function( position, callback ){
157203 var _this = this;
158 - this.getVID();
 204+ this.getPlayerElement();
159205 var once = function( event ) {
160 - js_log("did seek cb");
161 - cb();
162 - _this.vid.removeEventListener( 'seeked', once, false );
 206+ js_log("did seek callback");
 207+ callback();
 208+ _this.playerElement.removeEventListener( 'seeked', once, false );
163209 };
164210 // Assume we will get to add the Listener before the seek is done
165 - _this.vid.currentTime = pos;
166 - _this.vid.addEventListener( 'seeked', once, false );
 211+ _this.playerElement.currentTime = position;
 212+ _this.playerElement.addEventListener( 'seeked', once, false );
167213 },
 214+
 215+ /**
 216+ * Monitor the video playback & update the currentTime
 217+ */
168218 monitor : function() {
169 - this.getVID(); // make sure we have .vid obj
170 - if ( !this.vid ) {
 219+ this.getPlayerElement(); // make sure we have .vid obj
 220+ if ( !this.playerElement ) {
171221 js_log( 'could not find video embed: ' + this.id + ' stop monitor' );
172222 this.stopMonitor();
173223 return false;
@@ -186,7 +236,7 @@
187237 this.prevCurrentTime = this.currentTime;
188238
189239 // update currentTime
190 - this.currentTime = this.vid.currentTime;
 240+ this.currentTime = this.playerElement.currentTime;
191241
192242 // js_log('currentTime:' + this.currentTime);
193243 // js_log('this.currentTime: ' + this.currentTime );
@@ -197,113 +247,199 @@
198248 /**
199249 * Get video src URI
200250 */
201 - getSrc:function() {
 251+ getSrc: function() {
202252 var src = this.parent_getSrc();
203253 if ( this.urlAppend != '' )
204254 return src + ( ( src.indexOf( '?' ) == -1 ) ? '?':'&' ) + this.urlAppend;
205255 return src;
206 - },
207 - /*
208 - * native callbacks for the video tag:
209 - */
210 - oncanplaythrough : function() {
211 - js_log('f:oncanplaythrough');
212 - this.getVID();
213 - if ( ! this.paused )
214 - this.vid.play();
215 - },
216 - onloadedmetadata: function() {
217 - this.getVID();
218 - js_log( 'f:onloadedmetadata metadata ready (update duration)' );
219 - // update duration if not set (for now trust the getDuration more than this.vid.duration
220 - if ( this.getDuration() == 0 && ! isNaN( this.vid.duration ) ) {
221 - js_log( 'updaed duration via native video duration: ' + this.vid.duration )
222 - this.duration = this.vid.duration;
223 - }
224 - //fire "onLoaded" flags if set
225 - while( this.onLoadedCallback.length ){
226 - func = this.onLoadedCallback.pop()
227 - if( typeof func == 'function' )
228 - func();
229 - }
230 - },
231 - onprogress: function( e ) {
232 - this.bufferedPercent = e.loaded / e.total;
233 - // js_log("onprogress:" +e.loaded + ' / ' + (e.total) + ' = ' + this.bufferedPercent);
234 - },
235 - onended:function() {
236 - var _this = this
237 - this.getVID();
238 - js_log( 'native:onended:' + this.vid.currentTime + ' real dur:' + this.getDuration() );
239 - // if we just started (under 1 second played) & duration is much longer.. don't run onClipDone just yet . (bug in firefox native sending onended event early)
240 - if ( this.vid.currentTime < 1 && this.getDuration() > 1 && this.grab_try_count < 5 ) {
241 - js_log( 'native on ended called with time:' + this.vid.currentTime + ' of total real dur: ' + this.getDuration() + ' attempting to reload src...' );
242 - var doRetry = function() {
243 - _this.urlAppend = 'retry_src=' + _this.grab_try_count;
244 - _this.doEmbedHTML();
245 - _this.grab_try_count++;
246 - }
247 - setTimeout( doRetry, 100 );
248 - } else {
249 - js_log( 'native onClipDone done call' );
250 - this.onClipDone();
251 - }
252 - },
253 - pause : function() {
254 - this.getVID();
 256+ },
 257+
 258+ /**
 259+ * Pause the video playback
 260+ * calls parent_pause to update the interface
 261+ */
 262+ pause: function() {
 263+ this.getPlayerElement();
255264 this.parent_pause(); // update interface
256 - if ( this.vid ) {
257 - this.vid.pause();
 265+ if ( this.playerElement ) {
 266+ this.playerElement.pause();
258267 }
259268 // stop updates:
260269 this.stopMonitor();
261270 },
262 - play:function() {
263 - this.getVID();
 271+
 272+ /**
 273+ * Play back the video stream
 274+ * calls parent_play to update the interface
 275+ */
 276+ play: function() {
 277+ this.getPlayerElement();
264278 this.parent_play(); // update interface
265 - if ( this.vid ) {
266 - this.vid.play();
 279+ if ( this.playerElement ) {
 280+ this.playerElement.play();
267281 // re-start the monitor:
268282 this.monitor();
269283 }
270284 },
271 - toggleMute:function() {
 285+
 286+ /**
 287+ * Toggle the Mute
 288+ * calls parent_toggleMute to update the interface
 289+ */
 290+ toggleMute: function() {
272291 this.parent_toggleMute();
273 - this.getVID();
274 - if ( this.vid )
275 - this.vid.muted = this.muted;
 292+ this.getPlayerElement();
 293+ if ( this.playerElement )
 294+ this.playerElement.muted = this.muted;
276295 },
277 - updateVolumen:function( perc ) {
278 - this.getVID();
279 - if ( this.vid )
280 - this.vid.volume = perc;
 296+
 297+ /**
 298+ * Update Volume
 299+ *
 300+ * @param {Float} percentage Value between 0 and 1 to set audio volume
 301+ */
 302+ updateVolumen: function( percentage ) {
 303+ this.getPlayerElement();
 304+ if ( this.playerElement )
 305+ this.playerElement.volume = percentage;
281306 },
282 - getVolumen:function() {
283 - this.getVID();
284 - if ( this.vid )
285 - return this.vid.volume;
 307+
 308+ /**
 309+ * get Volume
 310+ *
 311+ * @return {Float}
 312+ * Audio volume between 0 and 1.
 313+ */
 314+ getVolumen: function() {
 315+ this.getPlayerElement();
 316+ if ( this.playerElement )
 317+ return this.playerElement.volume;
286318 },
287 - getNativeDuration:function() {
288 - if ( this.vid )
289 - return this.vid.duration;
 319+
 320+ /**
 321+ * Get the native media duration
 322+ */
 323+ getNativeDuration: function() {
 324+ if ( this.playerElement )
 325+ return this.playerElement.duration;
290326 },
291 - load:function( callback ) {
292 - this.getVID();
293 - if ( !this.vid ) {
 327+
 328+ /**
 329+ * load the video stream with a callback fired once the video is "loaded"
 330+ *
 331+ * @parma {Function} callbcak Function called once video is loaded
 332+ */
 333+ load: function( callback ) {
 334+ this.getPlayerElement();
 335+ if ( !this.playerElement ) {
294336 // No vid loaded
295337 js_log( 'native::load() ... doEmbed' );
296338 this.onlyLoadFlag = true;
297339 this.doEmbedHTML();
298 - this.onLoadedCallback.push( callback );
 340+ this.onLoadedCallback = callback;
299341 } else {
300342 // Should not happen offten
301 - this.vid.load();
 343+ this.playerElement.load();
302344 if( callback)
303345 callback();
304346 }
305347 },
306 - // get the embed vlc object
307 - getVID : function () {
308 - this.vid = $j( '#' + this.pid ).get( 0 );
 348+
 349+ /**
 350+ * Get /update the playerElement value
 351+ */
 352+ getPlayerElement : function () {
 353+ this.playerElement = $j( '#' + this.pid ).get( 0 );
 354+ },
 355+
 356+ /**
 357+ * Bindings for the Video Element Events
 358+ */
 359+
 360+ /**
 361+ * Local method for seeking event
 362+ * fired when "seeking"
 363+ */
 364+ onseeking:function() {
 365+ js_log( "onseeking" );
 366+ this.seeking = true;
 367+ this.setStatus( gM( 'mwe-seeking' ) );
 368+ },
 369+
 370+ /**
 371+ * Local method for seeked event
 372+ * fired when done seeking
 373+ */
 374+ onseeked: function() {
 375+ js_log("onseeked");
 376+ this.seeking = false;
 377+ },
 378+
 379+ /**
 380+ * Local method for can play through
 381+ * fired when done video can play through without re-buffering
 382+ */
 383+ oncanplaythrough : function() {
 384+ js_log('f:oncanplaythrough');
 385+ this.getPlayerElement();
 386+ if ( ! this.paused )
 387+ this.playerElement.play();
 388+ },
 389+
 390+ /**
 391+ * Local method for metadata ready
 392+ * fired when metadata becomes avaliable
 393+ *
 394+ * Used to update the media duration to
 395+ * accurately reflect the src duration
 396+ */
 397+ onloadedmetadata: function() {
 398+ this.getPlayerElement();
 399+ js_log( 'f:onloadedmetadata metadata ready (update duration)' );
 400+ // update duration if not set (for now trust the getDuration more than this.playerElement.duration
 401+ if ( this.getDuration() == 0 && ! isNaN( this.playerElement.duration ) ) {
 402+ js_log( 'updaed duration via native video duration: ' + this.playerElement.duration )
 403+ this.duration = this.playerElement.duration;
 404+ }
 405+
 406+ //Fire "onLoaded" flags if set
 407+ if( typeof this.onLoadedCallback == 'function' ){
 408+ this.onLoadedCallback();
 409+ }
 410+ },
 411+
 412+ /**
 413+ * Local method for progress event
 414+ * fired as the video is downloaded / buffered
 415+ *
 416+ * Used to update the bufferedPercent
 417+ */
 418+ onprogress: function( e ) {
 419+ this.bufferedPercent = e.loaded / e.total;
 420+ },
 421+
 422+ /**
 423+ * Local method for progress event
 424+ * fired as the video is downloaded / buffered
 425+ *
 426+ * Used to update the bufferedPercent
 427+ */
 428+ onended: function() {
 429+ var _this = this
 430+ this.getPlayerElement();
 431+ js_log( 'native:onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() );
 432+ // if we just started (under 1 second played) & duration is much longer.. don't run onClipDone just yet . (bug in firefox native sending onended event early)
 433+ if ( this.playerElement.currentTime < 1 && this.getDuration() > 1 && this.grab_try_count < 5 ) {
 434+ js_log( 'native on ended called with time:' + this.playerElement.currentTime + ' of total real dur: ' + this.getDuration() + ' attempting to reload src...' );
 435+ var doRetry = function() {
 436+ _this.urlAppend = 'retry_src=' + _this.grab_try_count;
 437+ _this.doEmbedHTML();
 438+ _this.grab_try_count++;
 439+ }
 440+ setTimeout( doRetry, 100 );
 441+ } else {
 442+ js_log( 'native onClipDone done call' );
 443+ this.onClipDone();
 444+ }
309445 }
310446 };
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/kplayerEmbed.js
@@ -1,5 +1,12 @@
 2+/*
 3+* The "kaltura player" embedPlayer interface for fallback h.264 and flv video format support
 4+*/
25 var kplayerEmbed = {
 6+
 7+ // Instance name:
38 instanceOf:'kplayerEmbed',
 9+
 10+ // List of supported features:
411 supports: {
512 'play_head':true,
613 'pause':true,
@@ -9,6 +16,10 @@
1017 'overlay':false,
1118 'fullscreen':false
1219 },
 20+
 21+ /*
 22+ * Get the Embed html by wraping the embed code in the embed container:
 23+ */
1324 getEmbedHTML : function () {
1425 var embed_code = this.getEmbedObj();
1526 alert
@@ -19,6 +30,10 @@
2031 js_log( "return embed html" );
2132 return this.wrapEmebedContainer( embed_code );
2233 },
 34+
 35+ /**
 36+ * Get the plugin embed html
 37+ */
2338 getEmbedObj:function() {
2439 var player_path = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/kaltura-player';
2540 return '<object width="' + this.width + '" height="' + this.height + '" '+
@@ -40,65 +55,92 @@
4156 '<param value="opaque" name="wmode"/>'+
4257 '</object>';
4358 },
 59+
 60+ /**
 61+ * javascript run post player embeding
 62+ */
4463 postEmbedJS:function() {
4564 var _this = this;
46 - this.getKDP();
47 - //alert( this.kdp );
48 - if( this.kdp && this.kdp.insertMedia){
 65+ this.getPlayerElement();
 66+ //alert( this.playerElement );
 67+ if( this.playerElement && this.playerElement.insertMedia){
4968 // Add KDP listeners
5069
51 - //this.kdp.addJsListener("doPlay","kdpDoOnPlay");
52 - //this.kdp.addJsListener("doStop","kdpDoOnStop");
 70+ //this.playerElement.addJsListener("doPlay","kdpDoOnPlay");
 71+ //this.playerElement.addJsListener("doStop","kdpDoOnStop");
5372 //myKdp.addJsListener("fastForward","kdpDoOnFF");
5473
55 - _this.bindKdpFunc( 'doPause', 'kdpPause' );
56 - _this.bindKdpFunc( 'doPlay', 'play' );
57 - _this.bindKdpFunc( 'playerPlayEnd', 'onClipDone' );
 74+ _this.bindPlayerFunction( 'doPause', 'onPause' );
 75+ _this.bindPlayerFunction( 'doPlay', 'play' );
 76+ _this.bindPlayerFunction( 'playerPlayEnd', 'onClipDone' );
5877
5978 // KDP player likes an absolute url for the src:
6079 var src = mw.absoluteUrl( _this.getSrc() );
6180 js_log('play src: ' + src);
 81+
6282 // Insert the src:
63 - this.kdp.insertMedia("-1", src, 'true' );
64 - this.kdp.dispatchKdpEvent('doPlay');
 83+ this.playerElement.insertMedia( "-1", src, 'true' );
 84+ this.playerElement.dispatchKdpEvent( 'doPlay' );
6585
6686 // Start the monitor
6787 this.monitor();
6888 }else{
69 - js_log('insert media: not defiend' + typeof this.kdp.insertMedia );
 89+ js_log('insert media: not defiend' + typeof this.playerElement.insertMedia );
7090 setTimeout( function(){
7191 _this.postEmbedJS();
7292 }, 25);
7393 }
7494 },
 95+
7596 /**
76 - * bindKdpFunc
 97+ * Bind a Player Function,
7798 *
 99+ * Does some tricker to bind to "this" player instance:
 100+ *
78101 * @param {String} flash binding name
79102 * @param {String} function callback name
80103 */
81 - bindKdpFunc:function( bName, fName ){
 104+ bindPlayerFunction:function( bName, fName ){
82105 var cbid = fName + '_cb_' + this.id.replace(' ', '_');
83106 eval( 'window[ \'' + cbid +'\' ] = function(){$j(\'#' + this.id + '\').get(0).'+ fName +'();}' );
84 - this.kdp.addJsListener( bName , cbid);
 107+ this.playerElement.addJsListener( bName , cbid);
85108 },
86 - kdpPause:function(){
 109+
 110+ /**
 111+ * on Pause callback from the kaltura flash player
 112+ * calls parent_pause to update the interface
 113+ */
 114+ onPause:function(){
87115 this.parent_pause();
88116 },
 117+
 118+ /**
 119+ * play method
 120+ * calls parent_play to update the interface
 121+ */
89122 play:function() {
90 - if( this.kdp && this.kdp.dispatchKdpEvent )
91 - this.kdp.dispatchKdpEvent('doPlay');
 123+ if( this.playerElement && this.playerElement.dispatchKdpEvent )
 124+ this.playerElement.dispatchKdpEvent('doPlay');
92125 this.parent_play();
93126 },
 127+
 128+ /**
 129+ * pause method
 130+ * calls parent_pause to update the interface
 131+ */
94132 pause:function() {
95 - this.kdp.dispatchKdpEvent('doPause');
 133+ this.playerElement.dispatchKdpEvent('doPause');
96134 this.parent_pause();
97135 },
 136+
 137+ /**
 138+ * Issues a seek to the playerElement
 139+ */
98140 doSeek:function( prec ){
99141 var _this = this;
100 - if( this.kdp ){
 142+ if( this.playerElement ){
101143 var seek_time = prec * this.getDuration();
102 - this.kdp.dispatchKdpEvent('doSeek', seek_time);
 144+ this.playerElement.dispatchKdpEvent('doSeek', seek_time);
103145 // Kdp is missing seek done callback
104146 setTimeout(function(){
105147 _this.seeking= false;
@@ -106,35 +148,37 @@
107149 }
108150 this.monitor();
109151 },
110 - updateVolumen:function( perc ) {
111 - if( this.kdp && this.kdp.dispatchKdpEvent )
112 - this.kdp.dispatchKdpEvent('volumeChange', perc);
 152+
 153+ /**
 154+ * Issues a volume update to the playerElement
 155+ */
 156+ updateVolumen:function( percentage ) {
 157+ if( this.playerElement && this.playerElement.dispatchKdpEvent )
 158+ this.playerElement.dispatchKdpEvent('volumeChange', percentage);
113159 },
 160+
 161+ /**
 162+ * Monitors playback updating the current Time
 163+ */
114164 monitor:function() {
115 - if( this.kdp && this.kdp.getMediaSeekTime ){
116 - this.currentTime = this.kdp.getMediaSeekTime();
 165+ if( this.playerElement && this.playerElement.getMediaSeekTime ){
 166+ this.currentTime = this.playerElement.getMediaSeekTime();
117167 }
118168 this.parent_monitor();
119169 },
120 - // get the embed fla object
121 - getKDP: function () {
122 - this.kdp = document.getElementById( this.pid );
 170+
 171+ /**
 172+ * Get the embed fla object player Element
 173+ */
 174+ getPlayerElement: function () {
 175+ this.playerElement = document.getElementById( this.pid );
123176 }
124177 }
125 -
126 -function kdpDoOnPause( player ){
127 - var cat = player
128 - debugger;
129 -}
130 -
 178+/**
 179+* function called once player is ready.
 180+*
 181+* NOTE: playerID is not always passed so we can't use this:
 182+*/
131183 function onKdpReady( playerId ) {
132 - js_log( "IN THEORY PLAYER IS READY:" + playerId);
133 - /*
134 - window.myKdp=get(playerId);
135 - get("Player_State").innerHTML="<br>&nbsp; READY (Id=" + playerId + ")";
136 - get("nowPlaying").innerHTML=(myKdp.evaluate('{entryId}'));
137 - getDuration();
138 - attachKdpEvents();
139 - addKdpListners();
140 - */
 184+ js_log( "player is ready::" + playerId);
141185 }
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/omtkEmbed.js
@@ -1,15 +1,36 @@
 2+/*
 3+* omtk media player supports ogg vorbis playback.
 4+* omtk is not feature complete and fails on some ogg vorbis streams.
 5+*
 6+* This script will be depreciated unless the omtk flash applet improves in quality
 7+*/
28 var omtkEmbed = {
 9+
 10+ // Instance name
311 instanceOf:'omtkEmbed',
 12+
 13+ // Supported player features
414 supports: {
515 'pause':true,
6 - 'time_display':true
 16+ 'time_display':true
717 },
 18+
 19+ /**
 20+ * Wrap the embed code
 21+ */
822 getEmbedHTML : function () {
 23+ var _this = this;
924 var embed_code = this.getEmbedObj();
1025 // Need omtk to fire an onReady event.
11 - setTimeout( '$j(\'#' + this.id + '\').get(0).postEmbedJS()', 2000 );
 26+ setTimeout( function(){
 27+ _this.postEmbedJS();
 28+ }, 2000 );
1229 return this.wrapEmebedContainer( embed_code );
1330 },
 31+
 32+ /**
 33+ * Get the embed object html
 34+ */
1435 getEmbedObj:function() {
1536 var player_path = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/omtk-fx/omtkp.swf';
1637 // player_path = 'omtkp.swf';
@@ -25,37 +46,53 @@
2647 '<!--<![endif]-->' + "\n" +
2748 '</object>';
2849 },
 50+
 51+ /**
 52+ * Run post embed javascript
 53+ */
2954 postEmbedJS:function() {
30 - this.getOMTK();
 55+ this.getPlayerElement();
3156 // play the url:
3257 js_log( "play: pid:" + this.pid + ' src:' + this.src );
3358
34 - this.omtk.play( this.src );
 59+ this.playerElement.play( this.src );
3560
3661 this.monitor();
3762 // $j('#omtk_player').get(0).play(this.src);
3863 // $j('#'+this.pid).get(0).play( this.src );
3964 },
 65+
 66+ /**
 67+ * omtk does not support pause, issue the "stop" request
 68+ */
4069 pause:function() {
4170 this.stop();
4271 },
 72+
 73+ /**
 74+ * Monitor the audio playback and update the position
 75+ */
4376 monitor:function() {
44 - if ( this.omtk.getPosition )
45 - this.currentTime = this.omtk.getPosition() / 1000;
 77+ if ( this.playerElement.getPosition )
 78+ this.currentTime = this.playerElement.getPosition() / 1000;
4679
4780 this.parent_monitor();
4881 },
49 - getOMTK : function () {
50 - this.omtk = $j( '#' + this.pid ).get( 0 );
51 - if ( !this.omtk.play )
52 - this.omtk = $j( '#' + this.pid + '_ie' ).get( 0 );
 82+
 83+ /**
 84+ * Update the playerElement pointer
 85+ */
 86+ getPlayerElement : function () {
 87+ this.playerElement = $j( '#' + this.pid ).get( 0 );
 88+ if ( !this.playerElement.play )
 89+ this.playerElement = $j( '#' + this.pid + '_ie' ).get( 0 );
5390
54 - if ( this.omtk.play ) {
 91+ if ( this.playerElement.play ) {
5592 // js_log('omtk obj is missing .play (probably not omtk obj)');
5693 }
5794 },
5895 }
59 -
 96+// Some auto-called globals (bad)
6097 function OMTK_P_complete() {
6198 js_log( 'OMTK_P_complete' );
6299 }
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js
@@ -163,7 +163,7 @@
164164 } );
165165
166166 },
167 - showPlayerselect:function() {
 167+ showPlayerSelect:function() {
168168 this.cur_clip.embed.showPlayerselect();
169169 },
170170 closeDisplayedHTML:function() {
@@ -552,7 +552,7 @@
553553 setStatus:function( value ) {
554554 $j( '#' + this.id + ' .time-disp' ).text( value );
555555 },
556 - setSliderValue:function( value ) {
 556+ updatePlayHead:function( value ) {
557557 // slider is on 1000 scale:
558558 var val = parseInt( value * 1000 );
559559 //js_log( 'update slider: #' + this.id + ' .play_head to ' + val );
@@ -689,7 +689,7 @@
690690 var clip_time = this.cur_clip.dur_offset;
691691 }
692692
693 - this.setSliderValue( clip_time / this.getDuration() );
 693+ this.updatePlayHead( clip_time / this.getDuration() );
694694 }
695695 },
696696 playPrev: function() {
@@ -857,7 +857,7 @@
858858 // reset the currentTime:
859859 this.currentTime = 0;
860860 // rest the sldier
861 - this.setSliderValue( 0 );
 861+ this.updatePlayHead( 0 );
862862 // FIXME still some issues with "stoping" and reseting the playlist
863863 },
864864 doSeek:function( v ) {
@@ -1364,9 +1364,9 @@
13651365 setStatus:function( value ) {
13661366 // status updates handled by playlist obj
13671367 },
1368 - setSliderValue:function( value ) {
1369 - //js_log( 'PlMvEmbed:setSliderValue:' + value );
1370 - // setSlider value handled by playlist obj
 1368+ updatePlayHead:function( value ) {
 1369+ //js_log( 'PlMvEmbed:updatePlayHead:' + value );
 1370+ // updatePlayHead handled by playlist obj
13711371 }
13721372 }
13731373
@@ -1522,14 +1522,16 @@
15231523 if ( this.currentTime > this.getDuration() )
15241524 this.stop();
15251525
 1526+
 1527+ var relative_time = ( this.start_offset ) ? ( this.currentTime - this.start_offset) : this.currentTime;
15261528 // update the playlist current time:
15271529 // check for a trsnOut from the previus clip to subtract
1528 - this.currentTime = this.cur_clip.dur_offset + this.cur_clip.embed.relativeCurrentTime();
 1530+ this.currentTime = this.cur_clip.dur_offset + relative_time;
15291531
15301532 // update slider:
15311533 if ( !this.userSlide ) {
15321534 this.setStatus( seconds2npt( this.currentTime ) + '/' + seconds2npt( this.getDuration() ) );
1533 - this.setSliderValue( this.currentTime / this.getDuration() );
 1535+ this.updatePlayHead( this.currentTime / this.getDuration() );
15341536 }
15351537 // pre-load any future clips:
15361538 this.loadFutureClips();

Status & tagging log