r50085 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50084‎ | r50085 | r50086 >
Date:23:41, 30 April 2009
Author:dale
Status:deferred
Tags:
Comment:
uploader interface updates
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvUploader.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_baseEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvUploader.js
@@ -196,8 +196,8 @@
197197
198198 //check for post action override:
199199 if( _this.form_post_override ){
200 - alert('woudld submit here');
201 - //return true;
 200+ //alert('woudld submit here');
 201+ return true;
202202 }
203203
204204
@@ -233,7 +233,7 @@
234234 return js_error( 'Error: can\'t autodetect mode without api url' );
235235 do_api_req( {
236236 'data':{ 'action':'paraminfo','modules':'upload' },
237 - 'url':_this.api_url
 237+ 'url' :_this.api_url
238238 }, function(data){
239239 if( typeof data.paraminfo == 'undefined' || typeof data.paraminfo.modules == 'undefined' )
240240 return js_error( 'Error: bad api results' );
@@ -243,7 +243,7 @@
244244 }else{
245245 js_log( 'Autodetect Upload Mode: api ' );
246246 _this.upload_mode = 'api';
247 - //make sure chunks are supported:
 247+ //check to see if chunks are supported:
248248 for( var i in data.paraminfo.modules[0].parameters ){
249249 var pname = data.paraminfo.modules[0].parameters[i].name;
250250 if( pname == 'enablechunks' ){
@@ -262,7 +262,7 @@
263263 doUploadSwitch:function(){
264264 js_log('mvUPload:doUploadSwitch()');
265265 var _this = this;
266 - //issue a post req:
 266+ //issue a normal post request
267267 if( _this.upload_mode == 'post' || $j('#wpSourceTypeFile').get(0).checked ){
268268 //update the status
269269 $j('#dlbox-centered').html('<h5>' + _this.getProgressTitle() + '</h5>' +
@@ -270,15 +270,29 @@
271271 );
272272
273273 //do normal post upload no status indicators (also since its a file I think we have to submit the form)
274 - _this.form_post_override=true;
275 - //js_log('run form submit!!');
276 - _this.editForm.submit();
277 - }else if( _this.upload_mode == 'api'){
278 - //do api upload
 274+ _this.form_post_override = true;
 275+ //trick the browser into thinking the wpUpload button was pressed (there might be a cleaner way to do this)
 276+ $j(_this.editForm).append('<input type="hidden" name="wpUpload" value="' + $j('#wpUpload').val() + '"/>');
 277+ //do the submit :
 278+ _this.editForm.submit();
 279+ }else if( _this.upload_mode == 'api' && $j('#wpSourceTypeURL').get(0).checked){
 280+ //if the api is supported.. && source type is http do upload with http status updates
 281+ _this.doHttpUpload();
279282 }else{
280283 js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode );
281284 }
282285 },
 286+ doHttpUpload:function(){
 287+ //build the api query:
 288+ js_log('do doHttpUpload upload!');
 289+
 290+ /*do_api_req( {
 291+ 'data':{ 'action':'upload','modules':'upload' },
 292+ 'url':_this.api_url
 293+ }, function(data){
 294+ js_log('result data:')
 295+ }); */
 296+ },
283297 getProgressTitle:function(){
284298 return gM('upload-in-progress');
285299 },
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -68,6 +68,7 @@
6969 //all default msg in [English] should be overwritten by the CMS language msg system.
7070 loadGM({
7171 "loading_txt":"loading <blink>...</blink>",
 72+
7273 "loading_plugin" : "loading plugin<blink>...</blink>",
7374 "select_playback" : "Set Playback Preference",
7475 "link_back" : "Link Back",
@@ -142,7 +143,7 @@
143144 mv_get_loading_img('top:30px;left:30px') +
144145 '</div>');
145146 }
146 -
 147+//library to load core mv_embed libraries
147148 var mvBaseLoader = {
148149 calledloadBaseLibs:false,
149150 callbacks:new Array(),
@@ -326,250 +327,6 @@
327328
328329
329330
330 -/**
331 - * mediaPlayer represents a media player plugin.
332 - * @param {String} id id used for the plugin.
333 - * @param {Array<String>} supported_types n array of supported MIME types.
334 - * @param {String} library external script containing the plugin interface code. (mv_<library>Embed.js)
335 - * @constructor
336 - */
337 -function mediaPlayer(id, supported_types, library)
338 -{
339 - this.id=id;
340 - this.supported_types = supported_types;
341 - this.library = library;
342 - this.loaded = false;
343 - this.loading_callbacks = new Array();
344 - return this;
345 -}
346 -mediaPlayer.prototype =
347 -{
348 - id:null,
349 - supported_types:null,
350 - library:null,
351 - loaded:false,
352 - loading_callbacks:null,
353 - supportsMIMEType : function(type)
354 - {
355 - for (var i=0; i < this.supported_types.length; i++)
356 - if(this.supported_types[i] == type)
357 - return true;
358 - return false;
359 - },
360 - getName : function()
361 - {
362 - return gM('mv_ogg-player-' + this.id);
363 - },
364 - load : function(callback)
365 - {
366 - if(this.loaded)
367 - {
368 - js_log('plugin loaded, scheduling immediate processing');
369 - callback();
370 - }
371 - else
372 - {
373 - var _this = this;
374 - var plugin_path = mv_embed_path + 'libEmbedVideo/mv_'+this.library+'Embed.js';
375 - //add the callback:
376 - this.loading_callbacks.push(callback);
377 - //jQuery based get script does not work so well.
378 - /*$j.getScript(plugin_path, function(){
379 - js_log(_this.id + ' plugin loaded');
380 - _this.loaded = true;
381 - for(var i in _this.loading_callbacks)
382 - _this.loading_callbacks[i]();
383 - _this.loading_callbacks = null;
384 - });*/
385 -
386 - eval('var lib = {"'+this.library+'Embed":\'libEmbedVideo/mv_'+this.library+'Embed.js\'}');
387 - js_log('DO LOAD: '+this.library);
388 - mvJsLoader.doLoad(lib,function(){
389 - //js_log( 'type of lib: ' + eval( 'typeof ' + this.library + 'Embed' ) );
390 - //js_log(_this.id + ' plugin loaded');
391 - _this.loaded = true;
392 - //make sure we have not already cleared the callbacks:
393 - if( _this.loading_callbacks != null){
394 - for(var i=0; i < _this.loading_callbacks.length; i++ ){
395 - if(_this.loading_callbacks[i])
396 - _this.loading_callbacks[i]();
397 - }
398 - }
399 - _this.loading_callbacks = null;
400 -
401 - });
402 - }
403 - }
404 -}
405 -/* players and supported mime types
406 -@@todo ideally we query the plugin to get what mime types it supports in practice not always reliable/avaliable
407 -*/
408 -var flowPlayer = new mediaPlayer('flowplayer',['video/x-flv', 'video/h264'],'flash');
409 -
410 -var cortadoPlayer = new mediaPlayer('cortado',['video/ogg'],'java');
411 -var videoElementPlayer = new mediaPlayer('videoElement',['video/ogg'],'native');
412 -var vlcMozillaPlayer = new mediaPlayer('vlc-mozilla',['video/ogg', 'video/x-flv', 'video/mp4', 'video/h264'],'vlc');
413 -var vlcActiveXPlayer = new mediaPlayer('vlc-activex',['video/ogg', 'video/x-flv', 'video/mp4', 'video/h264'],'vlc');
414 -
415 -var oggPluginPlayer = new mediaPlayer('oggPlugin',['video/ogg'],'generic');
416 -var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime');
417 -var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime');
418 -
419 -var htmlPlayer = new mediaPlayer('html',['text/html', 'image/jpeg', 'image/png', 'image/svg'], 'html');
420 -
421 -/**
422 - * mediaPlayers is a collection of mediaPlayer objects supported by the client.
423 - * It could be merged with embedTypes, since there is one embedTypes per script
424 - * and one mediaPlayers per embedTypes.
425 - */
426 -function mediaPlayers()
427 -{
428 - this.init();
429 -}
430 -
431 -mediaPlayers.prototype =
432 -{
433 - players : null,
434 - preference : null,
435 - default_players : {},
436 - init : function()
437 - {
438 - this.players = new Array();
439 - this.loadPreferences();
440 -
441 - //set up default players order for each library type
442 - this.default_players['video/x-flv'] = ['flash','vlc'];
443 - this.default_players['video/h264'] = ['flash', 'vlc'];
444 -
445 - this.default_players['video/ogg'] = ['native','vlc','java', 'generic'];
446 - this.default_players['application/ogg'] = ['native','vlc','java', 'generic'];
447 -
448 - this.default_players['video/mp4'] = ['vlc'];
449 -
450 - this.default_players['text/html'] = ['html'];
451 - this.default_players['image/jpeg'] = ['html'];
452 -
453 - },
454 - addPlayer : function(player, mime_type)
455 - {
456 - //js_log('Adding ' + player.id + ' with mime_type ' + mime_type);
457 - for (var i =0; i < this.players.length; i++){
458 - if (this.players[i].id == player.id)
459 - {
460 - if(mime_type!=null)
461 - {
462 - //make sure the mime_type is not already there:
463 - var add_mime = true;
464 - for(var j=0; j < this.players[i].supported_types.length; j++ ){
465 - if( this.players[i].supported_types[j]== mime_type)
466 - add_mime=false;
467 - }
468 - if(add_mime)
469 - this.players[i].supported_types.push(mime_type);
470 - }
471 - return;
472 - }
473 - }
474 - //player not found:
475 - if(mime_type!=null)
476 - player.supported_types.push(mime_type);
477 -
478 - this.players.push( player );
479 - },
480 - getMIMETypePlayers : function(mime_type)
481 - {
482 - var mime_players = new Array();
483 - var _this = this;
484 - var inx = 0;
485 - if( this.default_players[mime_type] ){
486 - $j.each( this.default_players[mime_type], function(d, lib){
487 - var library = _this.default_players[mime_type][d];
488 - for ( var i=0; i < _this.players.length; i++ ){
489 - if ( _this.players[i].library == library && _this.players[i].supportsMIMEType(mime_type) ){
490 - mime_players[ inx ] = _this.players[i];
491 - inx++;
492 - }
493 - }
494 - });
495 - }
496 - return mime_players;
497 - },
498 - defaultPlayer : function(mime_type)
499 - {
500 - js_log("f:defaultPlayer: " + mime_type);
501 - var mime_players = this.getMIMETypePlayers(mime_type);
502 - if( mime_players.length > 0)
503 - {
504 - // check for prior preference for this mime type
505 - for( var i=0; i < mime_players.length; i++ ){
506 - if( mime_players[i].id==this.preference[mime_type] )
507 - return mime_players[i];
508 - }
509 - // otherwise just return the first compatible player
510 - // (it will be chosen according to the default_players list
511 - return mime_players[0];
512 - }
513 - js_log( 'No default player found for ' + mime_type );
514 - return null;
515 - },
516 - userSelectFormat : function (mime_format){
517 - this.preference['format_prefrence'] = mime_format;
518 - this.savePreferences();
519 - },
520 - userSelectPlayer : function(player_id, mime_type)
521 - {
522 - var selected_player=null;
523 - for(var i=0; i < this.players.length; i++){
524 - if(this.players[i].id == player_id)
525 - {
526 - selected_player = this.players[i];
527 - js_log('choosing ' + player_id + ' for ' + mime_type);
528 - this.preference[mime_type]=player_id;
529 - this.savePreferences();
530 - break;
531 - }
532 - }
533 - if( selected_player )
534 - {
535 - for(var i=0; i < global_player_list.length; i++)
536 - {
537 - var embed = $j('#'+global_player_list[i]).get(0);
538 - if(embed.media_element.selected_source && (embed.media_element.selected_source.mime_type == mime_type))
539 - {
540 - embed.selectPlayer(selected_player);
541 - js_log('using ' + embed.selected_player.getName() + ' for ' + embed.media_element.selected_source.getTitle());
542 - }
543 - }
544 - }
545 - },
546 - loadPreferences : function()
547 - {
548 - this.preference = new Object();
549 - // see if we have a cookie set to a clientSupported type:
550 - var cookieVal = getCookie( 'ogg_player_exp' );
551 - if (cookieVal)
552 - {
553 - var pairs = cookieVal.split('&');
554 - for(var i=0; i < pairs.length; i++)
555 - {
556 - var name_value = pairs[i].split('=');
557 - this.preference[name_value[0]]=name_value[1];
558 - //js_log('load preference for ' + name_value[0] + ' is ' + name_value[1]);
559 - }
560 - }
561 - },
562 - savePreferences : function()
563 - {
564 - var cookieVal = '';
565 - for(var i in this.preference)
566 - cookieVal+= i + '='+ this.preference[i] + '&';
567 -
568 - cookieVal=cookieVal.substr(0, cookieVal.length-1);
569 - var week = 7*86400*1000;
570 - setCookie( 'ogg_player_exp', cookieVal, week, false, false, false, false );
571 - }
572 -};
573 -
574331 function getCookie ( cookieName ) {
575332 var m = document.cookie.match( cookieName + '=(.*?)(;|$)' );
576333 //js_log('getCookie:' + cookieName + ' v:' + (m ? unescape( m[1] ) : false));
@@ -589,148 +346,6 @@
590347 (domain ? ("; domain=" + domain) : "") +
591348 (secure ? "; secure" : "");
592349 }
593 -/*
594 - * embedTypes object handles setting and getting of supported embed types:
595 - * closely mirrors OggHandler so that its easier to share efforts in this area:
596 - * http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/OggHandler/OggPlayer.js
597 - */
598 -var embedTypes = {
599 - // List of players
600 - players: null,
601 - detect_done:false,
602 - init: function(){
603 - //detect supported types
604 - this.detect();
605 - this.detect_done=true;
606 - },
607 - clientSupports: { 'thumbnail' : true },
608 - detect: function() {
609 - js_log("running detect");
610 - this.players = new mediaPlayers();
611 - //every browser supports html rendering:
612 - this.players.addPlayer( htmlPlayer );
613 - // First some browser detection
614 - this.msie = ( navigator.appName == "Microsoft Internet Explorer" );
615 - this.msie6 = ( navigator.userAgent.indexOf("MSIE 6")===false);
616 - this.opera = ( navigator.appName == 'Opera' );
617 - this.safari = ( navigator.vendor && navigator.vendor.substr( 0, 5 ) == 'Apple' );
618 -
619 - // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to
620 - // search navigator.mimeTypes to see if it's installed
621 - var javaEnabled = navigator.javaEnabled();
622 - // In Opera, navigator.javaEnabled() is all there is
623 - var invisibleJava = this.opera;
624 - // Some browsers filter out duplicate mime types, hiding some plugins
625 - var uniqueMimesOnly = this.opera || this.safari;
626 - // Opera will switch off javaEnabled in preferences if java can't be found.
627 - // And it doesn't register an application/x-java-applet mime type like Mozilla does.
628 - if ( invisibleJava && javaEnabled )
629 - this.players.addPlayer( cortadoPlayer );
630 -
631 - // ActiveX plugins
632 - if(this.msie){
633 - // check for flash
634 - if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash'))
635 - this.players.addPlayer(flowPlayer);
636 - // VLC
637 - if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) )
638 - this.players.addPlayer(vlcActiveXPlayer);
639 - // Java
640 - if ( javaEnabled && this.testActiveX( 'JavaWebStart.isInstalled' ) )
641 - this.players.addPlayer(cortadoPlayer);
642 - // quicktime
643 - if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) )
644 - this.players.addPlayer(quicktimeActiveXPlayer);
645 - }
646 - // <video> element
647 - if ( typeof HTMLVideoElement == 'object' // Firefox, Safari
648 - || typeof HTMLVideoElement == 'function' ) // Opera
649 - {
650 - //do another test for safari:
651 - if( this.safari ){
652 - var dummyvid = document.createElement("video");
653 - if (dummyvid.canPlayType("video/ogg;codecs=\"theora,vorbis\"") == "probably")
654 - {
655 - this.players.addPlayer( videoElementPlayer );
656 - } else {
657 - /* could add some user nagging to install the xiph qt */
658 - }
659 - }else{
660 - this.players.addPlayer( videoElementPlayer );
661 - }
662 - }
663 -
664 -
665 - // Mozilla plugins
666 - if( navigator.mimeTypes && navigator.mimeTypes.length > 0) {
667 - for ( var i = 0; i < navigator.mimeTypes.length; i++ ) {
668 - var type = navigator.mimeTypes[i].type;
669 - var semicolonPos = type.indexOf( ';' );
670 - if ( semicolonPos > -1 ) {
671 - type = type.substr( 0, semicolonPos );
672 - }
673 - //js_log('on type: '+type);
674 - var pluginName = navigator.mimeTypes[i].enabledPlugin ? navigator.mimeTypes[i].enabledPlugin.name : '';
675 - if ( !pluginName ) {
676 - // In case it is null or undefined
677 - pluginName = '';
678 - }
679 - if ( pluginName.toLowerCase() == 'vlc multimedia plugin' || pluginName.toLowerCase() == 'vlc multimedia plug-in' ) {
680 - this.players.addPlayer(vlcMozillaPlayer, type);
681 - continue;
682 - }
683 -
684 - if ( javaEnabled && type == 'application/x-java-applet' ) {
685 - this.players.addPlayer(cortadoPlayer);
686 - continue;
687 - }
688 -
689 - if ( type == 'application/ogg' ) {
690 - if ( pluginName.toLowerCase() == 'vlc multimedia plugin' )
691 - this.players.addPlayer(vlcMozillaPlayer, type);
692 - else if ( pluginName.indexOf( 'QuickTime' ) > -1 )
693 - this.players.addPlayer(quicktimeMozillaPlayer);
694 - else
695 - this.players.addPlayer(oggPluginPlayer);
696 - continue;
697 - } else if ( uniqueMimesOnly ) {
698 - if ( type == 'application/x-vlc-player' ) {
699 - this.players.addPlayer(vlcMozillaPlayer, type);
700 - continue;
701 - } else if ( type == 'video/quicktime' ) {
702 - this.players.addPlayer(quicktimeMozillaPlayer);
703 - continue;
704 - }
705 - }
706 -
707 - /*if ( type == 'video/quicktime' ) {
708 - this.players.addPlayer(vlcMozillaPlayer, type);
709 - continue;
710 - }*/
711 - if(type=='application/x-shockwave-flash'){
712 - this.players.addPlayer(flowPlayer);
713 - continue;
714 - }
715 - }
716 - }
717 - //@@The xiph quicktime component does not work well with annodex streams (temporarly disable)
718 - //this.clientSupports['quicktime-mozilla'] = false;
719 - //this.clientSupports['quicktime-activex'] = false;
720 - //js_log(this.clientSupports);
721 - },
722 - testActiveX : function ( name ) {
723 - var hasObj = true;
724 - try {
725 - // No IE, not a class called "name", it's a variable
726 - var obj = new ActiveXObject( '' + name );
727 - } catch ( e ) {
728 - hasObj = false;
729 - }
730 - return hasObj;
731 - }
732 -}
733 -//set up embedTypes
734 -embedTypes.init();
735350
736351 //load an external JS (similar to jquery .require plugin)
737352 //but checks for object availability rather than load state
@@ -809,11 +424,11 @@
810425 * set DOM ready callback to init_mv_embed
811426 *********************************************/
812427 // for Mozilla browsers
813 -if (document.addEventListener && !embedTypes.safari ) {
 428+if (document.addEventListener ) {
814429 document.addEventListener("DOMContentLoaded", function(){init_mv_embed()}, false);
815430 }else{
816431 //backup "onload" method in case on DOMContentLoaded does not exist
817 - window.onload = function(){init_mv_embed()};
 432+ window.onload = function(){ init_mv_embed() };
818433 }
819434 //for IE (temporarily disabled causing empty document rewrites:
820435 /*if (document.all && !window.opera){ //Crude test for IE
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_baseEmbed.js
@@ -2057,4 +2057,394 @@
20582058 //update status:
20592059 $j('#mv_time_'+id).html(value);
20602060 }
2061 -}
\ No newline at end of file
 2061+}
 2062+
 2063+
 2064+
 2065+
 2066+/**
 2067+ * mediaPlayer represents a media player plugin.
 2068+ * @param {String} id id used for the plugin.
 2069+ * @param {Array<String>} supported_types n array of supported MIME types.
 2070+ * @param {String} library external script containing the plugin interface code. (mv_<library>Embed.js)
 2071+ * @constructor
 2072+ */
 2073+function mediaPlayer(id, supported_types, library)
 2074+{
 2075+ this.id=id;
 2076+ this.supported_types = supported_types;
 2077+ this.library = library;
 2078+ this.loaded = false;
 2079+ this.loading_callbacks = new Array();
 2080+ return this;
 2081+}
 2082+mediaPlayer.prototype =
 2083+{
 2084+ id:null,
 2085+ supported_types:null,
 2086+ library:null,
 2087+ loaded:false,
 2088+ loading_callbacks:null,
 2089+ supportsMIMEType : function(type)
 2090+ {
 2091+ for (var i=0; i < this.supported_types.length; i++)
 2092+ if(this.supported_types[i] == type)
 2093+ return true;
 2094+ return false;
 2095+ },
 2096+ getName : function()
 2097+ {
 2098+ return gM('mv_ogg-player-' + this.id);
 2099+ },
 2100+ load : function(callback)
 2101+ {
 2102+ if(this.loaded)
 2103+ {
 2104+ js_log('plugin loaded, scheduling immediate processing');
 2105+ callback();
 2106+ }
 2107+ else
 2108+ {
 2109+ var _this = this;
 2110+ var plugin_path = mv_embed_path + 'libEmbedVideo/mv_'+this.library+'Embed.js';
 2111+ //add the callback:
 2112+ this.loading_callbacks.push(callback);
 2113+ //jQuery based get script does not work so well.
 2114+ /*$j.getScript(plugin_path, function(){
 2115+ js_log(_this.id + ' plugin loaded');
 2116+ _this.loaded = true;
 2117+ for(var i in _this.loading_callbacks)
 2118+ _this.loading_callbacks[i]();
 2119+ _this.loading_callbacks = null;
 2120+ });*/
 2121+
 2122+ eval('var lib = {"'+this.library+'Embed":\'libEmbedVideo/mv_'+this.library+'Embed.js\'}');
 2123+ js_log('DO LOAD: '+this.library);
 2124+ mvJsLoader.doLoad(lib,function(){
 2125+ //js_log( 'type of lib: ' + eval( 'typeof ' + this.library + 'Embed' ) );
 2126+ //js_log(_this.id + ' plugin loaded');
 2127+ _this.loaded = true;
 2128+ //make sure we have not already cleared the callbacks:
 2129+ if( _this.loading_callbacks != null){
 2130+ for(var i=0; i < _this.loading_callbacks.length; i++ ){
 2131+ if(_this.loading_callbacks[i])
 2132+ _this.loading_callbacks[i]();
 2133+ }
 2134+ }
 2135+ _this.loading_callbacks = null;
 2136+
 2137+ });
 2138+ }
 2139+ }
 2140+}
 2141+/* players and supported mime types
 2142+@@todo ideally we query the plugin to get what mime types it supports in practice not always reliable/avaliable
 2143+*/
 2144+var flowPlayer = new mediaPlayer('flowplayer',['video/x-flv', 'video/h264'],'flash');
 2145+
 2146+var cortadoPlayer = new mediaPlayer('cortado',['video/ogg'],'java');
 2147+var videoElementPlayer = new mediaPlayer('videoElement',['video/ogg'],'native');
 2148+var vlcMozillaPlayer = new mediaPlayer('vlc-mozilla',['video/ogg', 'video/x-flv', 'video/mp4', 'video/h264'],'vlc');
 2149+var vlcActiveXPlayer = new mediaPlayer('vlc-activex',['video/ogg', 'video/x-flv', 'video/mp4', 'video/h264'],'vlc');
 2150+
 2151+var oggPluginPlayer = new mediaPlayer('oggPlugin',['video/ogg'],'generic');
 2152+var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime');
 2153+var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime');
 2154+
 2155+var htmlPlayer = new mediaPlayer('html',['text/html', 'image/jpeg', 'image/png', 'image/svg'], 'html');
 2156+
 2157+/**
 2158+ * mediaPlayers is a collection of mediaPlayer objects supported by the client.
 2159+ * It could be merged with embedTypes, since there is one embedTypes per script
 2160+ * and one mediaPlayers per embedTypes.
 2161+ */
 2162+function mediaPlayers()
 2163+{
 2164+ this.init();
 2165+}
 2166+
 2167+mediaPlayers.prototype =
 2168+{
 2169+ players : null,
 2170+ preference : null,
 2171+ default_players : {},
 2172+ init : function()
 2173+ {
 2174+ this.players = new Array();
 2175+ this.loadPreferences();
 2176+
 2177+ //set up default players order for each library type
 2178+ this.default_players['video/x-flv'] = ['flash','vlc'];
 2179+ this.default_players['video/h264'] = ['flash', 'vlc'];
 2180+
 2181+ this.default_players['video/ogg'] = ['native','vlc','java', 'generic'];
 2182+ this.default_players['application/ogg'] = ['native','vlc','java', 'generic'];
 2183+
 2184+ this.default_players['video/mp4'] = ['vlc'];
 2185+
 2186+ this.default_players['text/html'] = ['html'];
 2187+ this.default_players['image/jpeg'] = ['html'];
 2188+
 2189+ },
 2190+ addPlayer : function(player, mime_type)
 2191+ {
 2192+ //js_log('Adding ' + player.id + ' with mime_type ' + mime_type);
 2193+ for (var i =0; i < this.players.length; i++){
 2194+ if (this.players[i].id == player.id)
 2195+ {
 2196+ if(mime_type!=null)
 2197+ {
 2198+ //make sure the mime_type is not already there:
 2199+ var add_mime = true;
 2200+ for(var j=0; j < this.players[i].supported_types.length; j++ ){
 2201+ if( this.players[i].supported_types[j]== mime_type)
 2202+ add_mime=false;
 2203+ }
 2204+ if(add_mime)
 2205+ this.players[i].supported_types.push(mime_type);
 2206+ }
 2207+ return;
 2208+ }
 2209+ }
 2210+ //player not found:
 2211+ if(mime_type!=null)
 2212+ player.supported_types.push(mime_type);
 2213+
 2214+ this.players.push( player );
 2215+ },
 2216+ getMIMETypePlayers : function(mime_type)
 2217+ {
 2218+ var mime_players = new Array();
 2219+ var _this = this;
 2220+ var inx = 0;
 2221+ if( this.default_players[mime_type] ){
 2222+ $j.each( this.default_players[mime_type], function(d, lib){
 2223+ var library = _this.default_players[mime_type][d];
 2224+ for ( var i=0; i < _this.players.length; i++ ){
 2225+ if ( _this.players[i].library == library && _this.players[i].supportsMIMEType(mime_type) ){
 2226+ mime_players[ inx ] = _this.players[i];
 2227+ inx++;
 2228+ }
 2229+ }
 2230+ });
 2231+ }
 2232+ return mime_players;
 2233+ },
 2234+ defaultPlayer : function(mime_type)
 2235+ {
 2236+ js_log("f:defaultPlayer: " + mime_type);
 2237+ var mime_players = this.getMIMETypePlayers(mime_type);
 2238+ if( mime_players.length > 0)
 2239+ {
 2240+ // check for prior preference for this mime type
 2241+ for( var i=0; i < mime_players.length; i++ ){
 2242+ if( mime_players[i].id==this.preference[mime_type] )
 2243+ return mime_players[i];
 2244+ }
 2245+ // otherwise just return the first compatible player
 2246+ // (it will be chosen according to the default_players list
 2247+ return mime_players[0];
 2248+ }
 2249+ js_log( 'No default player found for ' + mime_type );
 2250+ return null;
 2251+ },
 2252+ userSelectFormat : function (mime_format){
 2253+ this.preference['format_prefrence'] = mime_format;
 2254+ this.savePreferences();
 2255+ },
 2256+ userSelectPlayer : function(player_id, mime_type)
 2257+ {
 2258+ var selected_player=null;
 2259+ for(var i=0; i < this.players.length; i++){
 2260+ if(this.players[i].id == player_id)
 2261+ {
 2262+ selected_player = this.players[i];
 2263+ js_log('choosing ' + player_id + ' for ' + mime_type);
 2264+ this.preference[mime_type]=player_id;
 2265+ this.savePreferences();
 2266+ break;
 2267+ }
 2268+ }
 2269+ if( selected_player )
 2270+ {
 2271+ for(var i=0; i < global_player_list.length; i++)
 2272+ {
 2273+ var embed = $j('#'+global_player_list[i]).get(0);
 2274+ if(embed.media_element.selected_source && (embed.media_element.selected_source.mime_type == mime_type))
 2275+ {
 2276+ embed.selectPlayer(selected_player);
 2277+ js_log('using ' + embed.selected_player.getName() + ' for ' + embed.media_element.selected_source.getTitle());
 2278+ }
 2279+ }
 2280+ }
 2281+ },
 2282+ loadPreferences : function()
 2283+ {
 2284+ this.preference = new Object();
 2285+ // see if we have a cookie set to a clientSupported type:
 2286+ var cookieVal = getCookie( 'ogg_player_exp' );
 2287+ if (cookieVal)
 2288+ {
 2289+ var pairs = cookieVal.split('&');
 2290+ for(var i=0; i < pairs.length; i++)
 2291+ {
 2292+ var name_value = pairs[i].split('=');
 2293+ this.preference[name_value[0]]=name_value[1];
 2294+ //js_log('load preference for ' + name_value[0] + ' is ' + name_value[1]);
 2295+ }
 2296+ }
 2297+ },
 2298+ savePreferences : function()
 2299+ {
 2300+ var cookieVal = '';
 2301+ for(var i in this.preference)
 2302+ cookieVal+= i + '='+ this.preference[i] + '&';
 2303+
 2304+ cookieVal=cookieVal.substr(0, cookieVal.length-1);
 2305+ var week = 7*86400*1000;
 2306+ setCookie( 'ogg_player_exp', cookieVal, week, false, false, false, false );
 2307+ }
 2308+};
 2309+
 2310+/*
 2311+ * embedTypes object handles setting and getting of supported embed types:
 2312+ * closely mirrors OggHandler so that its easier to share efforts in this area:
 2313+ * http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/OggHandler/OggPlayer.js
 2314+ */
 2315+var embedTypes = {
 2316+ // List of players
 2317+ players: null,
 2318+ detect_done:false,
 2319+ init: function(){
 2320+ //detect supported types
 2321+ this.detect();
 2322+ this.detect_done=true;
 2323+ },
 2324+ clientSupports: { 'thumbnail' : true },
 2325+ detect: function() {
 2326+ js_log("running detect");
 2327+ this.players = new mediaPlayers();
 2328+ //every browser supports html rendering:
 2329+ this.players.addPlayer( htmlPlayer );
 2330+ // First some browser detection
 2331+ this.msie = ( navigator.appName == "Microsoft Internet Explorer" );
 2332+ this.msie6 = ( navigator.userAgent.indexOf("MSIE 6")===false);
 2333+ this.opera = ( navigator.appName == 'Opera' );
 2334+ this.safari = ( navigator.vendor && navigator.vendor.substr( 0, 5 ) == 'Apple' );
 2335+
 2336+ // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to
 2337+ // search navigator.mimeTypes to see if it's installed
 2338+ var javaEnabled = navigator.javaEnabled();
 2339+ // In Opera, navigator.javaEnabled() is all there is
 2340+ var invisibleJava = this.opera;
 2341+ // Some browsers filter out duplicate mime types, hiding some plugins
 2342+ var uniqueMimesOnly = this.opera || this.safari;
 2343+ // Opera will switch off javaEnabled in preferences if java can't be found.
 2344+ // And it doesn't register an application/x-java-applet mime type like Mozilla does.
 2345+ if ( invisibleJava && javaEnabled )
 2346+ this.players.addPlayer( cortadoPlayer );
 2347+
 2348+ // ActiveX plugins
 2349+ if(this.msie){
 2350+ // check for flash
 2351+ if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash'))
 2352+ this.players.addPlayer(flowPlayer);
 2353+ // VLC
 2354+ if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) )
 2355+ this.players.addPlayer(vlcActiveXPlayer);
 2356+ // Java
 2357+ if ( javaEnabled && this.testActiveX( 'JavaWebStart.isInstalled' ) )
 2358+ this.players.addPlayer(cortadoPlayer);
 2359+ // quicktime
 2360+ if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) )
 2361+ this.players.addPlayer(quicktimeActiveXPlayer);
 2362+ }
 2363+ // <video> element
 2364+ if ( typeof HTMLVideoElement == 'object' // Firefox, Safari
 2365+ || typeof HTMLVideoElement == 'function' ) // Opera
 2366+ {
 2367+ //do another test for safari:
 2368+ if( this.safari ){
 2369+ var dummyvid = document.createElement("video");
 2370+ if (dummyvid.canPlayType("video/ogg;codecs=\"theora,vorbis\"") == "probably")
 2371+ {
 2372+ this.players.addPlayer( videoElementPlayer );
 2373+ } else {
 2374+ /* could add some user nagging to install the xiph qt */
 2375+ }
 2376+ }else{
 2377+ this.players.addPlayer( videoElementPlayer );
 2378+ }
 2379+ }
 2380+
 2381+
 2382+ // Mozilla plugins
 2383+ if( navigator.mimeTypes && navigator.mimeTypes.length > 0) {
 2384+ for ( var i = 0; i < navigator.mimeTypes.length; i++ ) {
 2385+ var type = navigator.mimeTypes[i].type;
 2386+ var semicolonPos = type.indexOf( ';' );
 2387+ if ( semicolonPos > -1 ) {
 2388+ type = type.substr( 0, semicolonPos );
 2389+ }
 2390+ //js_log('on type: '+type);
 2391+ var pluginName = navigator.mimeTypes[i].enabledPlugin ? navigator.mimeTypes[i].enabledPlugin.name : '';
 2392+ if ( !pluginName ) {
 2393+ // In case it is null or undefined
 2394+ pluginName = '';
 2395+ }
 2396+ if ( pluginName.toLowerCase() == 'vlc multimedia plugin' || pluginName.toLowerCase() == 'vlc multimedia plug-in' ) {
 2397+ this.players.addPlayer(vlcMozillaPlayer, type);
 2398+ continue;
 2399+ }
 2400+
 2401+ if ( javaEnabled && type == 'application/x-java-applet' ) {
 2402+ this.players.addPlayer(cortadoPlayer);
 2403+ continue;
 2404+ }
 2405+
 2406+ if ( type == 'application/ogg' ) {
 2407+ if ( pluginName.toLowerCase() == 'vlc multimedia plugin' )
 2408+ this.players.addPlayer(vlcMozillaPlayer, type);
 2409+ else if ( pluginName.indexOf( 'QuickTime' ) > -1 )
 2410+ this.players.addPlayer(quicktimeMozillaPlayer);
 2411+ else
 2412+ this.players.addPlayer(oggPluginPlayer);
 2413+ continue;
 2414+ } else if ( uniqueMimesOnly ) {
 2415+ if ( type == 'application/x-vlc-player' ) {
 2416+ this.players.addPlayer(vlcMozillaPlayer, type);
 2417+ continue;
 2418+ } else if ( type == 'video/quicktime' ) {
 2419+ this.players.addPlayer(quicktimeMozillaPlayer);
 2420+ continue;
 2421+ }
 2422+ }
 2423+
 2424+ /*if ( type == 'video/quicktime' ) {
 2425+ this.players.addPlayer(vlcMozillaPlayer, type);
 2426+ continue;
 2427+ }*/
 2428+ if(type=='application/x-shockwave-flash'){
 2429+ this.players.addPlayer(flowPlayer);
 2430+ continue;
 2431+ }
 2432+ }
 2433+ }
 2434+ //@@The xiph quicktime component does not work well with annodex streams (temporarly disable)
 2435+ //this.clientSupports['quicktime-mozilla'] = false;
 2436+ //this.clientSupports['quicktime-activex'] = false;
 2437+ //js_log(this.clientSupports);
 2438+ },
 2439+ testActiveX : function ( name ) {
 2440+ var hasObj = true;
 2441+ try {
 2442+ // No IE, not a class called "name", it's a variable
 2443+ var obj = new ActiveXObject( '' + name );
 2444+ } catch ( e ) {
 2445+ hasObj = false;
 2446+ }
 2447+ return hasObj;
 2448+ }
 2449+}
 2450+//set up embedTypes
 2451+embedTypes.init();
\ No newline at end of file

Status & tagging log