r39981 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39980‎ | r39981 | r39982 >
Date:22:29, 25 August 2008
Author:dale
Status:old
Tags:
Comment:
play_head updates for flash and vlc
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_vlcEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/sample_page.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_flashEmbed.js
@@ -316,6 +316,7 @@
317317
318318 var flashEmbed = {
319319 instanceOf:'flashEmbed',
 320+ monitorTimerId : 0,
320321 supports: {'play_head':true, 'play_or_pause':true, 'stop':true, 'fullscreen':true, 'time_display':true, 'volume_control':true},
321322 getPluginEmbedHTML : function (){
322323 setTimeout('document.getElementById(\''+this.id+'\').postEmbedJS()', 150);
@@ -326,36 +327,78 @@
327328 return '<div class="player" id="FlowPlayerAnnotationHolder_'+this.pid+'"></div>'+"\n";
328329 },
329330 postEmbedJS : function()
330 - {
331 - var clip = flashembed('FlowPlayerAnnotationHolder_'+this.pid,
332 - { src: mv_embed_path + 'FlowPlayerDark.swf', width: this.width, height: this.height, id: this.pid},
333 - { config: { autoPlay: true, hideControls: true,
334 - videoFile: this.media_element.selected_source.uri } });
335 - js_log('setInterval');
336 - this.update_interval = setInterval('document.getElementById(\''+this.id+'\').updateGUI()', 250);
 331+ {
 332+ this.getFLA();
 333+ if(!this.flv){
 334+ var clip = flashembed('FlowPlayerAnnotationHolder_'+this.pid,
 335+ { src: mv_embed_path + 'FlowPlayerDark.swf', width: this.width, height: this.height, id: this.pid},
 336+ { config: { autoPlay: true, hideControls: true,
 337+ videoFile: this.media_element.selected_source.uri } });
 338+ }
 339+ if(this.fla){
 340+ js_log('flash ready:start monitor:');
 341+ setTimeout('$j(\'#'+this.id+'\').get(0).monitor()', 250);
 342+ }else{
 343+ js_log('flash not ready');
 344+ setTimeout('$j(\'#'+this.id+'\').get(0).postEmbedJS()',100);
 345+ }
337346 },
338347 /* js hooks/controls */
339 - play : function(){
340 - if(this.thumbnail_disp)
 348+ play : function(){
 349+ this.getFLA();
 350+ if(!this.fla || this.thumbnail_disp)
341351 {
342352 //call the parent
343353 this.parent_play();
344354 }else{
345 - this.getPluginEmbed().DoPlay();
 355+ this.fla.DoPlay();
346356 this.paused=false;
 357+ setTimeout('$j(\'#'+this.id+'\').get(0).monitor()', 250);
347358 }
348359 },
349360 pause : function()
350361 {
351362 this.getPluginEmbed().Pause();
 363+ //stop updates:
 364+ if( this.monitorTimerId != 0 )
 365+ {
 366+ clearInterval(this.monitorTimerId);
 367+ this.monitorTimerId = 0;
 368+ }
352369 },
353 - updateGUI : function()
 370+ monitor : function()
354371 {
355 - var time = this.getPluginEmbed().getTime();
356 - var duration = this.getPluginEmbed().getDuration();
357 - this.setStatus( seconds2ntp(time, false) + '/' + seconds2ntp(duration, false));
358 - if($j('#mv_seeker_slider_'+this.id).length!=0)
359 - $j('#mv_seeker_slider_'+this.id).css({'marginLeft':(3 + 114 * time / duration) + 'px'});
 372+ this.getFLA();
 373+ var time = this.fla.getTime();
 374+ //flash is giving bogus duration get from this
 375+ var end_ntp = (this.media_element.selected_source.end_ntp)?
 376+ this.media_element.selected_source.end_ntp :
 377+ seconds2ntp( this.fla.getDuration() );
 378+ var start_ntp = (this.media_element.selected_source.start_ntp)?
 379+ this.media_element.selected_source.start_ntp : 0;
 380+ this.setStatus( seconds2ntp(time, false) + '/' + end_ntp);
 381+ js_log('cur time : ' + (time - ntp2seconds(start_ntp)) +
 382+ ' / ' +
 383+ (ntp2seconds(end_ntp)-ntp2seconds(start_ntp)));
 384+ this.setSliderValue((time - ntp2seconds(start_ntp)) / (ntp2seconds(end_ntp)-ntp2seconds(start_ntp)) );
 385+ //do monitor update:
 386+ if( ! this.monitorTimerId ){
 387+ if(document.getElementById(this.id)){
 388+ this.monitorTimerId = setInterval('$j(\'#'+this.id+'\').get(0).monitor()', 250);
 389+ }
 390+ }
 391+ },
 392+ // get the embed fla object
 393+ getFLA : function (){
 394+ this.fla = this.getPluginEmbed();
 395+ },
 396+ onStop: function(){
 397+ //stop updates:
 398+ if( this.monitorTimerId != 0 )
 399+ {
 400+ clearInterval(this.monitorTimerId);
 401+ this.monitorTimerId = 0;
 402+ }
360403 }
361404 }
362405
Index: trunk/extensions/MetavidWiki/skins/mv_embed/embedLibs/mv_vlcEmbed.js
@@ -56,9 +56,9 @@
5757 if(this.controls){
5858 //activate the slider: scriptaculus based)
5959 this.activateSlider();
60 - //start doing status updates every 1/10th of a second
61 - setTimeout('document.getElementById(\''+this.id+'\').monitor()',100);
62 - }
 60+ //start doing status updates every 1/10th of a second
 61+ }
 62+ setTimeout('$j(\'#'+this.id+'\').get(0).monitor()',100);
6363 }else{
6464 js_log('vlc not ready');
6565 setTimeout('document.getElementById(\''+this.id+'\').postEmbedJS()',100);
@@ -184,9 +184,11 @@
185185 this.setSliderValue(this.vlc.input.position);
186186 }else{
187187 //set via time:
188 - //js_log('set slider:'+(this.vlc.input.time-this.start_offset) + ' / ' + this.mediaLen +
189 - //' ='+ (this.vlc.input.time-this.start_offset)/this.mediaLen );
190 - this.setSliderValue( ((this.vlc.input.time-this.start_offset)/1000)/this.duration);
 188+ /*js_log('t:' +(this.vlc.input.time/1000) +' - so:'+this.start_offset+
 189+ ' set slider:' + ((this.vlc.input.time/1000)-this.start_offset) + ' / ' + this.duration +
 190+ ' ='+ ((this.vlc.input.time/1000)-this.start_offset)/this.duration );
 191+ */
 192+ this.setSliderValue( ((this.vlc.input.time/1000) -this.start_offset) / this.duration);
191193 }
192194 this.setStatus(seconds2ntp(this.currentTime) + ' / ' + seconds2ntp(this.duration+this.start_offset) );
193195 }else{
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -30,7 +30,8 @@
3131 var _global = this;
3232 var mv_init_done=false;
3333
34 -//this only affects roe based source media files
 34+//this restricts playable sources to ROE xml media without start end time atttribute
 35+var mv_restrict_roe_time_source = true;
3536
3637 var debug_global_vid_ref=null;
3738 /*
@@ -46,7 +47,7 @@
4748 getMvEmbedPath();
4849 }
4950 //here you can add in delay load refrence to test things with delayed load time:
50 -mv_embed_path = mv_embed_path + 'delay_load.php/';
 51+//mv_embed_path = mv_embed_path + 'delay_load.php/';
5152
5253 //the default thumbnail for missing images:
5354 var mv_default_thumb_url = mv_embed_path + 'images/vid_default_thumb.jpg';
@@ -278,19 +279,22 @@
279280
280281 //I am getting vlEmebed is not defined like 1/5 or 1/20th the time
281282 //the load order should be more defined and ordered via callbacks
282 - $j.getScript(plugin_path, function(){
 283+ /*$j.getScript(plugin_path, function(){
283284 js_log(_this.id + ' plugin loaded');
284285 _this.loaded = true;
285286 for(var i in _this.loading_callbacks)
286287 _this.loading_callbacks[i]();
287288 _this.loading_callbacks = null;
288 - });
289 - /*eval('var lib = {"'+this.library+'Embed":\'embedLibs/mv_'+this.library+'Embed.js\'}');
 289+ }); */
 290+ eval('var lib = {"'+this.library+'Embed":\'embedLibs/mv_'+this.library+'Embed.js\'}');
290291 mvJsLoader.doLoad(lib,function(){
291292 js_log(_this.id + ' plugin loaded');
292293 _this.loaded = true;
293 - callback();
294 - });*/
 294+ //callback();
 295+ for(var i in _this.loading_callbacks)
 296+ _this.loading_callbacks[i]();
 297+ _this.loading_callbacks = null;
 298+ });
