From: Michael Dale Date: Tue, 25 Aug 2009 15:34:45 +0000 (+0000) Subject: * related videos per commons wikiKey ( GerardoDoog ) X-Git-Tag: 1.31.0-rc.0~40065 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=b282fe0c1d0d649b3a83ad6ad89c42971f0cac31;p=lhc%2Fweb%2Fwiklou.git * related videos per commons wikiKey ( GerardoDoog ) --- diff --git a/js2/mwEmbed/example_usage/Player_RelatedVideos.html b/js2/mwEmbed/example_usage/Player_RelatedVideos.html new file mode 100644 index 0000000000..abe95a2008 --- /dev/null +++ b/js2/mwEmbed/example_usage/Player_RelatedVideos.html @@ -0,0 +1,29 @@ + + + + Simple Video Tag Usage + + + +

Simple Video Relational Audio and Video the Commons

+This Example search primitive video in the Wikimedia Commons + +
+
+ + + + +
+ Sample Relational Video And Audio
+
The Example Code ::: 
+ <video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" + poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" + src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video> +
+
+













  + + + diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index aef4cae6e2..a1ffb0b49b 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -1,6 +1,6 @@ /* the base video control JSON object with default attributes - * for supported attribute details see README - */ +* for supported attribute details see README +*/ loadGM({ "mwe-loading_plugin" : "loading plugin ...<\/blink>", @@ -45,13 +45,17 @@ loadGM({ "mwe-ogg-player-selected" : "(selected)", "mwe-ogg-player-omtkplayer" : "OMTK Flash Vorbis", "mwe-generic_missing_plugin" : "You browser does not appear to support the following playback type: $1<\/b>
Visit the Playback Methods<\/a> page to download a player.
", - "mwe-for_best_experience" : "For a better video playback experience we recommend:
Firefox 3.5<\/a>.<\/b>", + "mwe-for_best_experience" : "For a better video playback experience we recommend: Firefox 3.5<\/a>.<\/b>", "mwe-do_not_warn_again" : "Dissmiss for now.", "mwe-playerselect" : "Players", "mwe-read_before_embed" : "Please Read This<\/a> before embeding!", - "mwe-embed_site_or_blog" : "Embed on your site or blog" + "mwe-embed_site_or_blog" : "Embed on your site or blog", + "mwe_related_videos" : "Related Videos" }); +//set the globals: +var commons_api_url = 'http://commons.wikimedia.org/w/api.php'; + var default_video_attributes = { "id":null, "class":null, @@ -68,7 +72,8 @@ var default_video_attributes = { "end":null, "controls":true, "muted":false, - + "wikiTitleKey":null, + //roe url (for xml based metadata) "roe":null, //if roe includes metadata tracks we can expose a link to metadata @@ -82,15 +87,15 @@ var default_video_attributes = { "duration":null, //media duration (read from file or the temporal url) "networkState":0, - "startOffset":null, //if serving an ogg_chop segment use this to offset the presentation time + "startOffset":null, //if serving an ogg_chop segment use this to offset the presentation time //custom attributes for mv_embed: - "play_button":true, + "play_button":true, "thumbnail":null, "linkback":null, "embed_link":true, "download_link":true, - "type":null //the content type of the media + "type":null //the content type of the media }; /* * the base source attibute checks @@ -103,11 +108,11 @@ var mv_default_source_attr= new Array( 'startOffset', 'durationHint', 'start', - 'end', + 'end', 'default', 'lang' ); -//set the dismissNativeWarn flag: +//set the dismissNativeWarn flag: _global['dismissNativeWarn'] = false; /* * Converts all occurrences of
' + - embed_code + + return '
' + + embed_code + '
'; - }, + }, getEmbedHTML : function(){ //return this.wrapEmebedContainer( this.getEmbedObj() ); return 'function getEmbedHTML should be overitten by embedLib '; }, //do seek function (should be overwritten by implementing embedLibs) - // first check if seek can be done on locally downloaded content. - doSeek : function( perc ){ - if( this.supportsURLTimeEncoding() ){ + // first check if seek can be done on locally downloaded content. + doSeek : function( perc ){ + if( this.supportsURLTimeEncoding() ){ //make sure this.seek_time_sec is up-to-date: this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() ); js_log('updated seek_time_sec: ' + seconds2npt ( this.seek_time_sec) ); - this.stop(); + this.stop(); this.didSeekJump=true; //update the slider - this.setSliderValue( perc ); - } - //do play in 100ms (give things time to clear) + this.setSliderValue( perc ); + } + //do play in 100ms (give things time to clear) setTimeout('$j(\'#' + this.id + '\').get(0).play()',100); }, /* - * seeks to the requested time and issues a callback when ready + * seeks to the requested time and issues a callback when ready * (should be overwitten by client that supports frame serving) - */ + */ setCurrentTime:function( time, callback){ js_log('error: base embed setCurrentTime can not frame serve (overide via plugin)'); }, addPresTimeOffset:function(){ - //add in the offset: + //add in the offset: if(this.seek_time_sec && this.seek_time_sec!=0){ this.currentTime+=this.seek_time_sec; - }else if(this.start_offset && this.start_offset!=0){ - this.currentTime = parseFloat(this.currentTime) + parseFloat(this.start_offset); - } + }else if(this.start_offset && this.start_offset!=0){ + this.currentTime = parseFloat(this.currentTime) + parseFloat(this.start_offset); + } }, doEmbedHTML:function() { @@ -1066,90 +1074,179 @@ embedVideo.prototype = { this.closeDisplayedHTML(); // if(!this.selected_player){ -// return this.getPluginMissingHTML(); +// return this.getPluginMissingHTML(); //Set "loading" here $j('#mv_embedded_player_'+_this.id).html(''+ - '
' + - gM('mwe-loading_plugin') + - '
' + '
' + + gM('mwe-loading_plugin') + + '
' ); // schedule embedding this.selected_player.load(function() { - js_log('performing embed for ' + _this.id); - var embed_code = _this.getEmbedHTML(); + js_log('performing embed for ' + _this.id); + var embed_code = _this.getEmbedHTML(); //js_log('shopuld embed:' + embed_code); - $j('#mv_embedded_player_'+_this.id).html(embed_code); + $j('#mv_embedded_player_'+_this.id).html(embed_code); }); }, - onClipDone:function(){ - js_log('base:onClipDone'); - //stop the clip (load the thumbnail etc) - this.stop(); - this.seek_time_sec = 0; - this.setSliderValue(0); - var _this = this; - - //if the clip resolution is < 320 don't do fancy onClipDone stuff - if(this.width < 300){ - return ; - } - this.onClipDone_disp=true; - this.thumbnail_disp=true; - //make sure we are not in preview mode( no end clip actions in preview mode) - if( this.preview_mode ) - return ; - - $j('#img_thumb_'+this.id).css('zindex',1); - $j('#big_play_link_'+this.id).hide(); - //add the liks_info_div black back - $j('#dc_'+this.id).append('
'+ - '
' + - '
' + - '
' - ); - - //start animation (make thumb small in upper left add in div for "loading" - $j('#img_thumb_'+this.id).animate({ - width:parseInt(parseInt(_this.width)/2), - height:parseInt(parseInt(_this.height)/2), - top:20, - left:10 - }, - 1000, - function(){ - //animation done.. add "loading" to div if empty - if($j('#liks_info_'+_this.id).html()==''){ - $j('#liks_info_'+_this.id).html(gM('mwe-loading_txt')); - } + mvVideoAudioSearch:function(){ + var _this = this; + js_log('switch video Relational' ); + var reqObj = { + 'action':'query', + 'titles': this.wikiTitleKey, + 'generator':'categories' + }; + var req_categories= new Array(); + do_api_req( { + 'data':reqObj, + 'url': commons_api_url + }, function(data){ + req_categories = Array(); + if(data.query && data.query.pages){ + for(var pageid in data.query.pages){ + if(data.query.pages[pageid].title) + req_categories.push(data.query.pages[pageid].title); + } } - ) - //now load roe if run the showNextPrevLinks - if(this.roe && this.media_element.addedROEData==false){ - do_request(this.roe, function(data) - { - _this.media_element.addROE(data); - _this.getNextPrevLinks(); - }); - }else{ - this.getNextPrevLinks(); - } + _this.getRelatedFromCat( req_categories ); + }); }, - //@@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them. + getRelatedFromCat:function(catAry){ + js_log('getRelatedFromCat'); + var _this = this; + for ( var i= 0 ; i <= catAry.length ;i++ ){ + if(!catAry[i]) + continue; + var reqObj = { + 'action' : 'query', + 'generator' : 'categorymembers' , + 'gcmtitle' : catAry[i], + 'prop' : 'imageinfo', + 'iiprop' : 'url', + 'iiurlwidth': '80' + }; + do_api_req({ + 'data':reqObj, + 'url': commons_api_url + }, function(data){ + //empty the videos: + $j('#dc_'+ _this.id + ' .related_vids ul').html(' '); + var leyenda=""; + var titule=""; + + for(var j in data.query.pages){ + //setup poster default: + var local_poster ="http://upload.wikimedia.org/wikipedia/commons/7/79/Wiki-commons.png"; + //make sure it exists: + var page = data.query.pages[j]; + if( j > 0 && page && page['imageinfo'] ){ + if( page['imageinfo'][0].thumburl ){ + local_poster = page['imageinfo'][0].thumburl; + } + var descriptionurl = page['imageinfo'][0].descriptionurl; + var title_str = page.title.replace( /File:|.ogv$|.oga$|.ogg$/gi, "" ); + //only link to other videos: + if ( descriptionurl.match( /\.ogg$|\.ogv$|\.oga$/gi ) != null) { + var liout = '
  • ' + + '' + + '' + + '' + + '
    ' + + '' + title_str + '' + + '
    ' + + '
  • '; + $j('#dc_'+ _this.id + ' .related_vids ul').append(liout) ; + } + } + }; + js_log( 'content: ' + $j('#dc_'+ _this.id + ' .related_vids ul').html() ); + }); //end do_api_req + }; + }, + onClipDone:function(){ + js_log('base:onClipDone'); + //stop the clip (load the thumbnail etc) + this.stop(); + this.seek_time_sec = 0; + this.setSliderValue(0); + var _this = this; + + if(this.width < 300){ + return ; + } + this.onClipDone_disp=true; + this.thumbnail_disp=true; + //make sure we are not in preview mode( no end clip actions in preview mode) + if( this.preview_mode ) + return ; + + $j('#img_thumb_'+this.id).css('zindex',1); + $j('#big_play_link_'+this.id).hide(); + + //add black background + $j('#dc_'+this.id).append('
    ' + + '
    '); + + if( this.wikiTitleKey){ + $j('#dc_'+this.id).append( + ''); + $j('#img_thumb_' + this.id).fadeOut("fast"); + $j('#dc_'+ _this.id + ' .related_vids ul').html( gM('mwe-loading_txt') ); + this.mvVideoAudioSearch(); + }else{ + //add the liks_info_div black back + $j('#dc_'+this.id).append('
    '+ + '
    ' + ); + //start animation (make thumb small in upper left add in div for "loading" + $j('#img_thumb_'+this.id).animate({ + width:parseInt(parseInt(_this.width)/2), + height:parseInt(parseInt(_this.height)/2), + top:20, + left:10 + }, + 1000, + function(){ + //animation done.. add "loading" to div if empty + if($j('#liks_info_'+_this.id).html()==''){ + $j('#liks_info_'+_this.id).html(gM('mwe-loading_txt')); + } + } + ) + //now load roe if run the showNextPrevLinks + if(this.roe && this.media_element.addedROEData==false){ + do_request(this.roe, function(data) + { + _this.media_element.addROE(data); + _this.getNextPrevLinks(); + }); + }else{ + this.getNextPrevLinks(); + } + } + }, + //@@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them. getNextPrevLinks:function(){ js_log('f:getNextPrevLinks'); var anno_track_url = null; - var _this = this; + var _this = this; //check for annoative track - $j.each(this.media_element.sources, function(inx, n){ + $j.each(this.media_element.sources, function(inx, n){ if(n.mime_type=='text/cmml'){ if( n.id == 'Anno_en'){ anno_track_url = n.src; @@ -1161,28 +1258,28 @@ embedVideo.prototype = { //zero out seconds (should improve cache hit rate and generally expands metadata search) //@@todo this could be repalced with a regExp var annoURL = parseUri(anno_track_url); - var times = annoURL.queryKey['t'].split('/'); - var stime_parts = times[0].split(':'); - var etime_parts = times[1].split(':'); + var times = annoURL.queryKey['t'].split('/'); + var stime_parts = times[0].split(':'); + var etime_parts = times[1].split(':'); //zero out the hour: var new_start = stime_parts[0]+':'+'0:0'; //zero out the end sec var new_end = (etime_parts[0]== stime_parts[0])? (etime_parts[0]+1)+':0:0' :etime_parts[0]+':0:0'; - + var etime_parts = times[1].split(':'); - + var new_anno_track_url = annoURL.protocol +'://'+ annoURL.host + annoURL.path +'?'; $j.each(annoURL.queryKey, function(i, val){ new_anno_track_url +=(i=='t')?'t='+new_start+'/'+new_end +'&' : i+'='+ val+'&'; }); var request_key = new_start+'/'+new_end; - //check the anno_data cache: - //@@todo search cache see if current is in range. + //check the anno_data cache: + //@@todo search cache see if current is in range. if(this.anno_data_cache){ js_log('anno data found in cache: '+request_key); this.showNextPrevLinks(); - }else{ + }else{ do_request(new_anno_track_url, function(cmml_data){ js_log('raw response: '+ cmml_data); if(typeof cmml_data == 'string') @@ -1193,8 +1290,8 @@ embedVideo.prototype = { } //init anno_data_cache if(!_this.anno_data_cache) - _this.anno_data_cache={}; - //grab all metadata and put it into the anno_data_cache: + _this.anno_data_cache={}; + //grab all metadata and put it into the anno_data_cache: $j.each(cmml_data.getElementsByTagName('clip'), function(inx, clip){ _this.anno_data_cache[ $j(clip).attr("id") ]={ 'start_time_sec':npt2seconds($j(clip).attr("start").replace('npt:','')), @@ -1203,32 +1300,32 @@ embedVideo.prototype = { }; //grab all its meta _this.anno_data_cache[ $j(clip).attr("id") ]['meta']={}; - $j.each(clip.getElementsByTagName('meta'),function(imx, meta){ + $j.each(clip.getElementsByTagName('meta'),function(imx, meta){ //js_log('adding meta: '+ $j(meta).attr("name")+ ' = '+ $j(meta).attr("content")); _this.anno_data_cache[$j(clip).attr("id")]['meta'][$j(meta).attr("name")]=$j(meta).attr("content"); }); }); - _this.showNextPrevLinks(); + _this.showNextPrevLinks(); }); } }else{ js_log('no annotative track found'); $j('#liks_info_'+this.id).html('no metadata found for related links'); } - //query current request time +|- 60s to get prev next speech links. + //query current request time +|- 60s to get prev next speech links. }, showNextPrevLinks:function(){ //js_log('f:showNextPrevLinks'); - //int requested links: + //int requested links: var link = { 'prev':'', 'current':'', 'next':'' - } + } var curTime = this.getTimeReq().split('/'); - + var s_sec = npt2seconds(curTime[0]); - var e_sec = npt2seconds(curTime[1]); + var e_sec = npt2seconds(curTime[1]); js_log('showNextPrevLinks: req time: '+ s_sec + ' to ' + e_sec); //now we have all the data in anno_data_cache var current_done=false; @@ -1240,52 +1337,52 @@ embedVideo.prototype = { link.prev = clip_id; js_log('showNextPrevLinks: ' + s_sec + ' < ' + clip.end_time_sec + ' set prev'); } - + if(e_sec==clip.end_time_sec && s_sec== clip.start_time_sec) current_done = true; //current clip is not done: if( e_sec < clip.end_time_sec && link.current=='' && !current_done){ link.current = clip_id; - js_log('showNextPrevLinks: ' + e_sec + ' < ' + clip.end_time_sec + ' set current'); + js_log('showNextPrevLinks: ' + e_sec + ' < ' + clip.end_time_sec + ' set current'); } - + //set end clip (first clip where start time is > end_time of req if( e_sec < clip.start_time_sec && link.next==''){ link.next = clip_id; js_log('showNextPrevLinks: '+ e_sec + ' < '+ clip.start_time_sec + ' && ' + link.next ); } - } - var html=''; + } + var html=''; if(link.prev=='' && link.current=='' && link.next==''){ html='

    clip page'; - }else{ + }else{ for(var link_type in link){ - var link_id = link[link_type]; + var link_id = link[link_type]; if(link_id!=''){ - var clip = this.anno_data_cache[link_id]; + var clip = this.anno_data_cache[link_id]; var title_msg=''; for(var j in clip['meta']){ title_msg+=j.replace(/_/g,' ') +': ' +clip['meta'][j].replace(/_/g,' ') +"
    "; - } + } var time_req = clip.time_req; - if(link_type=='current') //if current start from end of current clip play to end of current meta: + if(link_type=='current') //if current start from end of current clip play to end of current meta: time_req = curTime[1]+ '/' + seconds2npt( clip.end_time_sec ); - - //do special linkbacks for metavid content: - var regTimeCheck = new RegExp(/[0-9]+:[0-9]+:[0-9]+\/[0-9]+:[0-9]+:[0-9]+/); + + //do special linkbacks for metavid content: + var regTimeCheck = new RegExp(/[0-9]+:[0-9]+:[0-9]+\/[0-9]+:[0-9]+:[0-9]+/); html+='

    ' + - gM('mwe-'+link_type+'_clip_msg') + + html+=' title="' + title_msg + '">' + + gM(link_type+'_clip_msg') + '
    '+ title_msg +'

    '; - } + } } - } + } //js_og("should set html:"+ html); $j('#liks_info_'+this.id).html(html); }, @@ -1293,15 +1390,15 @@ embedVideo.prototype = { js_log('f:playByTimeReq: '+time_req ); this.stop(); this.updateVideoTimeReq(time_req); - this.play(); + this.play(); }, doThumbnailHTML:function() - { + { var _this = this; - js_log('f:doThumbnailHTML'+ this.thumbnail_disp); - this.closeDisplayedHTML(); + js_log('f:doThumbnailHTML'+ this.thumbnail_disp); + this.closeDisplayedHTML(); $j( '#mv_embedded_player_' + this.id ).html( this.getThumbnailHTML() ); - this.paused = true; + this.paused = true; this.thumbnail_disp = true; }, refreshControlsHTML:function(){ @@ -1312,40 +1409,40 @@ embedVideo.prototype = { return; }else{ $j('#mv_embedded_controls_'+this.id).html( this.getControlsHTML() ); - ctrlBuilder.addControlHooks(this); - } - }, + ctrlBuilder.addControlHooks(this); + } + }, getControlsHTML:function() - { + { return ctrlBuilder.getControls( this ); - }, - getHTML : function (){ - //@@todo check if we have sources avaliable - js_log('embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type); - var _this = this; - var html_code = ''; - html_code = '
    '; + }, + getHTML : function (){ + //@@todo check if we have sources avaliable + js_log('embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type); + var _this = this; + var html_code = ''; + html_code = '
    '; html_code += '
    ' + - this.getThumbnailHTML() + - '
    '; - //js_log("mvEmbed:controls "+ typeof this.controls); + this.getThumbnailHTML() + + '
    '; + //js_log("mvEmbed:controls "+ typeof this.controls); if( this.controls ) { js_log("f:getHTML:AddControls"); html_code +='
    '; - html_code += this.getControlsHTML(); - html_code +='
    '; - //block out some space by encapulating the top level div + html_code += this.getControlsHTML(); + html_code +='
    '; + //block out some space by encapulating the top level div $j(this).wrap('
    '); + +(parseInt(this.height)+ctrlBuilder.height)+'px">
    '); } - html_code += ''; //videoPlayer div close + html_code += ''; //videoPlayer div close //js_log('should set: '+this.id); - $j(this).html( html_code ); + $j(this).html( html_code ); //add hooks once Controls are in DOM - ctrlBuilder.addControlHooks(this); - - //js_log('set this to: ' + $j(this).html() ); + ctrlBuilder.addControlHooks(this); + + //js_log('set this to: ' + $j(this).html() ); //alert('stop'); //if auto play==true directly embed the plugin if(this.autoplay) @@ -1375,7 +1472,7 @@ embedVideo.prototype = { this.updateVideoTime(time_parts[0], time_parts[1]); }, //update video time - updateVideoTime:function(start_ntp, end_ntp){ + updateVideoTime:function(start_ntp, end_ntp){ //update media this.media_element.updateSourceTimes( start_ntp, end_ntp ); //update mv_time @@ -1387,11 +1484,11 @@ embedVideo.prototype = { this.seek_time_sec=0; else this.seek_time_sec=npt2seconds(start_ntp); - }, - //@@todo overwite by embed library if we can render frames natavily + }, + //@@todo overwite by embed library if we can render frames natavily renderTimelineThumbnail:function( options ){ var my_thumb_src = this.media_element.getThumbnailURL(); - //check if our thumbnail has a time attribute: + //check if our thumbnail has a time attribute: if( my_thumb_src.indexOf('t=') !== -1){ var time_ntp = seconds2npt ( options.time + parseInt(this.start_offset) ); my_thumb_src = getURLParamReplace( my_thumb_src, { 't':time_ntp, 'size': options.size } ); @@ -1399,7 +1496,7 @@ embedVideo.prototype = { var thumb_class = (typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : ''; return '
    ' + + 'width:' + options.width + 'px" >' + '' + @@ -1410,58 +1507,58 @@ embedVideo.prototype = { }, updateThumbTime:function( float_sec ){ //js_log('updateThumbTime:'+float_sec); - var _this = this; - if( typeof this.org_thum_src=='undefined' ){ + var _this = this; + if( typeof this.org_thum_src=='undefined' ){ this.org_thum_src = this.media_element.getThumbnailURL(); - } + } if( this.org_thum_src.indexOf('t=') !== -1){ - this.last_thumb_url = getURLParamReplace(this.org_thum_src, - { 't' : seconds2npt( float_sec + parseInt(this.start_offset)) } ); - if(!this.thumbnail_updating){ + this.last_thumb_url = getURLParamReplace(this.org_thum_src, + { 't' : seconds2npt( float_sec + parseInt(this.start_offset)) } ); + if(!this.thumbnail_updating){ this.updateThumbnail(this.last_thumb_url ,false); this.last_thumb_url =null; } } }, //for now provide a src url .. but need to figure out how to copy frames from video for plug-in based thumbs - updateThumbPerc:function( perc ){ + updateThumbPerc:function( perc ){ return this.updateThumbTime( (this.getDuration() * perc) ); }, //updates the thumbnail if the thumbnail is being displayed - updateThumbnail : function(src, quick_switch){ - //make sure we don't go to the same url if we are not already updating: + updateThumbnail : function(src, quick_switch){ + //make sure we don't go to the same url if we are not already updating: if( !this.thumbnail_updating && $j('#img_thumb_'+this.id).attr('src')== src ) return false; - //if we are already updating don't issue a new update: + //if we are already updating don't issue a new update: if( this.thumbnail_updating && $j('#new_img_thumb_'+this.id).attr('src')== src ) return false; - + js_log('update thumb: ' + src); - + if(quick_switch){ $j('#img_thumb_'+this.id).attr('src', src); }else{ - var _this = this; + var _this = this; //if still animating remove new_img_thumb_ if(this.thumbnail_updating==true) - $j('#new_img_thumb_'+this.id).stop().remove(); - + $j('#new_img_thumb_'+this.id).stop().remove(); + if(this.thumbnail_disp){ js_log('set to thumb:'+ src); this.thumbnail_updating=true; $j('#dc_'+this.id).append(''); - //js_log('appended: new_img_thumb_'); - $j('#new_img_thumb_'+this.id).fadeIn("slow", function(){ + 'id = "new_img_thumb_'+this.id+'" />'); + //js_log('appended: new_img_thumb_'); + $j('#new_img_thumb_'+this.id).fadeIn("slow", function(){ //once faded in remove org and rename new: $j('#img_thumb_'+_this.id).remove(); $j('#new_img_thumb_'+_this.id).attr('id', 'img_thumb_'+_this.id); $j('#img_thumb_'+_this.id).css('zindex','1'); - _this.thumbnail_updating=false; + _this.thumbnail_updating=false; //js_log("done fadding in "+ $j('#img_thumb_'+_this.id).attr("src")); - + //if we have a thumb queued update to that if(_this.last_thumb_url){ var src_url =_this.last_thumb_url; @@ -1478,7 +1575,7 @@ embedVideo.prototype = { download, and embed code. */ getThumbnailHTML : function () - { + { js_log('embedVideo:getThumbnailHTML::' + this.id); var thumb_html = ''; var class_atr=''; @@ -1493,10 +1590,10 @@ embedVideo.prototype = { ' overflow:hidden; top:0px; left:0px; width:'+this.playerPixelWidth()+'px; height:'+this.playerPixelHeight()+'px; z-index:0;">'+ ''; - + if(this.play_button == true && this.controls == true) thumb_html+=this.getPlayButton(); - + thumb_html+='
    '; return thumb_html; }, @@ -1550,16 +1647,16 @@ embedVideo.prototype = { this.displayHTML(gM('mwe-loading_txt')); do_request(this.roe, function(data) { - _this.media_element.addROE(data); + _this.media_element.addROE(data); _this.doLinkBack(); - }); + }); }else{ - if(this.media_element.linkback){ + if(this.media_element.linkback){ window.location = this.media_element.linkback; }else{ this.displayHTML(gM('mwe-could_not_find_linkback')); } - } + } }, //display the code to remotely embed this video: showEmbedCode : function(embed_code){ @@ -1584,42 +1681,42 @@ embedVideo.prototype = { this.displayHTML(o); }, copyText:function(){ - $j('#embedding_user_html_'+this.id).focus().select(); - if(document.selection){ - CopiedTxt = document.selection.createRange(); + $j('#embedding_user_html_'+this.id).focus().select(); + if(document.selection){ + CopiedTxt = document.selection.createRange(); CopiedTxt.execCommand("Copy"); } }, - showTextInterface:function(){ + showTextInterface:function(){ var _this = this; - //display the text container with loading text: + //display the text container with loading text: //@@todo support position config - var loc = $j(this).position(); + var loc = $j(this).position(); if($j('#metaBox_'+this.id).length==0){ $j(this).after('
    '+ gM('mwe-loading_txt') + - '
    '); + ''); } //fade in the text display - $j('#metaBox_'+this.id).fadeIn("fast"); + $j('#metaBox_'+this.id).fadeIn("fast"); //check if textObj present: if(typeof this.textInterface == 'undefined' ){ //load the default text interface: mvJsLoader.doLoad([ - 'mvTextInterface', + 'mvTextInterface', '$j.fn.hoverIntent' - ], function(){ - _this.textInterface = new mvTextInterface( _this ); + ], function(){ + _this.textInterface = new mvTextInterface( _this ); //show interface _this.textInterface.show(); js_log("NEW TEXT INTERFACE"); for(var i in _this.textInterface.availableTracks){ - js_log("tracks in new interface: "+_this.id+ ' tid:' + i); + js_log("tracks in new interface: "+_this.id+ ' tid:' + i); } } ); @@ -1636,26 +1733,26 @@ embedVideo.prototype = { }, /** Generic function to display custom HTML inside the mv_embed element. The code should call the closeDisplayedHTML function to close the - display of the custom HTML and restore the regular mv_embed display. + display of the custom HTML and restore the regular mv_embed display. @param {String} HTML code for the selection list. */ displayHTML:function(html_code) { var sel_id = (this.pc!=null)?this.pc.pp.id:this.id; - + if(!this.supports['overlays']) this.stop(); - + //put select list on-top //make sure the parent is relatively positioned: $j('#'+sel_id).css('position', 'relative'); //set height width (check for playlist container) var width = (this.pc)?this.pc.pp.width:this.playerPixelWidth(); var height = (this.pc)?this.pc.pp.height:this.playerPixelHeight(); - + if(this.pc) height+=(this.pc.pp.pl_layout.title_bar_height + this.pc.pp.pl_layout.control_height); - + var fade_in = true; if($j('#blackbg_'+sel_id).length!=0) { @@ -1667,11 +1764,11 @@ embedVideo.prototype = { 'style="height:'+parseInt(height)+'px;width:'+parseInt(width)+'px;">'+ '
    '+ //@@TODO: this style should go to .css - '' + + '' + 'close' + ''+ '
    '+ - html_code + html_code +'
    '+ '
    '; $j('#'+sel_id).prepend(div_code); @@ -1691,43 +1788,43 @@ embedVideo.prototype = { }); return false; //onclick action return false }, - selectPlaybackMethod:function(){ + selectPlaybackMethod:function(){ //get id (in case where we have a parent container) var this_id = (this.pc!=null)?this.pc.pp.id:this.id; - - var _this=this; + + var _this=this; var out= '
    '; var _this=this; //js_log('selected src'+ _this.media_element.selected_source.url); - $j.each( this.media_element.getPlayableSources(), function(source_id, source){ - var default_player = embedTypes.players.defaultPlayer( source.getMIMEType() ); - + $j.each( this.media_element.getPlayableSources(), function(source_id, source){ + var default_player = embedTypes.players.defaultPlayer( source.getMIMEType() ); + var is_selected = (source == _this.media_element.selected_source); var image_src = mv_skin_img_path ; - - //set the Playable source type: + + //set the Playable source type: if( source.mime_type == 'video/x-flv' ){ image_src += 'flash_icon_'; }else if( source.mime_type == 'video/h264'){ - //for now all mp4 content is pulled from archive.org (so use archive.org icon) + //for now all mp4 content is pulled from archive.org (so use archive.org icon) image_src += 'archive_org_'; }else{ image_src += 'fish_xiph_org_'; } image_src += is_selected ? 'color':'bw'; - image_src += '.png'; - + image_src += '.png'; + if (default_player) { out += ''; if( ! is_selected ) out+=''; out += source.getTitle()+ (is_selected?'':'') + ' '; - - //output the player select code: - var supporting_players = embedTypes.players.getMIMETypePlayers( source.getMIMEType() ); + + //output the player select code: + var supporting_players = embedTypes.players.getMIMETypePlayers( source.getMIMEType() ); out+='
      '; - for(var i=0; i < supporting_players.length ; i++){ + for(var i=0; i < supporting_players.length ; i++){ if( _this.selected_player.id == supporting_players[i].id && is_selected ){ out+='
    • '+ '' + @@ -1743,36 +1840,36 @@ embedVideo.prototype = { '
    • '; } } - out+='
    '; + out+=''; }else out+= source.getTitle() + ' - no player available'; }); out+='
    '; this.displayHTML(out); - + //set up the click bindings: $j('.sel_source').each(function(){ $j(this).click(function(){ var iparts = $j(this).attr( 'id' ).replace(/sc_/,'').split('_'); var source_id = iparts[0]; var default_player_id = iparts[1]; - js_log('source id: ' + source_id + ' player id: ' + default_player_id); - - $j('#' + this_id ).get(0).closeDisplayedHTML(); + js_log('source id: ' + source_id + ' player id: ' + default_player_id); + + $j('#' + this_id ).get(0).closeDisplayedHTML(); $j('#' + _this.id ).get(0).media_element.selectSource( source_id ); - + embedTypes.players.userSelectPlayer( default_player_id, _this.media_element.sources[ source_id ].getMIMEType() ); - + //be sure to issue a stop $j('#' + this_id ).get(0).stop(); - + //don't follow the empty # link: return false; }); }); - }, - showVideoDownload:function(){ + }, + showVideoDownload:function(){ //load the roe if available (to populate out download options: //js_log('f:showVideoDownload '+ this.roe + ' ' + this.media_element.addedROEData); if(this.roe && this.media_element.addedROEData == false){ @@ -1780,23 +1877,23 @@ embedVideo.prototype = { this.displayHTML(gM('mwe-loading_txt')); do_request(this.roe, function(data) { - _this.media_element.addROE(data); + _this.media_element.addROE(data); $j('#mv_disp_inner_'+_this.id).html( _this.getShowVideoDownload() ); - }); + }); }else{ this.displayHTML( this.getShowVideoDownload() ); - } + } }, - getShowVideoDownload:function(){ + getShowVideoDownload:function(){ var out='
    ' + ''+gM('mwe-download_segment')+'
    '; out+='
    '+ gM('mwe-download_right_click') + '

    '; var dl_list=''; - var dl_txt_list=''; + var dl_txt_list=''; $j.each(this.media_element.getSources(), function(index, source){ var dl_line = '
  • ' + ' ' - + source.getTitle()+' '+ '
  • '+"\n"; + + source.getTitle()+' '+ ''+"\n"; if( source.getURI().indexOf('?t=')!==-1){ out+=dl_line; }else if( this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt" ){ @@ -1804,8 +1901,8 @@ embedVideo.prototype = { }else{ dl_list+=dl_line; } - }); - + }); + if(dl_list!='') out+=gM('mwe-download_full') + '
    ' + dl_list + '
    '; if(dl_txt_list!='') @@ -1819,11 +1916,11 @@ embedVideo.prototype = { */ play:function(){ var this_id = (this.pc!=null)?this.pc.pp.id:this.id; - - //js_log( "mv_embed play:" + this.id); + + //js_log( "mv_embed play:" + this.id); //js_log('thum disp:'+this.thumbnail_disp); //check if thumbnail is being displayed and embed html - if( this.thumbnail_disp ){ + if( this.thumbnail_disp ){ if( !this.selected_player ){ js_log('no selected_player'); //this.innerHTML = this.getPluginMissingHTML(); @@ -1831,21 +1928,21 @@ embedVideo.prototype = { $j('#'+this.id).html( this.getPluginMissingHTML() ); }else{ this.doEmbedHTML(); - this.onClipDone_disp=false; - this.paused=false; - this.thumbnail_disp=false; + this.onClipDone_disp=false; + this.paused=false; + this.thumbnail_disp=false; } }else{ - //the plugin is already being displayed + //the plugin is already being displayed this.paused=false; //make sure we are not "paused" this.seeking=false; - } - - $j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-play').addClass('ui-icon-pause'); - $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ + } + + $j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-play').addClass('ui-icon-pause'); + $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ $j('#' + this_id ).get(0).pause(); }).attr('title', gM('mwe-pause_clip')); - + }, load:function(){ //should be done by child (no base way to load assets) @@ -1853,41 +1950,41 @@ embedVideo.prototype = { }, getSrc:function(){ return this.media_element.selected_source.getURI( this.seek_time_sec ); - }, + }, /* * base embed pause * there is no general way to pause the video * must be overwritten by embed object to support this functionality. */ pause: function(){ - var this_id = (this.pc!=null)?this.pc.pp.id:this.id; - //js_log('mv_embed:do pause'); - //(playing) do pause - this.paused = true; - //update the ctrl "paused state" + var this_id = (this.pc!=null)?this.pc.pp.id:this.id; + //js_log('mv_embed:do pause'); + //(playing) do pause + this.paused = true; + //update the ctrl "paused state" $j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-pause').addClass('ui-icon-play'); - $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ + $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ $j('#'+this_id).get(0).play(); }).attr('title', gM('mwe-play_clip')); - }, + }, /* * base embed stop (can be overwritten by the plugin) */ stop: function(){ var _this = this; js_log('mvEmbed:stop:'+this.id); - + //no longer seeking: this.didSeekJump=false; - - //first issue pause to update interface (only call the parent) + + //first issue pause to update interface (only call the parent) if(this['parent_pause']){ this.parent_pause(); }else{ this.pause(); - } - - //reset the currentTime: + } + + //reset the currentTime: this.currentTime=0; //check if thumbnail is being displayed in which case do nothing if( this.thumbnail_disp ){ @@ -1900,12 +1997,12 @@ embedVideo.prototype = { this.setSliderValue(0); this.setStatus( this.getTimeReq() ); } - - //make sure the big playbutton is has click action: + + //make sure the big playbutton is has click action: $j('#big_play_link_' + _this.id).unbind('click').click(function(){ $j('#' +_this.id).get(0).play(); }); - + if(this.update_interval) { clearInterval(this.update_interval); @@ -1913,19 +2010,19 @@ embedVideo.prototype = { } }, toggleMute:function(){ - var this_id = (this.pc!=null)?this.pc.pp.id:this.id; + var this_id = (this.pc!=null)?this.pc.pp.id:this.id; if(this.muted){ this.muted=false; $j('#volume_control_'+this_id + ' span').removeClass('ui-icon-volume-off').addClass('ui-icon-volume-on'); - $j('#volume_bar_'+this_id).slider('value', 100); + $j('#volume_bar_'+this_id).slider('value', 100); this.updateVolumen(1); }else{ this.muted=true; $j('#volume_control_'+this_id + ' span').removeClass('ui-icon-volume-on').addClass('ui-icon-volume-off'); $j('#volume_bar_'+this_id).slider('value', 0); - this.updateVolumen(0); + this.updateVolumen(0); } - js_log('f:toggleMute::' + this.muted); + js_log('f:toggleMute::' + this.muted); }, updateVolumen:function(perc){ js_log('update volume not supported with current playback type'); @@ -1959,19 +2056,19 @@ embedVideo.prototype = { postEmbedJS:function(){ return ''; }, - //do common monitor code like update the playhead and play status + //do common monitor code like update the playhead and play status //plugin objects are responsible for updating currentTime monitor:function(){ if( this.currentTime && this.currentTime > 0 && this.duration){ if( !this.userSlide ){ - if( this.start_offset ){ - //if start offset include that calculation - this.setSliderValue( ( this.currentTime - this.start_offset ) / this.duration ); - this.setStatus( seconds2npt(this.currentTime) + '/'+ seconds2npt(parseFloat(this.start_offset)+parseFloat(this.duration) )); + if( this.start_offset ){ + //if start offset include that calculation + this.setSliderValue( ( this.currentTime - this.start_offset ) / this.duration ); + this.setStatus( seconds2npt(this.currentTime) + '/'+ seconds2npt(parseFloat(this.start_offset)+parseFloat(this.duration) )); }else{ this.setSliderValue( this.currentTime / this.duration ); this.setStatus( seconds2npt(this.currentTime) + '/' + seconds2npt(this.duration )); - } + } } }else{ //js_log(' ct:' + this.currentTime + ' dur: ' + this.duration); @@ -1980,25 +2077,30 @@ embedVideo.prototype = { }else if( this.isPaused() ){ this.setStatus( "paused" ); }else if( this.isPlaying() ){ - if( this.currentTime && ! this.duration ) + if( this.currentTime && ! this.duration ) this.setStatus( seconds2npt( this.currentTime ) + ' /' ); - else + else this.setStatus(" - - - "); }else{ this.setStatus( this.getTimeReq() ); - } + } } - //update buffer information + //update buffer information this.updateBufferStatus(); - + + //check if we passed duration + if( this.duration && (this.currentTime > this.duration) ){ + this.onClipDone(); + } + //update monitorTimerId to call child monitor if( ! this.monitorTimerId ){ - //make sure an instance of this.id exists: + //make sure an instance of this.id exists: if( document.getElementById(this.id) ){ this.monitorTimerId = setInterval('$j(\'#'+this.id+'\').get(0).monitor()', 250); } } - }, + }, stopMonitor:function(){ if( this.monitorTimerId != 0 ) { @@ -2007,18 +2109,18 @@ embedVideo.prototype = { } }, updateBufferStatus: function(){ - - //build the buffer targeet based for playlist vs clip - var buffer_select = (this.pc) ? - '#cl_status_' + this.id + ' .mv_buffer': + + //build the buffer targeet based for playlist vs clip + var buffer_select = (this.pc) ? + '#cl_status_' + this.id + ' .mv_buffer': '#mv_play_head_' + this.id + ' .mv_buffer'; - + //update the buffer progress bar (if available ) if( this.bufferedPercent != 0 ){ - //js_log('bufferedPercent: ' + this.bufferedPercent); + //js_log('bufferedPercent: ' + this.bufferedPercent); if(this.bufferedPercent > 1) - this.bufferedPercent=1; - + this.bufferedPercent=1; + $j(buffer_select).css("width", (this.bufferedPercent*100) +'%' ); }else{ $j(buffer_select).css("width", '0px' ); @@ -2028,7 +2130,7 @@ embedVideo.prototype = { if(!this.start_offset) this.start_offset =0; var rt = this.currentTime - this.start_offset; - if( rt < 0 ) //should not happen but does. + if( rt < 0 ) //should not happen but does. return 0; return rt; }, @@ -2044,7 +2146,7 @@ embedVideo.prototype = { } return null; }, - //HELPER Functions for selected source + //HELPER Functions for selected source /* * returns the selected source url for players to play */ @@ -2055,12 +2157,12 @@ embedVideo.prototype = { //do head request if on the same domain return this.media_element.selected_source.URLTimeEncoding; }, - setSliderValue: function(perc, hide_progress){ - if(this.controls){ + setSliderValue: function(perc, hide_progress){ + if(this.controls){ var this_id = (this.pc)?this.pc.pp.id:this.id; - var val = parseInt( perc*1000 ); + var val = parseInt( perc*1000 ); $j('#mv_play_head_'+this_id).slider('value', val); - + //js_log("embed video set: " + '#mv_play_head_'+this_id + ' to ' + val); } //js_log('set#mv_seeker_slider_'+this_id + ' perc in: ' + perc + ' * ' + $j('#mv_seeker_'+this_id).width() + ' = set to: '+ val + ' - '+ Math.round(this.mv_seeker_width*perc) ); @@ -2070,44 +2172,44 @@ embedVideo.prototype = { js_log('highlightPlaySection'); var this_id = (this.pc)?this.pc.pp.id:this.id; var dur = this.getDuration(); - var hide_progress = true; - //set the left percet and update the slider: + var hide_progress = true; + //set the left percet and update the slider: rel_start_sec = npt2seconds( options['start']); - //remove the start_offset if relevent: + //remove the start_offset if relevent: if(this.start_offset) rel_start_sec = rel_start_sec - this.start_offset - + var slider_perc=0; if( rel_start_sec <= 0 ){ - left_perc =0; + left_perc =0; options['start'] = seconds2npt( this.start_offset ); - rel_start_sec=0; + rel_start_sec=0; this.setSliderValue( 0 , hide_progress); }else{ - left_perc = parseInt( (rel_start_sec / dur)*100 ) ; + left_perc = parseInt( (rel_start_sec / dur)*100 ) ; slider_perc = (left_perc / 100); - } - js_log("slider perc:" + slider_perc); + } + js_log("slider perc:" + slider_perc); if( ! this.isPlaying() ){ - this.setSliderValue( slider_perc , hide_progress); + this.setSliderValue( slider_perc , hide_progress); } - - width_perc = parseInt( (( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur)*100 ) ; + + width_perc = parseInt( (( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur)*100 ) ; if( (width_perc + left_perc) > 100 ){ - width_perc = 100 - left_perc; - } - //js_log('should hl: '+rel_start_sec+ '/' + dur + ' re:' + rel_end_sec+' lp:' + left_perc + ' width: ' + width_perc); + width_perc = 100 - left_perc; + } + //js_log('should hl: '+rel_start_sec+ '/' + dur + ' re:' + rel_end_sec+' lp:' + left_perc + ' width: ' + width_perc); $j('#mv_seeker_' + this_id + ' .mv_highlight').css({ 'left':left_perc+'%', - 'width':width_perc+'%' - }).show(); - + 'width':width_perc+'%' + }).show(); + this.jump_time = options['start']; this.seek_time_sec = npt2seconds( options['start']); - //trim output to + //trim output to this.setStatus( gM('mwe-seek_to')+' '+ seconds2npt( this.seek_time_sec ) ); js_log('DO update: ' + this.jump_time); - this.updateThumbTime( rel_start_sec ); + this.updateThumbTime( rel_start_sec ); }, hideHighlight:function(){ var this_id = (this.pc)?this.pc.pp.id:this.id; @@ -2119,7 +2221,7 @@ embedVideo.prototype = { var id = (this.pc)?this.pc.pp.id:this.id; //update status: $j('#mv_time_'+id).html(value); - } + } } @@ -2146,9 +2248,9 @@ mediaPlayer.prototype = supported_types:null, library:null, loaded:false, - loading_callbacks:null, + loading_callbacks:null, supportsMIMEType : function(type) - { + { for (var i=0; i < this.supported_types.length; i++) if(this.supported_types[i] == type) return true; @@ -2164,17 +2266,17 @@ mediaPlayer.prototype = js_log('plugin loaded, do callback:'); callback(); }else{ - var _this = this; - //jQuery based get script does not work so well. - mvJsLoader.doLoad([ + var _this = this; + //jQuery based get script does not work so well. + mvJsLoader.doLoad([ libName ],function(){ - callback(); + callback(); }); } - } + } } -/* players and supported mime types +/* players and supported mime types @@todo ideally we query the plugin to get what mime types it supports in practice not always reliable/avaliable */ var flowPlayer = new mediaPlayer('flowplayer',['video/x-flv', 'video/h264'],'flash'); @@ -2191,7 +2293,7 @@ var vlcActiveXPlayer = new mediaPlayer('vlc-activex',vlcMineList,'vlc'); //add generic var oggPluginPlayer = new mediaPlayer('oggPlugin',['video/ogg'],'generic'); -//depricate quicktime in favor of safari native +//depricate quicktime in favor of safari native //var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime'); //var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime'); @@ -2216,24 +2318,24 @@ mediaPlayers.prototype = { this.players = new Array(); this.loadPreferences(); - - //set up default players order for each library type + + //set up default players order for each library type this.default_players['video/x-flv'] = ['flash','vlc']; this.default_players['video/h264'] = ['flash', 'vlc']; - - this.default_players['video/ogg'] = ['native','vlc','java', 'generic']; - this.default_players['application/ogg'] = ['native','vlc','java', 'generic']; - this.default_players['audio/ogg'] = ['native','vlc', 'java', 'omtk' ]; + + this.default_players['video/ogg'] = ['native','vlc','java', 'generic']; + this.default_players['application/ogg'] = ['native','vlc','java', 'generic']; + this.default_players['audio/ogg'] = ['native','vlc', 'java', 'omtk' ]; this.default_players['video/mp4'] = ['vlc']; - + this.default_players['text/html'] = ['html']; this.default_players['image/jpeg'] = ['html']; this.default_players['image/png'] = ['html']; this.default_players['image/svg'] = ['html']; - + }, addPlayer : function(player, mime_type) - { + { //js_log('Adding ' + player.id + ' with mime_type ' + mime_type); for (var i =0; i < this.players.length; i++){ if (this.players[i].id == player.id) @@ -2241,52 +2343,52 @@ mediaPlayers.prototype = if(mime_type!=null) { //make sure the mime_type is not already there: - var add_mime = true; + var add_mime = true; for(var j=0; j < this.players[i].supported_types.length; j++ ){ if( this.players[i].supported_types[j]== mime_type) add_mime=false; - } + } if(add_mime) this.players[i].supported_types.push(mime_type); } return; } } - //player not found: + //player not found: if(mime_type!=null) - player.supported_types.push(mime_type); - + player.supported_types.push(mime_type); + this.players.push( player ); }, getMIMETypePlayers : function(mime_type) - { + { var mime_players = new Array(); var _this = this; var inx = 0; - if( this.default_players[mime_type] ){ - $j.each( this.default_players[mime_type], function(d, lib){ - var library = _this.default_players[mime_type][d]; - for ( var i=0; i < _this.players.length; i++ ){ + if( this.default_players[mime_type] ){ + $j.each( this.default_players[mime_type], function(d, lib){ + var library = _this.default_players[mime_type][d]; + for ( var i=0; i < _this.players.length; i++ ){ if ( _this.players[i].library == library && _this.players[i].supportsMIMEType(mime_type) ){ - mime_players[ inx ] = _this.players[i]; + mime_players[ inx ] = _this.players[i]; inx++; } } }); - } + } return mime_players; }, defaultPlayer : function(mime_type) - { - js_log("get defaultPlayer for " + mime_type); - var mime_players = this.getMIMETypePlayers(mime_type); + { + js_log("get defaultPlayer for " + mime_type); + var mime_players = this.getMIMETypePlayers(mime_type); if( mime_players.length > 0) { // check for prior preference for this mime type for( var i=0; i < mime_players.length; i++ ){ if( mime_players[i].id==this.preference[mime_type] ) return mime_players[i]; - } + } // otherwise just return the first compatible player // (it will be chosen according to the default_players list return mime_players[0]; @@ -2326,7 +2428,7 @@ mediaPlayers.prototype = }, loadPreferences : function() { - this.preference = new Object(); + this.preference = new Object(); // see if we have a cookie set to a clientSupported type: var cookieVal = $j.cookie( 'ogg_player_exp' ); if (cookieVal) @@ -2342,11 +2444,11 @@ mediaPlayers.prototype = }, savePreferences : function() { - var cookieVal = ''; + var cookieVal = ''; for(var i in this.preference) cookieVal+= i + '='+ this.preference[i] + '&'; - - cookieVal=cookieVal.substr(0, cookieVal.length-1); + + cookieVal=cookieVal.substr(0, cookieVal.length-1); var week = 7*86400*1000; $j.cookie( 'ogg_player_exp', cookieVal, { 'expires':week } ); } @@ -2360,7 +2462,7 @@ mediaPlayers.prototype = var embedTypes = { // List of players players: null, - detect_done:false, + detect_done:false, init: function(){ //detect supported types this.detect(); @@ -2380,7 +2482,7 @@ var embedTypes = { js_log("running detect"); this.players = new mediaPlayers(); //every browser supports html rendering: - this.players.addPlayer( htmlPlayer ); + this.players.addPlayer( htmlPlayer ); // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to // search navigator.mimeTypes to see if it's installed var javaEnabled = navigator.javaEnabled(); @@ -2392,28 +2494,28 @@ var embedTypes = { // And it doesn't register an application/x-java-applet mime type like Mozilla does. if ( invisibleJava && javaEnabled ) this.players.addPlayer( cortadoPlayer ); - + // ActiveX plugins if($j.browser.msie){ - // check for flash - if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash')){ - //try to get the flash version for omtk include: + // check for flash + if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash')){ + //try to get the flash version for omtk include: try { a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7"); d = a.GetVariable("$version"); // Will crash fp6.0.21/23/29 if (d) { - d = d.split(" ")[1].split(","); + d = d.split(" ")[1].split(","); //we need flash version 10 or greater: if(parseInt( d[0]) >=10){ this.players.addPlayer( omtkPlayer ); } - - } - }catch(e) {} - - //flowplayer has pretty good compatiablity + + } + }catch(e) {} + + //flowplayer has pretty good compatiablity // (but if we wanted to be fancy we would check for version of flash and update the mp4/h.264 support - this.players.addPlayer( flowPlayer ); + this.players.addPlayer( flowPlayer ); } // VLC if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) ) @@ -2423,14 +2525,14 @@ var embedTypes = { this.players.addPlayer(cortadoPlayer); // quicktime //if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) ) - // this.players.addPlayer(quicktimeActiveXPlayer); - } + // this.players.addPlayer(quicktimeActiveXPlayer); + } //