r51323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51322‎ | r51323 | r51324 >
Date:00:20, 2 June 2009
Author:dale
Status:deferred
Tags:
Comment:
fixes for attributes setting if a source type supports temporal urls
switched back to java swapping ( url updating was not working very well)
Modified paths:
  • /branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_baseEmbed.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_htmlEmbed.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_javaEmbed.js (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_baseEmbed.js
@@ -41,9 +41,20 @@
4242 "download_link":true,
4343 "type":null //the content type of the media
4444 };
45 -
46 -
4745 /*
 46+ * the base source attibute checks
 47+ */
 48+var mv_default_source_attr= new Array(
 49+ 'id',
 50+ 'src',
 51+ 'title',
 52+ 'URLTimeEncoding', //boolean if we support temporal url requests on the source media
 53+ 'start',
 54+ 'end',
 55+ 'default',
 56+ 'lang'
 57+);
 58+/*
4859 * Converts all occurrences of <video> tag into video object
4960 */
5061 function mv_video_embed(swap_done_callback, force_id){
@@ -462,16 +473,7 @@
463474 this.init(element);
464475 }
465476
466 -var mv_default_source_attr= new Array(
467 - 'id',
468 - 'src',
469 - 'title',
470 - 'timeFormat',
471 - 'start',
472 - 'end',
473 - 'default',
474 - 'lang'
475 -);
 477+
