1 window.cortadoDomainLocations = {
2 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar',
3 'tinyvid.tv' : 'http://tinyvid.tv/static/cortado.jar',
4 'media.tinyvid.tv' : 'http://media.tinyvid.tv/cortado.jar'
8 instanceOf:'javaEmbed',
10 logged_domain_error:false,
17 'volume_control':false
19 getEmbedHTML : function () {
20 // big delay on embed html cuz its just for status updates and ie6 is crazy.
22 setTimeout( 'document.getElementById(\'' + this.id + '\').postEmbedJS()', 500 );
23 // set a default duration of 30 seconds: cortao should detect duration.
24 return this.wrapEmebedContainer( this.getEmbedObj() );
26 getEmbedObj:function() {
27 js_log( "java play url:" + this.getURI( this.seek_time_sec ) );
30 // if still unset set to an arbitrary time 60 seconds:
31 if ( !this.duration )this.duration = 60;
32 // @@todo we should have src property in our base embed object
33 var mediaSrc = this.getSrc();
35 if ( mediaSrc.indexOf( '://' ) != -1 & mw.parseUri( document.URL ).host != mw.parseUri( mediaSrc ).host ) {
36 if ( window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host] ) {
37 applet_loc = window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host];
39 applet_loc = 'http://theora.org/cortado.jar';
42 // should be identical to cortado.jar
43 applet_loc = mv_embed_path + 'libEmbedVideo/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
45 // load directly in the page..
46 // (media must be on the same server or applet must be signed)
47 var appplet_code = '' +
48 '<applet id="' + this.pid + '" code="com.fluendo.player.Cortado.class" archive="' + applet_loc + '" width="' + this.width + '" height="' + this.height + '"> ' + "\n" +
49 '<param name="url" value="' + mediaSrc + '" /> ' + "\n" +
50 '<param name="local" value="false"/>' + "\n" +
51 '<param name="keepaspect" value="true" />' + "\n" +
52 '<param name="video" value="true" />' + "\n" +
53 '<param name="showStatus" value="hide" />' + "\n" +
54 '<param name="audio" value="true" />' + "\n" +
55 '<param name="seekable" value="true" />' + "\n" +
56 '<param name="duration" value="' + this.duration + '" />' + "\n" +
57 '<param name="bufferSize" value="4096" />' + "\n" +
60 // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar
61 // Doesn't work in MSIE or Safari/Mac or Opera 9.5
62 if ( embedTypes.mozilla ) {
63 var iframe = document.createElement( 'iframe' );
64 iframe.setAttribute( 'width', params.width );
65 iframe.setAttribute( 'height', playerHeight );
66 iframe.setAttribute( 'scrolling', 'no' );
67 iframe.setAttribute( 'frameborder', 0 );
68 iframe.setAttribute( 'marginWidth', 0 );
69 iframe.setAttribute( 'marginHeight', 0 );
70 iframe.setAttribute( 'id', 'cframe_' + this.id )
71 elt.appendChild( iframe );
72 var newDoc = iframe.contentDocument;
74 newDoc.write( '<html><body>' + appplet_code + '</body></html>' );
75 newDoc.close(); // spurious error in some versions of FF, no workaround known
80 postEmbedJS:function() {
81 // reset logged domain error flag:
82 this.logged_domain_error = false;
88 if ( this.isPlaying() ) {
89 if ( this.jce && this.jce.getPlayPosition ) {
91 // java reads ogg media time.. so no need to add the start or seek offset:
92 // js_log(' ct: ' + this.jce.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
93 this.currentTime = this.jce.getPlayPosition();
94 if ( this.jce.getPlayPosition() < 0 ) {
95 js_log( 'pp:' + this.jce.getPlayPosition() );
96 // probably reached clip end
100 js_log( 'could not get time from jPlayer: ' + e );
104 // once currentTime is updated call parent_monitor
105 this.parent_monitor();
108 * (local cortado seek does not seem to work very well)
110 doSeek:function( perc ) {
111 js_log( 'java:seek:p: ' + perc + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
114 if ( this.supportsURLTimeEncoding() ) {
115 this.parent_doSeek( perc );
116 // this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() );
117 // this.jce.setParam('url', this.getURI( this.seek_time_sec ))
118 // this.jce.restart();
119 } else if ( this.jce ) {
120 // do a (genneraly broken) local seek:
121 js_log( "cortado javascript seems to always fail ... but here we go... doSeek(" + ( perc * parseFloat( this.getDuration() ) ) );
122 this.jce.doSeek( perc * parseFloat( this.getDuration() ) );
124 this.doPlayThenSeek( perc );
127 doPlayThenSeek:function( perc ) {
128 js_log( 'doPlayThenSeek Hack' );
132 var readyForSeek = function() {
134 // if we have .jre ~in theory~ we can seek (but probably not)
136 _this.doSeek( perc );
138 // try to get player for 10 seconds:
139 if ( rfsCount < 200 ) {
140 setTimeout( readyForSeek, 50 );
143 js_log( 'error:doPlayThenSeek failed' );
149 // get java cortado embed object
151 if ( embedTypes.mozilla ) {
152 this.jce = window.frames['cframe_' + this.id ].document.getElementById( this.pid );
154 this.jce = $j( '#' + this.pid ).get( 0 );
157 doThumbnailHTML:function() {
158 // empty out player html (jquery with java applets does mix) :
159 var pelm = document.getElementById( 'dc_' + this.id );
163 this.parent_doThumbnailHTML();