295299 }
296300 }
297301 }
@@ -1239,9 +1243,15 @@
12401244 parts[1]=parts[1].replace('x-flv', 'flash');
12411245 this.title = parts[1] + ' ' + parts[0];
12421246 }
 1247+
12431248 if (element.hasAttribute("id"))
12441249 this.id = element.getAttribute("id");
1245 -
 1250+
 1251+ //@@todo parse start time format and put into start_ntp
 1252+ if(element.hasAttribute("start"))
 1253+ this.start = element.getAttribute("start");
 1254+ if(element.hasAttribute("end"))
 1255+ this.start = element.getAttribute("end");
12461256 //js_log('Adding mediaSource of type ' + this.mime_type + ' and uri ' + this.uri + ' and title ' + this.title);
12471257 this.parseURLDuration();
12481258 },
@@ -1363,9 +1373,7 @@
13641374 mediaElement.prototype =
13651375 {
13661376 /** The array of mediaSource elements. */
1367 - sources:null,
1368 - /** Playable sources **/
1369 - playable_sources:null,
 1377+ sources:null,
13701378 addedROEData:false,
13711379 /** Selected mediaSource element. */
13721380 selected_source:null,
@@ -1378,7 +1386,6 @@
13791387 var _this = this;
13801388 js_log('Initializing mediaElement...');
13811389 this.sources = new Array();
1382 - this.playable_sources = new Array();
13831390 this.thumbnail = mv_default_thumb_url;
13841391 // Process the <video> element
13851392 this.tryAddSource(video_element);
@@ -1421,17 +1428,18 @@
14221429 //@@todo read user preference for source
14231430
14241431 // Select the default source
1425 - for (var source in this.playable_sources){
1426 - if(this.playable_sources[source].marked_default){
1427 - this.selected_source = this.playable_sources[source];
 1432+ var playable_sources = this.getPlayableSources();
 1433+ for (var source in playable_sources){
 1434+ if(playable_sources[source].marked_default){
 1435+ this.selected_source = playable_sources[source];
14281436 return true;
14291437 }
14301438 }
14311439 // select streams that start with 'mv_' first source
14321440 if (!this.selected_source)
14331441 {
1434 - js_log('autoselecting first source:' + this.playable_sources[0]);
1435 - this.selected_source = this.playable_sources[0];
 1442+ js_log('autoselecting first source:' + playable_sources[0]);
 1443+ this.selected_source = playable_sources[0];
14361444 }
14371445 },
14381446 /** Returns the thumbnail URL for the media element.
@@ -1476,12 +1484,21 @@
14771485 }
14781486 }
14791487 var source = new mediaSource(element);
1480 - this.sources.push(source);
1481 - //check if we support the mime type and its a url based time segment
1482 - if(this.isPlayableType(source.mime_type)){
1483 - this.playable_sources.push(source);
1484 - }
 1488+ this.sources.push(source);
14851489 },
 1490+ getPlayableSources: function(){
 1491+ var playable_sources= new Array();
 1492+ for(var i in this.sources){
 1493+ if(this.isPlayableType(this.sources[i].mime_type)){
 1494+ if(mv_restrict_roe_time_source){
 1495+ if(this.sources[i]['start'])
 1496+ continue;
 1497+ }
 1498+ playable_sources.push(this.sources[i]);
 1499+ }
 1500+ }
 1501+ return playable_sources;
 1502+ },
14861503 /** Imports media sources from ROE data.
14871504 @param roe_data ROE data.
14881505 */
@@ -1787,7 +1804,7 @@
17881805 if(this.supports['play_head'] && (available_width > 18))
17891806 {
17901807 html_code +=
1791 - ' <div class="seeker" style="width: ' + (available_width - 18) + 'px;">';
 1808+ ' <div class="seeker" id="mv_seeker_'+this.id+'" style="width: ' + (available_width - 18) + 'px;">';
17921809 html_code+=
17931810 ' <div class="seeker_bar">'+
17941811 ' <div class="seeker_bar_outer"></div>'+
@@ -2238,7 +2255,7 @@
22392256 var out='<span style="color:white"><blockquote>';
22402257 var _this=this;
22412258 //js_log('selected src'+ _this.media_element.selected_source.url);
2242 - $j.each(this.media_element.playable_sources, function(index, source)
 2259+ $j.each(this.media_element.getPlayableSources(), function(index, source)
22432260 {
22442261 var default_player = embedTypes.players.defaultPlayer(source.getMIMEType());
22452262 var source_select_code = 'document.getElementById(\''+_this.id+'\').closeDisplayedHTML(); document.getElementById(\''+_this.id+'\').media_element.selectSource(\''+index+'\');';
@@ -2255,8 +2272,7 @@
22562273 retval+='<a href="#" onClick="' + source_select_code + 'embedTypes.players.userSelectPlayer(\''+default_player.id+'\',\''+source.getMIMEType()+'\'); return false;">';
22572274 out += source.getTitle()+/*' - ' + default_player.getName() +*/ (is_not_selected?'</a>':'') + ' ';
22582275 out += /*'(<a href="#" onClick=\'$j("#player_select_list_'+index+'").fadeIn("slow");return false;\'>choose player</a>)' +*/ player_code;
2259 - }
2260 - else
 2276+ }else
22612277 out+= source.getTitle() + ' - no player available';
22622278 });
22632279 out+='</blockquote></span>';
@@ -2483,10 +2499,12 @@
24842500 setSliderValue: function(perc){
24852501 var id = (this.pc)?this.pc.pp.id:this.id;
24862502 //this.slider.setValue(perc);
2487 - var cur_slider = $j('#playhead_'+id).width();
2488 - var offset_perc = 1-(cur_slider / $j('#slider_'+id).width());
2489 - var val = Math.round( offset_perc* (perc * $j('#slider_'+id).width() ) );
2490 - $j('#playhead_'+id).css('left',val);
 2503+ //var cur_slider = $j('#mv_seeker_'+id).width();
 2504+ //var offset_perc = 1-(cur_slider / $j('#mv_seeker_'+id).width());
 2505+ //offset_perc*
 2506+ var val = Math.round( perc * $j('#mv_seeker_'+id).width() );
 2507+ $j('#mv_seeker_slider_'+id).css('marginLeft',val);
 2508+ js_log('perc in: ' + perc + ' * ' + $j('#mv_seeker_'+id).width() + ' = set to: '+ val);
24912509 //js_log('op:' + offset_perc + ' *('+perc+' * ' + $j('#slider_'+id).width() + ')');
24922510 },
24932511 setStatus:function(value){
@@ -2582,8 +2600,10 @@
25832601 return null;
25842602 }
25852603 times = ntp.split(':');
2586 - if(times.length!=3)
 2604+ if(times.length!=3){
 2605+ js_log('ntp2seconds:not valid ntp:'+ntp);
25872606 return null;
 2607+ }
25882608 //return seconds float (ie take seconds float value if present):
25892609 return parseInt(times[0]*3600)+parseInt(times[1]*60)+parseFloat(times[2]);
25902610 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/sample_page.php
@@ -50,7 +50,7 @@
5151 '<a href="javascript:document.getElementById(\'vflash\').play();">Play</a> | '.
5252 '<a href="javascript:document.getElementById(\'vflash\').stop();">Stop</a> <br />';
5353
54 -$sample_embed[2]['tag']='<video style="width:400px"><source type="video/ogg" src="http://128.114.20.64/media/senate_proceeding_05-15-08.ogg.anx?t=0:00:00/0:20:00" title="annodex ogg"/><source src="http://www.archive.org/download/mv_senate_proceeding_05-15-08/senate_proceeding_05-15-08.flv" title="flash"/></video>';
 54+$sample_embed[2]['tag']='<video style="width:400px"><source src="http://mvbox2.cse.ucsc.edu/mvFlvServer.php/senate_proceeding_08-01-07.flv?t=0:20:00/0:21:00" title="flash"/></video>';
5555 $sample_embed[2]['desc']='';
5656
5757 //$sample_embed[1]['tag'] = '<video roe="http://192.168.0.104/mvWiki/index.php?title=Special:MvExportStream&feed_format=roe&stream_name=Senate_proceeding_08-01-07&t=0:00:00/0:05:00">';
@@ -114,7 +114,7 @@
115115 ?>
116116 <table border="1" cellpadding="6" width="600">
117117 <? foreach($sample_embed as $key=>$aval){
118 - if($key!=3)continue;
 118+ if($key!=2)continue;
119119 ?>
120120 <tr>
121121 <td><?=$aval['tag']?></td>

Status & tagging log