476478 mediaSource.prototype =
477479 {
478480 /** MIME type of the source. */
@@ -483,7 +485,7 @@
484486 /** True if the source has been marked as the default. */
485487 marked_default:false,
486488 /** True if the source supports url specification of offset and duration */
487 - serverSideSeeking:false,
 489+ URLTimeEncoding:false,
488490 /** Start offset of the requested segment */
489491 start_offset:null,
490492 /** Duration of the requested segment (0 if not known) */
@@ -503,12 +505,12 @@
504506 if ( element.tagName.toLowerCase() == 'video')
505507 this.marked_default = true;
506508
507 - //set default timeFormat if we have a time url:
 509+ //set default URLTimeEncoding if we have a time url:
508510 //not ideal way to discover if content is on an oggz_chop server.
509511 //should check some other way.
510512 var pUrl = parseUri ( this.src );
511513 if(typeof pUrl['queryKey']['t'] != 'undefined'){
512 - this['timeFormat']='anx';
 514+ this['URLTimeEncoding']=true;
513515 }
514516
515517 for(var i=0; i < mv_default_source_attr.length; i++){ //for in loop oky on object
@@ -544,28 +546,19 @@
545547 //js_log("f:updateSrcTime: "+ start_ntp+'/'+ end_ntp + ' from org: ' + this.start_ntp+ '/'+this.end_ntp);
546548 //js_log("pre uri:" + this.src);
547549 //if we have time we can use:
548 - if( this.serverSideSeeking ){
 550+ if( this.URLTimeEncoding ){
549551 //make sure its a valid start time / end time (else set default)
550552 if( !npt2seconds(start_ntp) )
551553 start_ntp = this.start_ntp;
552554
553555 if( !npt2seconds(end_ntp) )
554556 end_ntp = this.end_ntp;
555 -
556 - if( this.timeFormat == 'anx' ){
557 - this.src = getURLParamReplace(this.src, { 't': start_ntp +'/'+end_ntp } );
558 - }else if ( this.timeFormat =='mp4'){
559 - var mp4URL = parseUri( this.src );
560 - this.src = mp4URL.protocol+'://'+mp4URL.authority + mp4URL.path +
561 - '?start=' + ( npt2seconds( start_ntp ) ) +
562 - '&end=' + ( npt2seconds( end_ntp ) );
563 - }
 557+
 558+ this.src = getURLParamReplace(this.src, { 't': start_ntp +'/'+end_ntp } );
564559
565560 //update the duration
566561 this.parseURLDuration();
567 - }
568 - //this.setDuration( )
569 - //js_log("post uri:" + this.src);
 562+ }
570563 },
571564 setDuration:function (duration)
572565 {
@@ -588,20 +581,11 @@
589582 @type String
590583 */
591584 getURI : function( seek_time_sec )
592 - {
593 - //js_log("f:getURI: tf:" + this.timeFormat +' uri_enc:'+this.serverSideSeeking);
594 - if( !seek_time_sec || !this.serverSideSeeking ){
 585+ {
 586+ if( !seek_time_sec || !this.URLTimeEncoding ){
595587 return this.src;
596 - }
597 - if( this.timeFormat == 'anx' ){
598 - var new_url = getURLParamReplace(this.src, { 't': seconds2npt( seek_time_sec )+'/'+ this.end_ntp } );
599 - }else if(this.timeFormat=='mp4'){
600 - var mp4URL = parseUri( this.src );
601 - var new_url = mp4URL.protocol+'://'+mp4URL.authority + mp4URL.path + '?start='
602 - + ( seek_time_sec + parseInt(mp4URL.queryKey['start']) );
603 - }
604 - //js_log('getURI seek url:'+ new_url);
605 - return new_url;
 588+ }
 589+ return getURLParamReplace(this.src, { 't': seconds2npt( seek_time_sec )+'/'+ this.end_ntp } ); ;
606590 },
607591 /** Title accessor function.
608592 @return the title of the source.
@@ -625,36 +609,20 @@
626610 * supports media_url?t=ntp_start/ntp_end url request format
627611 */
628612 parseURLDuration : function(){
629 - //check if we have a timeFormat:
630 - if( this.timeFormat ){
631 - if( this.timeFormat == 'anx' ){
632 - var annoURL = parseUri( this.src );
633 - if( annoURL.queryKey['t'] ){
634 - var times = annoURL.queryKey['t'].split('/');
635 - this.start_ntp = times[0];
636 - this.end_ntp = times[1];
637 - }
638 - }
639 - if( this.timeFormat == 'mp4' ){
640 - var mp4URL = parseUri( this.src );
641 - if( typeof mp4URL.queryKey['start'] != 'undefined' )
642 - this.start_ntp = seconds2npt( mp4URL.queryKey['start'] );
643 -
644 - if( typeof mp4URL.queryKey['end'] != 'undefined' ){
645 - this.end_ntp = seconds2npt( mp4URL.queryKey['end'] );
646 - //strip the &end param here (as per the mp4 format request (should fix server side)
647 - this.src = mp4URL.protocol+'://'+mp4URL.authority + mp4URL.path + '?start=' + mp4URL.queryKey['start'];
648 - }
649 - }
650 - this.serverSideSeeking = true;
 613+ //check if we have a URLTimeEncoding:
 614+ if( this.URLTimeEncoding ){
 615+ var annoURL = parseUri( this.src );
 616+ if( annoURL.queryKey['t'] ){
 617+ var times = annoURL.queryKey['t'].split('/');
 618+ this.start_ntp = times[0];
 619+ this.end_ntp = times[1];
 620+ }
651621 this.start_offset = npt2seconds( this.start_ntp );
652622 this.duration = npt2seconds( this.end_ntp ) - this.start_offset;
653 - } //time format
654 -
655 - if( !this.serverSideSeeking ){
 623+ }else{
656624 //else normal media request (can't predict the duration without the plugin reading it)
657 - this.duration = null;
658 - this.start_offset = 0;
 625+ this.duration = null;
 626+ this.start_offset = 0;
659627 this.start_ntp = seconds2npt(this.start_offset);
660628 }
661629 //js_log('f:parseURLDuration() for:' + this.src + ' d:' + this.duration);
@@ -1558,7 +1526,7 @@
15591527 //reset slider
15601528 this.setSliderValue(0);
15611529 //reset seek_offset:
1562 - if(this.media_element.selected_source.serverSideSeeking)
 1530+ if(this.media_element.selected_source.URLTimeEncoding )
15631531 this.seek_time_sec=0;
15641532 else
15651533 this.seek_time_sec=npt2seconds(start_ntp);
@@ -2212,7 +2180,7 @@
22132181 },
22142182 supportsURLTimeEncoding: function(){
22152183 //do head request if on the same domain
2216 - return this.media_element.selected_source.serverSideSeeking;
 2184+ return this.media_element.selected_source.URLTimeEncoding;
22172185 },
22182186 setSliderValue: function(perc, hide_progress){
22192187 var this_id = (this.pc)?this.pc.pp.id:this.id;
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_javaEmbed.js
@@ -1,3 +1,8 @@
 2+window.cortadoDomainLocations = {
 3+ 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar',
 4+ 'tinyvid.tv' : 'http://tinyvid.tv/static/cortado.jar'
 5+}
 6+
27 var javaEmbed = {
38 instanceOf:'javaEmbed',
49 iframe_src:'',
@@ -26,14 +31,18 @@
2732 var mediaSrc = this.media_element.selected_source.getURI( this.seek_time_sec );
2833
2934 if(mediaSrc.indexOf('://')!=-1 & parseUri(document.URL).host != parseUri(mediaSrc).host){
30 - applet_loc = 'http://theora.org/cortado.jar';
 35+ if(window.cortadoDomainLocations[parseUri(mediaSrc).host]){
 36+ applet_loc = window.cortadoDomainLocations[parseUri(mediaSrc).host];
 37+ }else{
 38+ applet_loc = 'http://theora.org/cortado.jar';
 39+ }
3140 }else{
3241 applet_loc = mv_embed_path+'binPlayers/cortado/cortado-wmf-r46643.jar';
3342 }
3443 //load directly in the page..
3544 // (media must be on the same server or applet must be signed)
3645 var appplet_code = ''+
37 - '<applet id="'+this.pid+'" code="com.fluendo.player.Cortado.class" archive="'+applet_loc+'" width="'+this.width+'" height="'+this.height+'"> '+ "\n"+
 46+ '<applet id="' + this.pid + '" code="com.fluendo.player.Cortado.class" archive="' + applet_loc + '" width="' + this.width + '" height="' + this.height + '"> '+ "\n"+
3847 '<param name="url" value="' + mediaSrc + '" /> ' + "\n"+
3948 '<param name="local" value="false"/>'+ "\n"+
4049 '<param name="keepaspect" value="true" />'+ "\n"+
@@ -41,7 +50,7 @@
4251 '<param name="showStatus" value="hide" />' + "\n"+
4352 '<param name="audio" value="true" />'+"\n"+
4453 '<param name="seekable" value="true" />'+"\n"+
45 - '<param name="duration" value="'+this.duration+'" />'+"\n"+
 54+ '<param name="duration" value="' + this.duration + '" />'+"\n"+
4655 '<param name="bufferSize" value="200" />'+"\n"+
4756 '</applet>';
4857 // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar
@@ -78,7 +87,7 @@
7988 //js_log(' ct: ' + this.jce.getPlayPosition() + ' so:' + this.start_offset + ' st:' + this.seek_time_sec);
8089 if(!this.start_offset)
8190 this.start_offset = 0;
82 - this.currentTime = this.jce.getPlayPosition();
 91+ this.currentTime = this.jce.getPlayPosition();
8392 }catch (e){
8493 ///js_log('could not get time from jPlayer: ' + e);
8594 }
@@ -90,19 +99,24 @@
91100 //once currentTime is updated call parent_monitor
92101 this.parent_monitor();
93102 },
 103+ /*
 104+ * (local cortado seek does not seem to work very well)
 105+ */
94106 doSeek:function(perc){
95 - this.getJCE();
96 - js_log('java:seek:p: ' + perc+ ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
97 -
98 - if(!this.jce)
99 - return this.parent_doSeek(perc);
100 -
101 - if( this.supportsURLTimeEncoding() ){
102 - this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() );
103 - this.jce.setParam('url', this.getURI( this.seek_time_sec ))
104 - this.jce.restart();
105 - }else if( this.vid.duration ){
106 - this.jce.currentTime = perc * this.vid.duration;
 107+ this.getJCE();
 108+ if(this.jce){
 109+ js_log('java:seek:p: ' + perc+ ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
 110+
 111+ if( this.supportsURLTimeEncoding() ){
 112+ this.parent_doSeek(perc);
 113+ //this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() );
 114+ // this.jce.setParam('url', this.getURI( this.seek_time_sec ))
 115+ //this.jce.restart();
 116+ }else{
 117+ //do a (genneraly broken) local seek:
 118+ js_log("cortado javascript seems to always fail ... but here we go... doSeek(" + perc * this.getDuration() );
 119+ this.jce.doSeek( perc * this.getDuration() );
 120+ }
107121 }
108122 },
109123 //get java cortado embed object
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_htmlEmbed.js
@@ -70,7 +70,7 @@
7171 library:"html"
7272 },
7373 selected_source:{
74 - serverSideSeeking:false
 74+ URLTimeEncoding:false
7575 },
7676 timedTextSources:function(){
7777 return false;

Status & tagging log