Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_baseEmbed.js |
— | — | @@ -41,9 +41,20 @@ |
42 | 42 | "download_link":true, |
43 | 43 | "type":null //the content type of the media |
44 | 44 | }; |
45 | | - |
46 | | - |
47 | 45 | /* |
| 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 | +/* |
48 | 59 | * Converts all occurrences of <video> tag into video object |
49 | 60 | */ |
50 | 61 | function mv_video_embed(swap_done_callback, force_id){ |
— | — | @@ -462,16 +473,7 @@ |
463 | 474 | this.init(element); |
464 | 475 | } |
465 | 476 | |
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 | + |
476 | 478 | mediaSource.prototype = |
477 | 479 | { |
478 | 480 | /** MIME type of the source. */ |
— | — | @@ -483,7 +485,7 @@ |
484 | 486 | /** True if the source has been marked as the default. */ |
485 | 487 | marked_default:false, |
486 | 488 | /** True if the source supports url specification of offset and duration */ |
487 | | - serverSideSeeking:false, |
| 489 | + URLTimeEncoding:false, |
488 | 490 | /** Start offset of the requested segment */ |
489 | 491 | start_offset:null, |
490 | 492 | /** Duration of the requested segment (0 if not known) */ |
— | — | @@ -503,12 +505,12 @@ |
504 | 506 | if ( element.tagName.toLowerCase() == 'video') |
505 | 507 | this.marked_default = true; |
506 | 508 | |
507 | | - //set default timeFormat if we have a time url: |
| 509 | + //set default URLTimeEncoding if we have a time url: |
508 | 510 | //not ideal way to discover if content is on an oggz_chop server. |
509 | 511 | //should check some other way. |
510 | 512 | var pUrl = parseUri ( this.src ); |
511 | 513 | if(typeof pUrl['queryKey']['t'] != 'undefined'){ |
512 | | - this['timeFormat']='anx'; |
| 514 | + this['URLTimeEncoding']=true; |
513 | 515 | } |
514 | 516 | |
515 | 517 | for(var i=0; i < mv_default_source_attr.length; i++){ //for in loop oky on object |
— | — | @@ -544,28 +546,19 @@ |
545 | 547 | //js_log("f:updateSrcTime: "+ start_ntp+'/'+ end_ntp + ' from org: ' + this.start_ntp+ '/'+this.end_ntp); |
546 | 548 | //js_log("pre uri:" + this.src); |
547 | 549 | //if we have time we can use: |
548 | | - if( this.serverSideSeeking ){ |
| 550 | + if( this.URLTimeEncoding ){ |
549 | 551 | //make sure its a valid start time / end time (else set default) |
550 | 552 | if( !npt2seconds(start_ntp) ) |
551 | 553 | start_ntp = this.start_ntp; |
552 | 554 | |
553 | 555 | if( !npt2seconds(end_ntp) ) |
554 | 556 | 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 } ); |
564 | 559 | |
565 | 560 | //update the duration |
566 | 561 | this.parseURLDuration(); |
567 | | - } |
568 | | - //this.setDuration( ) |
569 | | - //js_log("post uri:" + this.src); |
| 562 | + } |
570 | 563 | }, |
571 | 564 | setDuration:function (duration) |
572 | 565 | { |
— | — | @@ -588,20 +581,11 @@ |
589 | 582 | @type String |
590 | 583 | */ |
591 | 584 | 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 ){ |
595 | 587 | 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 } ); ; |
606 | 590 | }, |
607 | 591 | /** Title accessor function. |
608 | 592 | @return the title of the source. |
— | — | @@ -625,36 +609,20 @@ |
626 | 610 | * supports media_url?t=ntp_start/ntp_end url request format |
627 | 611 | */ |
628 | 612 | 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 | + } |
651 | 621 | this.start_offset = npt2seconds( this.start_ntp ); |
652 | 622 | this.duration = npt2seconds( this.end_ntp ) - this.start_offset; |
653 | | - } //time format |
654 | | - |
655 | | - if( !this.serverSideSeeking ){ |
| 623 | + }else{ |
656 | 624 | //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; |
659 | 627 | this.start_ntp = seconds2npt(this.start_offset); |
660 | 628 | } |
661 | 629 | //js_log('f:parseURLDuration() for:' + this.src + ' d:' + this.duration); |
— | — | @@ -1558,7 +1526,7 @@ |
1559 | 1527 | //reset slider |
1560 | 1528 | this.setSliderValue(0); |
1561 | 1529 | //reset seek_offset: |
1562 | | - if(this.media_element.selected_source.serverSideSeeking) |
| 1530 | + if(this.media_element.selected_source.URLTimeEncoding ) |
1563 | 1531 | this.seek_time_sec=0; |
1564 | 1532 | else |
1565 | 1533 | this.seek_time_sec=npt2seconds(start_ntp); |
— | — | @@ -2212,7 +2180,7 @@ |
2213 | 2181 | }, |
2214 | 2182 | supportsURLTimeEncoding: function(){ |
2215 | 2183 | //do head request if on the same domain |
2216 | | - return this.media_element.selected_source.serverSideSeeking; |
| 2184 | + return this.media_element.selected_source.URLTimeEncoding; |
2217 | 2185 | }, |
2218 | 2186 | setSliderValue: function(perc, hide_progress){ |
2219 | 2187 | 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 | + |
2 | 7 | var javaEmbed = { |
3 | 8 | instanceOf:'javaEmbed', |
4 | 9 | iframe_src:'', |
— | — | @@ -26,14 +31,18 @@ |
27 | 32 | var mediaSrc = this.media_element.selected_source.getURI( this.seek_time_sec ); |
28 | 33 | |
29 | 34 | 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 | + } |
31 | 40 | }else{ |
32 | 41 | applet_loc = mv_embed_path+'binPlayers/cortado/cortado-wmf-r46643.jar'; |
33 | 42 | } |
34 | 43 | //load directly in the page.. |
35 | 44 | // (media must be on the same server or applet must be signed) |
36 | 45 | 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"+ |
38 | 47 | '<param name="url" value="' + mediaSrc + '" /> ' + "\n"+ |
39 | 48 | '<param name="local" value="false"/>'+ "\n"+ |
40 | 49 | '<param name="keepaspect" value="true" />'+ "\n"+ |
— | — | @@ -41,7 +50,7 @@ |
42 | 51 | '<param name="showStatus" value="hide" />' + "\n"+ |
43 | 52 | '<param name="audio" value="true" />'+"\n"+ |
44 | 53 | '<param name="seekable" value="true" />'+"\n"+ |
45 | | - '<param name="duration" value="'+this.duration+'" />'+"\n"+ |
| 54 | + '<param name="duration" value="' + this.duration + '" />'+"\n"+ |
46 | 55 | '<param name="bufferSize" value="200" />'+"\n"+ |
47 | 56 | '</applet>'; |
48 | 57 | // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar |
— | — | @@ -78,7 +87,7 @@ |
79 | 88 | //js_log(' ct: ' + this.jce.getPlayPosition() + ' so:' + this.start_offset + ' st:' + this.seek_time_sec); |
80 | 89 | if(!this.start_offset) |
81 | 90 | this.start_offset = 0; |
82 | | - this.currentTime = this.jce.getPlayPosition(); |
| 91 | + this.currentTime = this.jce.getPlayPosition(); |
83 | 92 | }catch (e){ |
84 | 93 | ///js_log('could not get time from jPlayer: ' + e); |
85 | 94 | } |
— | — | @@ -90,19 +99,24 @@ |
91 | 100 | //once currentTime is updated call parent_monitor |
92 | 101 | this.parent_monitor(); |
93 | 102 | }, |
| 103 | + /* |
| 104 | + * (local cortado seek does not seem to work very well) |
| 105 | + */ |
94 | 106 | 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 | + } |
107 | 121 | } |
108 | 122 | }, |
109 | 123 | //get java cortado embed object |
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_htmlEmbed.js |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | library:"html" |
72 | 72 | }, |
73 | 73 | selected_source:{ |
74 | | - serverSideSeeking:false |
| 74 | + URLTimeEncoding:false |
75 | 75 | }, |
76 | 76 | timedTextSources:function(){ |
77 | 77 | return false; |