Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | /* the base video control JSON object with default attributes |
3 | | - * for supported attribute details see README |
4 | | - */ |
| 3 | +* for supported attribute details see README |
| 4 | +*/ |
5 | 5 | |
6 | 6 | loadGM({ |
7 | 7 | "mwe-loading_plugin" : "loading plugin <blink>...<\/blink>", |
— | — | @@ -45,13 +45,17 @@ |
46 | 46 | "mwe-ogg-player-selected" : "(selected)", |
47 | 47 | "mwe-ogg-player-omtkplayer" : "OMTK Flash Vorbis", |
48 | 48 | "mwe-generic_missing_plugin" : "You browser does not appear to support the following playback type: <b>$1<\/b><br \/>Visit the <a href=\"http:\/\/commons.wikimedia.org\/wiki\/Commons:Media_help\">Playback Methods<\/a> page to download a player.<br \/>", |
49 | | - "mwe-for_best_experience" : "For a better video playback experience we recommend:<br \/><b><a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/upgrade.html?from=mwEmbed\">Firefox 3.5<\/a>.<\/b>", |
| 49 | + "mwe-for_best_experience" : "For a better video playback experience we recommend: <b><a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/upgrade.html?from=mwEmbed\">Firefox 3.5<\/a>.<\/b>", |
50 | 50 | "mwe-do_not_warn_again" : "Dissmiss for now.", |
51 | 51 | "mwe-playerselect" : "Players", |
52 | 52 | "mwe-read_before_embed" : "Please <a href=\"http:\/\/mediawiki.org\/wiki\/Security_Notes_on_Remote_Embedding\" target=\"_new\">Read This<\/a> before embeding!", |
53 | | - "mwe-embed_site_or_blog" : "Embed on your site or blog" |
| 53 | + "mwe-embed_site_or_blog" : "Embed on your site or blog", |
| 54 | + "mwe_related_videos" : "Related Videos" |
54 | 55 | }); |
55 | 56 | |
| 57 | +//set the globals: |
| 58 | +var commons_api_url = 'http://commons.wikimedia.org/w/api.php'; |
| 59 | + |
56 | 60 | var default_video_attributes = { |
57 | 61 | "id":null, |
58 | 62 | "class":null, |
— | — | @@ -68,7 +72,8 @@ |
69 | 73 | "end":null, |
70 | 74 | "controls":true, |
71 | 75 | "muted":false, |
72 | | - |
| 76 | + "wikiTitleKey":null, |
| 77 | + |
73 | 78 | //roe url (for xml based metadata) |
74 | 79 | "roe":null, |
75 | 80 | //if roe includes metadata tracks we can expose a link to metadata |
— | — | @@ -82,15 +87,15 @@ |
83 | 88 | "duration":null, //media duration (read from file or the temporal url) |
84 | 89 | "networkState":0, |
85 | 90 | |
86 | | - "startOffset":null, //if serving an ogg_chop segment use this to offset the presentation time |
| 91 | + "startOffset":null, //if serving an ogg_chop segment use this to offset the presentation time |
87 | 92 | |
88 | 93 | //custom attributes for mv_embed: |
89 | | - "play_button":true, |
| 94 | + "play_button":true, |
90 | 95 | "thumbnail":null, |
91 | 96 | "linkback":null, |
92 | 97 | "embed_link":true, |
93 | 98 | "download_link":true, |
94 | | - "type":null //the content type of the media |
| 99 | + "type":null //the content type of the media |
95 | 100 | }; |
96 | 101 | /* |
97 | 102 | * the base source attibute checks |
— | — | @@ -103,11 +108,11 @@ |
104 | 109 | 'startOffset', |
105 | 110 | 'durationHint', |
106 | 111 | 'start', |
107 | | - 'end', |
| 112 | + 'end', |
108 | 113 | 'default', |
109 | 114 | 'lang' |
110 | 115 | ); |
111 | | -//set the dismissNativeWarn flag: |
| 116 | +//set the dismissNativeWarn flag: |
112 | 117 | _global['dismissNativeWarn'] = false; |
113 | 118 | /* |
114 | 119 | * Converts all occurrences of <video> tag into video object |
— | — | @@ -115,79 +120,79 @@ |
116 | 121 | function mv_video_embed(swap_done_callback, force_id){ |
117 | 122 | mvEmbed.init( swap_done_callback, force_id ); |
118 | 123 | } |
119 | | -mvEmbed = { |
120 | | - //flist stores the set of functions to run after the video has been swaped in. |
| 124 | +mvEmbed = { |
| 125 | + //flist stores the set of functions to run after the video has been swaped in. |
121 | 126 | flist:new Array(), |
122 | 127 | init:function( swap_done_callback, force_id ){ |
123 | | - |
| 128 | + |
124 | 129 | if(swap_done_callback) |
125 | 130 | mvEmbed.flist.push( swap_done_callback ); |
126 | | - |
| 131 | + |
127 | 132 | //get mv_embed location if it has not been set |
128 | | - js_log('mv_embed ' + MV_EMBED_VERSION); |
129 | | - |
130 | | - var loadPlaylistLib=false; |
131 | | - |
| 133 | + js_log('mv_embed ' + MV_EMBED_VERSION); |
| 134 | + |
| 135 | + var loadPlaylistLib=false; |
| 136 | + |
132 | 137 | var eAction = function(this_elm){ |
133 | 138 | js_log( "Do SWAP: " + $j(this_elm).attr("id") + ' tag: '+ this_elm.tagName.toLowerCase() ); |
134 | | - |
| 139 | + |
135 | 140 | if( $j(this_elm).attr("id") == '' ){ |
136 | 141 | $j(this_elm).attr("id", 'v'+ global_player_list.length); |
137 | | - } |
138 | | - //stre a global reference to the id |
| 142 | + } |
| 143 | + //stre a global reference to the id |
139 | 144 | global_player_list.push( $j(this_elm).attr("id") ); |
140 | 145 | //if video doSwap |
141 | 146 | switch( this_elm.tagName.toLowerCase()){ |
142 | 147 | case 'video': |
143 | | - var videoInterface = new embedVideo(this_elm); |
| 148 | + var videoInterface = new embedVideo(this_elm); |
144 | 149 | mvEmbed.swapEmbedVideoElement( this_elm, videoInterface ); |
145 | 150 | break; |
146 | 151 | case 'audio': |
147 | | - var videoInterface = new embedVideo(this_elm); |
| 152 | + var videoInterface = new embedVideo(this_elm); |
148 | 153 | videoInterface.type ='audio'; |
149 | 154 | mvEmbed.swapEmbedVideoElement( this_elm, videoInterface ); |
150 | 155 | break; |
151 | 156 | case 'playlist': |
152 | 157 | loadPlaylistLib=true; |
153 | 158 | break; |
154 | | - } |
| 159 | + } |
155 | 160 | } |
156 | | - |
| 161 | + |
157 | 162 | if( force_id == null && force_id != '' ){ |
158 | | - var j_selector = 'video,audio,playlist'; |
| 163 | + var j_selector = 'video,audio,playlist'; |
159 | 164 | }else{ |
160 | 165 | var j_selector = '#' + force_id; |
161 | 166 | } |
162 | | - //process selected elements: |
163 | | - //ie8 does not play well with the jQuery video,audio,playlist selector use native: |
| 167 | + //process selected elements: |
| 168 | + //ie8 does not play well with the jQuery video,audio,playlist selector use native: |
164 | 169 | if($j.browser.msie && $j.browser.version >= 8){ |
165 | | - jtags = j_selector.split(','); |
166 | | - for( var i=0; i < jtags.length; i++){ |
| 170 | + jtags = j_selector.split(','); |
| 171 | + for( var i=0; i < jtags.length; i++){ |
167 | 172 | $j( document.getElementsByTagName( jtags[i] )).each(function(){ |
168 | 173 | eAction(this); |
169 | 174 | }); |
170 | | - } |
171 | | - }else{ |
| 175 | + } |
| 176 | + }else{ |
172 | 177 | $j( j_selector ).each(function(){ |
173 | 178 | eAction(this); |
174 | | - }); |
175 | | - } |
176 | | - if(loadPlaylistLib){ |
177 | | - mvJsLoader.doLoad([ |
| 179 | + }); |
| 180 | + } |
| 181 | + if(loadPlaylistLib){ |
| 182 | + mvJsLoader.doLoad([ |
178 | 183 | 'mvPlayList', |
179 | 184 | '$j.ui', //include dialog for pop-ing up thigns |
180 | | - '$j.ui.dialog' |
| 185 | + '$j.ui.dialog' |
181 | 186 | ], function(){ |
182 | | - $j('playlist').each(function(){ |
| 187 | + $j('playlist').each(function(){ |
183 | 188 | //create new playlist interface: |
184 | 189 | var plObj = new mvPlayList( this ); |
185 | 190 | mvEmbed.swapEmbedVideoElement(this, plObj); |
186 | 191 | var added_height = plObj.pl_layout.title_bar_height + plObj.pl_layout.control_height; |
187 | | - //move into a blocking display container with height + controls + title height: |
188 | | - $j('#'+plObj.id).wrap('<div style="display:block;height:' + (plObj.height + added_height) + 'px;"></div>'); |
| 192 | + //move into a blocking display container with height + controls + title height: |
| 193 | + $j('#'+plObj.id).wrap('<div style="display:block;height:' + (plObj.height + added_height) + 'px;"></div>'); |
189 | 194 | }); |
190 | 195 | }); |
191 | | - } |
| 196 | + } |
192 | 197 | this.checkClipsReady(); |
193 | 198 | }, |
194 | 199 | /* |
— | — | @@ -199,13 +204,13 @@ |
200 | 205 | js_log('do swap ' + videoInterface.id + ' for ' + video_element); |
201 | 206 | embed_video = document.createElement('div'); |
202 | 207 | //make sure our div has a hight/width set: |
203 | | - |
| 208 | + |
204 | 209 | $j(embed_video).css({ |
205 | 210 | 'width':videoInterface.width, |
206 | 211 | 'height':videoInterface.height |
207 | | - }).html( mv_get_loading_img() ); |
| 212 | + }).html( mv_get_loading_img() ); |
208 | 213 | //inherit the video interface |
209 | | - for(var method in videoInterface){ //for in loop oky in Element context |
| 214 | + for(var method in videoInterface){ //for in loop oky in Element context |
210 | 215 | if(method!='readyState'){ //readyState crashes IE |
211 | 216 | if(method=='style'){ |
212 | 217 | embed_video.setAttribute('style', videoInterface[method]); |
— | — | @@ -222,32 +227,32 @@ |
223 | 228 | //string -> boolean: |
224 | 229 | if(embed_video[method]=="false")embed_video[method]=false; |
225 | 230 | if(embed_video[method]=="true")embed_video[method]=true; |
226 | | - } |
227 | | - ///js_log('did vI style'); |
228 | | - //now swap out the video element for the embed_video obj: |
229 | | - $j(video_element).after(embed_video).remove(); |
230 | | - //js_log('did swap'); |
231 | | - $j('#'+embed_video.id).get(0).on_dom_swap(); |
232 | | - |
| 231 | + } |
| 232 | + ///js_log('did vI style'); |
| 233 | + //now swap out the video element for the embed_video obj: |
| 234 | + $j(video_element).after(embed_video).remove(); |
| 235 | + //js_log('did swap'); |
| 236 | + $j('#'+embed_video.id).get(0).on_dom_swap(); |
| 237 | + |
233 | 238 | // now that "embed_video" is stable, do more initialization (if we are ready) |
234 | | - if($j('#'+embed_video.id).get(0).loading_external_data == false && |
| 239 | + if($j('#'+embed_video.id).get(0).loading_external_data == false && |
235 | 240 | $j('#'+embed_video.id).get(0).init_with_sources_loadedDone == false){ |
236 | | - //load and set ready state since source are available: |
| 241 | + //load and set ready state since source are available: |
237 | 242 | $j('#'+embed_video.id).get(0).init_with_sources_loaded(); |
238 | 243 | } |
239 | | - |
| 244 | + |
240 | 245 | js_log('done with child: ' + embed_video.id + ' len:' + global_player_list.length); |
241 | 246 | return true; |
242 | 247 | }, |
243 | 248 | //this should not be needed. |
244 | 249 | checkClipsReady : function(){ |
245 | 250 | //js_log('checkClipsReady'); |
246 | | - var is_ready=true; |
| 251 | + var is_ready=true; |
247 | 252 | for(var i=0; i < global_player_list.length; i++){ |
248 | 253 | if( $j('#'+global_player_list[i]).length !=0){ |
249 | | - var cur_vid = $j('#'+global_player_list[i]).get(0); |
| 254 | + var cur_vid = $j('#'+global_player_list[i]).get(0); |
250 | 255 | is_ready = ( cur_vid.ready_to_play ) ? is_ready : false; |
251 | | - if( !is_ready && cur_vid.load_error ){ |
| 256 | + if( !is_ready && cur_vid.load_error ){ |
252 | 257 | is_ready=true; |
253 | 258 | $j(cur_vid).html( cur_vid.load_error ); |
254 | 259 | } |
— | — | @@ -255,15 +260,15 @@ |
256 | 261 | } |
257 | 262 | if( is_ready ){ |
258 | 263 | mvEmbed.allClipsReady = true; |
259 | | - // run queued functions |
| 264 | + // run queued functions |
260 | 265 | //js_log('run queded functions:' + mvEmbed.flist[0]); |
261 | 266 | mvEmbed.runFlist(); |
262 | | - }else{ |
| 267 | + }else{ |
263 | 268 | setTimeout( 'mvEmbed.checkClipsReady()', 25 ); |
264 | | - } |
| 269 | + } |
265 | 270 | }, |
266 | 271 | runFlist:function(){ |
267 | | - while (this.flist.length){ |
| 272 | + while (this.flist.length){ |
268 | 273 | this.flist.shift()(); |
269 | 274 | } |
270 | 275 | } |
— | — | @@ -306,37 +311,37 @@ |
307 | 312 | |
308 | 313 | init : function(element) |
309 | 314 | { |
310 | | - //js_log('adding mediaSource: ' + element); |
| 315 | + //js_log('adding mediaSource: ' + element); |
311 | 316 | this.src = $j(element).attr('src'); |
312 | 317 | this.marked_default = false; |
313 | 318 | if ( element.tagName.toLowerCase() == 'video') |
314 | | - this.marked_default = true; |
315 | | - |
| 319 | + this.marked_default = true; |
| 320 | + |
316 | 321 | //set default URLTimeEncoding if we have a time url: |
317 | | - //not ideal way to discover if content is on an oggz_chop server. |
318 | | - //should check some other way. |
| 322 | + //not ideal way to discover if content is on an oggz_chop server. |
| 323 | + //should check some other way. |
319 | 324 | var pUrl = parseUri ( this.src ); |
320 | 325 | if(typeof pUrl['queryKey']['t'] != 'undefined'){ |
321 | | - this['URLTimeEncoding']=true; |
322 | | - } |
| 326 | + this['URLTimeEncoding']=true; |
| 327 | + } |
323 | 328 | for(var i=0; i < mv_default_source_attr.length; i++){ //array loop: |
324 | | - var attr = mv_default_source_attr[ i ]; |
| 329 | + var attr = mv_default_source_attr[ i ]; |
325 | 330 | if( $j(element).attr( attr ) ) { |
326 | 331 | this[ attr ] = $j(element).attr( attr ); |
327 | 332 | } |
328 | | - } |
329 | | - //update duration from hit if present: |
| 333 | + } |
| 334 | + //update duration from hit if present: |
330 | 335 | if(this.durationHint) |
331 | | - this.duration = this.durationHint; |
332 | | - |
333 | | - |
| 336 | + this.duration = this.durationHint; |
| 337 | + |
| 338 | + |
334 | 339 | if ( $j(element).attr('type')) |
335 | 340 | this.mime_type = $j(element).attr('type'); |
336 | 341 | else if ($j(element).attr('content-type')) |
337 | 342 | this.mime_type = $j(element).attr('content-type'); |
338 | | - else |
| 343 | + else |
339 | 344 | this.mime_type = this.detectType(this.src); |
340 | | - |
| 345 | + |
341 | 346 | //set the title if unset: |
342 | 347 | if( !this.title ) |
343 | 348 | this.title = this.mime_type; |
— | — | @@ -344,9 +349,9 @@ |
345 | 350 | this.parseURLDuration(); |
346 | 351 | }, |
347 | 352 | updateSource:function(element){ |
348 | | - //for now just update the title: |
| 353 | + //for now just update the title: |
349 | 354 | if ($j(element).attr("title")) |
350 | | - this.title = $j(element).attr("title"); |
| 355 | + this.title = $j(element).attr("title"); |
351 | 356 | }, |
352 | 357 | /** updates the src time and start & end |
353 | 358 | * @param {String} start_time in NTP format |
— | — | @@ -357,18 +362,18 @@ |
358 | 363 | //js_log("pre uri:" + this.src); |
359 | 364 | //if we have time we can use: |
360 | 365 | if( this.URLTimeEncoding ){ |
361 | | - //make sure its a valid start time / end time (else set default) |
362 | | - if( !npt2seconds(start_ntp) ) |
| 366 | + //make sure its a valid start time / end time (else set default) |
| 367 | + if( !npt2seconds(start_ntp) ) |
363 | 368 | start_ntp = this.start_ntp; |
364 | | - |
| 369 | + |
365 | 370 | if( !npt2seconds(end_ntp) ) |
366 | 371 | end_ntp = this.end_ntp; |
367 | | - |
368 | | - this.src = getURLParamReplace(this.src, { 't': start_ntp +'/'+ end_ntp } ); |
369 | | - |
| 372 | + |
| 373 | + this.src = getURLParamReplace(this.src, { 't': start_ntp +'/'+ end_ntp } ); |
| 374 | + |
370 | 375 | //update the duration |
371 | 376 | this.parseURLDuration(); |
372 | | - } |
| 377 | + } |
373 | 378 | }, |
374 | 379 | setDuration:function (duration) |
375 | 380 | { |
— | — | @@ -386,20 +391,20 @@ |
387 | 392 | return this.mime_type; |
388 | 393 | }, |
389 | 394 | /** URI accessor function. |
390 | | - * @param int seek_time_sec (used to adjust the URI for url based seeks) |
| 395 | + * @param int seek_time_sec (used to adjust the URI for url based seeks) |
391 | 396 | @return the URI of the source. |
392 | 397 | @type String |
393 | 398 | */ |
394 | 399 | getURI : function( seek_time_sec ) |
395 | | - { |
396 | | - if( !seek_time_sec || !this.URLTimeEncoding ){ |
397 | | - return this.src; |
398 | | - } |
| 400 | + { |
| 401 | + if( !seek_time_sec || !this.URLTimeEncoding ){ |
| 402 | + return this.src; |
| 403 | + } |
399 | 404 | if(!this.end_ntp){ |
400 | 405 | var endvar = ''; |
401 | 406 | }else{ |
402 | 407 | var endvar = '/'+ this.end_ntp; |
403 | | - } |
| 408 | + } |
404 | 409 | return getURLParamReplace(this.src, { 't': seconds2npt( seek_time_sec )+endvar } ); ; |
405 | 410 | }, |
406 | 411 | /** Title accessor function. |
— | — | @@ -423,9 +428,9 @@ |
424 | 429 | * special case derive duration from request url |
425 | 430 | * supports media_url?t=ntp_start/ntp_end url request format |
426 | 431 | */ |
427 | | - parseURLDuration : function(){ |
428 | | - //check if we have a URLTimeEncoding: |
429 | | - if( this.URLTimeEncoding ){ |
| 432 | + parseURLDuration : function(){ |
| 433 | + //check if we have a URLTimeEncoding: |
| 434 | + if( this.URLTimeEncoding ){ |
430 | 435 | var annoURL = parseUri( this.src ); |
431 | 436 | if( annoURL.queryKey['t'] ){ |
432 | 437 | var times = annoURL.queryKey['t'].split('/'); |
— | — | @@ -437,15 +442,15 @@ |
438 | 443 | //look for this info as attributes |
439 | 444 | if(this.startOffset){ |
440 | 445 | this.start_offset = this.startOffset; |
441 | | - this.start_ntp = seconds2npt( this.startOffset); |
442 | | - } |
| 446 | + this.start_ntp = seconds2npt( this.startOffset); |
| 447 | + } |
443 | 448 | if(this.duration){ |
444 | 449 | this.end_ntp = seconds2npt( parseInt(this.duration) + parseInt(this.start_offset) ); |
445 | | - } |
446 | | - } |
| 450 | + } |
| 451 | + } |
447 | 452 | } |
448 | 453 | //else nothing to parse just keep whatever info we already have |
449 | | - |
| 454 | + |
450 | 455 | //js_log('f:parseURLDuration() for:' + this.src + ' d:' + this.duration); |
451 | 456 | }, |
452 | 457 | /** Attempts to detect the type of a media file based on the URI. |
— | — | @@ -485,12 +490,12 @@ |
486 | 491 | mediaElement.prototype = |
487 | 492 | { |
488 | 493 | /** The array of mediaSource elements. */ |
489 | | - sources:null, |
490 | | - addedROEData:false, |
| 494 | + sources:null, |
| 495 | + addedROEData:false, |
491 | 496 | /** Selected mediaSource element. */ |
492 | 497 | selected_source:null, |
493 | 498 | thumbnail:null, |
494 | | - linkback:null, |
| 499 | + linkback:null, |
495 | 500 | |
496 | 501 | /** @private */ |
497 | 502 | init:function( video_element ) |
— | — | @@ -501,20 +506,23 @@ |
502 | 507 | this.thumbnail = mv_default_thumb_url; |
503 | 508 | // Process the source element: |
504 | 509 | if($j(video_element).attr("src")) |
505 | | - this.tryAddSource(video_element); |
506 | | - |
| 510 | + this.tryAddSource(video_element); |
| 511 | + |
507 | 512 | if($j(video_element).attr('thumbnail')) |
508 | 513 | this.thumbnail = $j(video_element).attr('thumbnail'); |
509 | | - |
| 514 | + |
510 | 515 | if($j(video_element).attr('poster')) |
511 | 516 | this.thumbnail = $j(video_element).attr('poster'); |
512 | | - |
513 | | - // Process all inner <source> elements |
| 517 | + |
| 518 | + if($j(video_element).attr('wikiTitleKey')) |
| 519 | + this.wikiTitleKey=$j(video_element).attr('wikiTitleKey'); |
| 520 | + |
| 521 | + // Process all inner <source> elements |
514 | 522 | //js_log("inner source count: " + video_element.getElementsByTagName('source').length ); |
515 | | - |
516 | | - $j(video_element).find('source,text').each(function(inx, inner_source){ |
| 523 | + |
| 524 | + $j(video_element).find('source,text').each(function(inx, inner_source){ |
517 | 525 | _this.tryAddSource( inner_source ); |
518 | | - }); |
| 526 | + }); |
519 | 527 | }, |
520 | 528 | /** Updates the time request for all sources that have a standard time request argument (ie &t=start_time/end_time) |
521 | 529 | */ |
— | — | @@ -526,10 +534,10 @@ |
527 | 535 | }, |
528 | 536 | /*timed Text check*/ |
529 | 537 | timedTextSources:function(){ |
530 | | - for(var i=0; i < this.sources.length; i++){ |
| 538 | + for(var i=0; i < this.sources.length; i++){ |
531 | 539 | if( this.sources[i].mime_type == 'text/cmml' || |
532 | 540 | this.sources[i].mime_type == 'text/x-srt') |
533 | | - return true; |
| 541 | + return true; |
534 | 542 | }; |
535 | 543 | return false; |
536 | 544 | }, |
— | — | @@ -540,7 +548,7 @@ |
541 | 549 | { |
542 | 550 | if(!mime_filter) |
543 | 551 | return this.sources; |
544 | | - //apply mime filter: |
| 552 | + //apply mime filter: |
545 | 553 | var source_set = new Array(); |
546 | 554 | for(var i=0; i < this.sources.length ; i++){ |
547 | 555 | if( this.sources[i].mime_type.indexOf( mime_filter ) != -1 ) |
— | — | @@ -548,7 +556,7 @@ |
549 | 557 | } |
550 | 558 | return source_set; |
551 | 559 | }, |
552 | | - getSourceById:function( source_id ){ |
| 560 | + getSourceById:function( source_id ){ |
553 | 561 | for(var i=0; i < this.sources.length ; i++){ |
554 | 562 | if( this.sources[i].id == source_id) |
555 | 563 | return this.sources[i]; |
— | — | @@ -564,70 +572,70 @@ |
565 | 573 | for(var i=0; i < playable_sources.length; i++){ |
566 | 574 | if( i==index ){ |
567 | 575 | this.selected_source = playable_sources[i]; |
568 | | - //update the user selected format: |
| 576 | + //update the user selected format: |
569 | 577 | embedTypes.players.userSelectFormat( playable_sources[i].mime_type ); |
570 | 578 | break; |
571 | 579 | } |
572 | | - } |
| 580 | + } |
573 | 581 | }, |
574 | 582 | /** selects the default source via cookie preference, default marked, or by id order |
575 | 583 | * */ |
576 | | - autoSelectSource:function(){ |
577 | | - js_log('f:autoSelectSource:'); |
578 | | - //@@todo read user preference for source |
| 584 | + autoSelectSource:function(){ |
| 585 | + js_log('f:autoSelectSource:'); |
| 586 | + //@@todo read user preference for source |
579 | 587 | // Select the default source |
580 | | - var playable_sources = this.getPlayableSources(); |
581 | | - var flash_flag=ogg_flag=false; |
| 588 | + var playable_sources = this.getPlayableSources(); |
| 589 | + var flash_flag=ogg_flag=false; |
582 | 590 | //debugger; |
583 | 591 | for(var source=0; source < playable_sources.length; source++){ |
584 | 592 | var mime_type =playable_sources[source].mime_type; |
585 | 593 | if( playable_sources[source].marked_default ){ |
586 | 594 | js_log('set via marked default: ' + playable_sources[source].marked_default); |
587 | | - this.selected_source = playable_sources[source]; |
| 595 | + this.selected_source = playable_sources[source]; |
588 | 596 | return true; |
589 | 597 | } |
590 | 598 | //set via user-preference |
591 | 599 | if(embedTypes.players.preference['format_prefrence'] == mime_type){ |
592 | 600 | js_log('set via preference: '+playable_sources[source].mime_type); |
593 | 601 | this.selected_source = playable_sources[source]; |
594 | | - return true; |
595 | | - } |
596 | | - } |
597 | | - //set Ogg via player support |
| 602 | + return true; |
| 603 | + } |
| 604 | + } |
| 605 | + //set Ogg via player support |
598 | 606 | for(var source=0; source < playable_sources.length; source++){ |
599 | 607 | js_log('f:autoSelectSource:' + playable_sources[source].mime_type); |
600 | | - var mime_type =playable_sources[source].mime_type; |
601 | | - //set source via player |
602 | | - if(mime_type=='video/ogg' || mime_type=='ogg/video' || mime_type=='video/annodex' || mime_type=='application/ogg'){ |
| 608 | + var mime_type =playable_sources[source].mime_type; |
| 609 | + //set source via player |
| 610 | + if(mime_type=='video/ogg' || mime_type=='ogg/video' || mime_type=='video/annodex' || mime_type=='application/ogg'){ |
603 | 611 | for(var i=0; i < embedTypes.players.players.length; i++){ //for in loop on object oky |
604 | | - var player = embedTypes.players.players[i]; |
| 612 | + var player = embedTypes.players.players[i]; |
605 | 613 | if(player.library=='vlc' || player.library=='native'){ |
606 | | - js_log('set via ogg via order'); |
607 | | - this.selected_source = playable_sources[source]; |
| 614 | + js_log('set via ogg via order'); |
| 615 | + this.selected_source = playable_sources[source]; |
608 | 616 | return true; |
609 | | - } |
| 617 | + } |
610 | 618 | } |
611 | 619 | } |
612 | 620 | } |
613 | 621 | //set basic flash |
614 | | - for(var source=0; source < playable_sources.length; source++){ |
615 | | - var mime_type =playable_sources[source].mime_type; |
| 622 | + for(var source=0; source < playable_sources.length; source++){ |
| 623 | + var mime_type =playable_sources[source].mime_type; |
616 | 624 | if( mime_type=='video/x-flv' ){ |
617 | 625 | js_log('set via by player preference normal flash') |
618 | 626 | this.selected_source = playable_sources[source]; |
619 | 627 | return true; |
620 | | - } |
| 628 | + } |
621 | 629 | } |
622 | | - //set h264 flash |
623 | | - for(var source=0; source < playable_sources.length; source++){ |
624 | | - var mime_type =playable_sources[source].mime_type; |
| 630 | + //set h264 flash |
| 631 | + for(var source=0; source < playable_sources.length; source++){ |
| 632 | + var mime_type =playable_sources[source].mime_type; |
625 | 633 | if( mime_type=='video/h264' ){ |
626 | 634 | js_log('set via playable_sources preference h264 flash') |
627 | 635 | this.selected_source = playable_sources[source]; |
628 | 636 | return true; |
629 | | - } |
630 | | - } |
631 | | - //select first source |
| 637 | + } |
| 638 | + } |
| 639 | + //select first source |
632 | 640 | if (!this.selected_source) |
633 | 641 | { |
634 | 642 | js_log('set via first source:' + playable_sources[0]); |
— | — | @@ -666,48 +674,48 @@ |
667 | 675 | //return mime_type=='video/ogg' || mime_type=='ogg/video' || mime_type=='video/annodex' || mime_type=='video/x-flv'; |
668 | 676 | }, |
669 | 677 | /** Adds a single mediaSource using the provided element if |
670 | | - the element has a 'src' attribute. |
| 678 | + the element has a 'src' attribute. |
671 | 679 | @param element {element} <video>, <source> or <mediaSource> element. |
672 | 680 | */ |
673 | 681 | tryAddSource:function(element) |
674 | 682 | { |
675 | | - js_log('f:tryAddSource:'+ $j(element).attr("src")); |
| 683 | + js_log('f:tryAddSource:'+ $j(element).attr("src")); |
676 | 684 | if (! $j(element).attr("src")){ |
677 | 685 | //js_log("element has no src"); |
678 | 686 | return false; |
679 | 687 | } |
680 | 688 | var new_src = $j(element).attr('src'); |
681 | | - //make sure an existing element with the same src does not already exist: |
682 | | - for( var i=0; i < this.sources.length; i++ ){ |
| 689 | + //make sure an existing element with the same src does not already exist: |
| 690 | + for( var i=0; i < this.sources.length; i++ ){ |
683 | 691 | if(this.sources[i].src == new_src){ |
684 | | - //js_log('checking existing: '+this.sources[i].getURI() + ' != '+ new_src); |
685 | | - //can't add it all but try to update any additional attr: |
| 692 | + //js_log('checking existing: '+this.sources[i].getURI() + ' != '+ new_src); |
| 693 | + //can't add it all but try to update any additional attr: |
686 | 694 | this.sources[i].updateSource(element); |
687 | 695 | return false; |
688 | 696 | } |
689 | 697 | } |
690 | | - var source = new mediaSource( element ); |
691 | | - this.sources.push(source); |
| 698 | + var source = new mediaSource( element ); |
| 699 | + this.sources.push(source); |
692 | 700 | //alert('pushed source to stack'+ source + 'sl:'+this.sources.length); |
693 | 701 | }, |
694 | | - getPlayableSources: function(){ |
| 702 | + getPlayableSources: function(){ |
695 | 703 | var playable_sources= new Array(); |
696 | | - for(var i=0; i < this.sources.length; i++){ |
697 | | - if( this.isPlayableType( this.sources[i].mime_type ) ){ |
| 704 | + for(var i=0; i < this.sources.length; i++){ |
| 705 | + if( this.isPlayableType( this.sources[i].mime_type ) ){ |
698 | 706 | playable_sources.push( this.sources[i] ); |
699 | 707 | }else{ |
700 | 708 | js_log("type "+ this.sources[i].mime_type + 'is not playable'); |
701 | 709 | } |
702 | | - }; |
| 710 | + }; |
703 | 711 | return playable_sources; |
704 | 712 | }, |
705 | 713 | /* Imports media sources from ROE data. |
706 | 714 | * @param roe_data ROE data. |
707 | 715 | */ |
708 | | - addROE:function(roe_data){ |
| 716 | + addROE:function(roe_data){ |
709 | 717 | js_log('f:addROE'); |
710 | 718 | this.addedROEData=true; |
711 | | - var _this = this; |
| 719 | + var _this = this; |
712 | 720 | if( typeof roe_data == 'string' ) |
713 | 721 | { |
714 | 722 | var parser=new DOMParser(); |
— | — | @@ -734,7 +742,7 @@ |
735 | 743 | }); |
736 | 744 | }else{ |
737 | 745 | js_log('ROE data empty.'); |
738 | | - } |
| 746 | + } |
739 | 747 | } |
740 | 748 | }; |
741 | 749 | |
— | — | @@ -750,7 +758,7 @@ |
751 | 759 | embedVideo.prototype = { |
752 | 760 | /** The mediaElement object containing all mediaSource objects */ |
753 | 761 | media_element:null, |
754 | | - preview_mode:false, |
| 762 | + preview_mode:false, |
755 | 763 | ready_to_play:false, //should use html5 ready state |
756 | 764 | load_error:false, //used to set error in case of error |
757 | 765 | loading_external_data:false, |
— | — | @@ -758,19 +766,19 @@ |
759 | 767 | thumbnail_disp:true, |
760 | 768 | init_with_sources_loadedDone:false, |
761 | 769 | inDOM:false, |
762 | | - //for onClip done stuff: |
| 770 | + //for onClip done stuff: |
763 | 771 | anno_data_cache:null, |
764 | 772 | seek_time_sec:0, |
765 | 773 | base_seeker_slider_offset:null, |
766 | 774 | onClipDone_disp:false, |
767 | | - supports:{}, |
| 775 | + supports:{}, |
768 | 776 | //for seek thumb updates: |
769 | 777 | cur_thumb_seek_time:0, |
770 | 778 | thumb_seek_interval:null, |
771 | | - |
| 779 | + |
772 | 780 | seeking:false, |
773 | | - //set the buffered percent: |
774 | | - bufferedPercent:0, |
| 781 | + //set the buffered percent: |
| 782 | + bufferedPercent:0, |
775 | 783 | //utility functions for property values: |
776 | 784 | hx : function ( s ) { |
777 | 785 | if ( typeof s != 'String' ) { |
— | — | @@ -799,7 +807,7 @@ |
800 | 808 | else |
801 | 809 | return parseInt(this.height); |
802 | 810 | }, |
803 | | - init: function(element){ |
| 811 | + init: function(element){ |
804 | 812 | //this.element_pointer = element; |
805 | 813 | |
806 | 814 | //inherit all the default video_attributes |
— | — | @@ -812,16 +820,16 @@ |
813 | 821 | //js_log('attr:' + attr + ' val: ' + video_attributes[attr] +" "+ 'elm_val:' + element.getAttribute(attr) + "\n (set by attr)"); |
814 | 822 | } |
815 | 823 | } |
816 | | - //make sure startOffset is cast as an int |
| 824 | + //make sure startOffset is cast as an int |
817 | 825 | if( this.startOffset && this.startOffset.split(':').length >= 2) |
818 | 826 | this.startOffset = npt2seconds(this.startOffset); |
819 | | - //make sure offset is in float: |
| 827 | + //make sure offset is in float: |
820 | 828 | this.startOffset = parseFloat(this.startOffset); |
821 | | - |
| 829 | + |
822 | 830 | if( this.duration && this.duration.split(':').length >= 2) |
823 | | - this.duration = npt2seconds( this.duration ); |
824 | | - //make sure duration is in float: |
825 | | - this.duration = parseFloat(this.duration); |
| 831 | + this.duration = npt2seconds( this.duration ); |
| 832 | + //make sure duration is in float: |
| 833 | + this.duration = parseFloat(this.duration); |
826 | 834 | js_log("duration is: " + this.duration); |
827 | 835 | //if style is set override width and height |
828 | 836 | var dwh = mwConfig['video_size'].split('x'); |
— | — | @@ -835,114 +843,114 @@ |
836 | 844 | if(element.innerHTML!='' && element.getElementsByTagName('source').length==0){ |
837 | 845 | js_log('innerHTML: ' + element.innerHTML); |
838 | 846 | this.user_missing_plugin_html=element.innerHTML; |
839 | | - } |
| 847 | + } |
840 | 848 | // load all of the specified sources |
841 | | - this.media_element = new mediaElement(element); |
| 849 | + this.media_element = new mediaElement(element); |
842 | 850 | }, |
843 | 851 | on_dom_swap: function(){ |
844 | | - js_log('f:on_dom_swap'); |
| 852 | + js_log('f:on_dom_swap'); |
845 | 853 | // Process the provided ROE file... if we don't yet have sources |
846 | 854 | if(this.roe && this.media_element.sources.length==0 ){ |
847 | 855 | js_log('loading external data'); |
848 | 856 | this.loading_external_data=true; |
849 | | - var _this = this; |
| 857 | + var _this = this; |
850 | 858 | do_request(this.roe, function(data) |
851 | | - { |
852 | | - //continue |
853 | | - _this.media_element.addROE( data ); |
854 | | - js_log('added_roe::' + _this.media_element.sources.length); |
855 | | - |
856 | | - js_log('set loading_external_data=false'); |
857 | | - _this.loading_external_data=false; |
858 | | - |
859 | | - _this.init_with_sources_loaded(); |
| 859 | + { |
| 860 | + //continue |
| 861 | + _this.media_element.addROE( data ); |
| 862 | + js_log('added_roe::' + _this.media_element.sources.length); |
| 863 | + |
| 864 | + js_log('set loading_external_data=false'); |
| 865 | + _this.loading_external_data=false; |
| 866 | + |
| 867 | + _this.init_with_sources_loaded(); |
860 | 868 | }); |
861 | 869 | } |
862 | 870 | }, |
863 | 871 | init_with_sources_loaded : function() |
864 | | - { |
| 872 | + { |
865 | 873 | js_log('f:init_with_sources_loaded'); |
866 | 874 | //set flag that we have run this function: |
867 | | - this.init_with_sources_loadedDone=true; |
| 875 | + this.init_with_sources_loadedDone=true; |
868 | 876 | //autoseletct the source |
869 | | - this.media_element.autoSelectSource(); |
| 877 | + this.media_element.autoSelectSource(); |
870 | 878 | //auto select player based on prefrence or default order |
871 | 879 | if( !this.media_element.selected_source ) |
872 | 880 | { |
873 | | - //check for parent clip: |
874 | | - if( typeof this.pc != 'undefined' ){ |
875 | | - js_log('no sources, type:' +this.type + ' check for html'); |
876 | | - //debugger; |
877 | | - //do load player if just displaying innerHTML: |
| 881 | + //check for parent clip: |
| 882 | + if( typeof this.pc != 'undefined' ){ |
| 883 | + js_log('no sources, type:' +this.type + ' check for html'); |
| 884 | + //debugger; |
| 885 | + //do load player if just displaying innerHTML: |
878 | 886 | if( this.pc.type == 'text/html' ){ |
879 | 887 | this.selected_player = embedTypes.players.defaultPlayer( 'text/html' ); |
880 | | - js_log('set selected player:'+ this.selected_player.mime_type); |
| 888 | + js_log('set selected player:'+ this.selected_player.mime_type); |
881 | 889 | } |
882 | 890 | } |
883 | | - }else{ |
| 891 | + }else{ |
884 | 892 | this.selected_player = embedTypes.players.defaultPlayer( this.media_element.selected_source.mime_type ); |
885 | | - } |
| 893 | + } |
886 | 894 | if( this.selected_player ){ |
887 | 895 | js_log('selected ' + this.selected_player.getName()); |
888 | 896 | js_log("PLAYBACK TYPE: "+this.selected_player.library); |
889 | | - this.thumbnail_disp = true; |
890 | | - this.inheritEmbedObj(); |
891 | | - }else{ |
| 897 | + this.thumbnail_disp = true; |
| 898 | + this.inheritEmbedObj(); |
| 899 | + }else{ |
892 | 900 | //no source's playable |
893 | 901 | var missing_type =''; |
894 | | - var or =''; |
| 902 | + var or =''; |
895 | 903 | for( var i=0; i < this.media_element.sources.length; i++){ |
896 | 904 | missing_type+= or + this.media_element.sources[i].mime_type; |
897 | 905 | or=' or '; |
898 | | - } |
| 906 | + } |
899 | 907 | if( this.pc ) |
900 | | - var missing_type = this.pc.type; |
| 908 | + var missing_type = this.pc.type; |
901 | 909 | js_log('no player found for given source type ' + missing_type); |
902 | | - this.load_error= this.getPluginMissingHTML(missing_type); |
903 | | - } |
| 910 | + this.load_error= this.getPluginMissingHTML(missing_type); |
| 911 | + } |
904 | 912 | }, |
905 | | - inheritEmbedObj:function(){ |
906 | | - js_log("inheritEmbedObj:duration is: " + this.duration); |
| 913 | + inheritEmbedObj:function(){ |
| 914 | + js_log("inheritEmbedObj:duration is: " + this.duration); |
907 | 915 | //@@note: tricky cuz direct overwrite is not so ideal.. since the extended object is already tied to the dom |
908 | 916 | //clear out any non-base embedObj stuff: |
909 | 917 | if(this.instanceOf){ |
910 | 918 | eval('tmpObj = '+this.instanceOf); |
911 | | - for(var i in tmpObj){ //for in loop oky for object |
| 919 | + for(var i in tmpObj){ //for in loop oky for object |
912 | 920 | if(this['parent_'+i]){ |
913 | 921 | this[i]=this['parent_'+i]; |
914 | 922 | }else{ |
915 | 923 | this[i]=null; |
916 | 924 | } |
917 | 925 | } |
918 | | - } |
| 926 | + } |
919 | 927 | //set up the new embedObj |
920 | 928 | js_log('f: inheritEmbedObj: embedding with ' + this.selected_player.library); |
921 | | - var _this = this; |
| 929 | + var _this = this; |
922 | 930 | this.selected_player.load( function() |
923 | 931 | { |
924 | | - js_log("selected_player::load:duration is: " + _this.duration); |
| 932 | + js_log("selected_player::load:duration is: " + _this.duration); |
925 | 933 | //js_log('inheriting '+_this.selected_player.library +'Embed to ' + _this.id + ' ' + $j('#'+_this.id).length); |
926 | 934 | //var _this = $j('#'+_this.id).get(0); |
927 | 935 | //js_log( 'type of ' + _this.selected_player.library +'Embed + ' + |
928 | | - // eval('typeof '+_this.selected_player.library +'Embed')); |
| 936 | + // eval('typeof '+_this.selected_player.library +'Embed')); |
929 | 937 | eval('embedObj = ' +_this.selected_player.library +'Embed;'); |
930 | | - for(var method in embedObj){ //for in loop oky for object |
| 938 | + for(var method in embedObj){ //for in loop oky for object |
931 | 939 | //parent method preservation for local overwritten methods |
932 | 940 | if(_this[method]) |
933 | 941 | _this['parent_' + method] = _this[method]; |
934 | 942 | _this[method]=embedObj[method]; |
935 | 943 | } |
936 | 944 | js_log('TYPEOF_ppause: ' + typeof _this['parent_pause']); |
937 | | - |
| 945 | + |
938 | 946 | if(_this.inheritEmbedOverride){ |
939 | 947 | _this.inheritEmbedOverride(); |
940 | 948 | } |
941 | 949 | //update controls if possible |
942 | 950 | if(!_this.loading_external_data) |
943 | | - _this.refreshControlsHTML(); |
944 | | - |
945 | | - //js_log("READY TO PLAY:"+_this.id); |
946 | | - _this.ready_to_play=true; |
| 951 | + _this.refreshControlsHTML(); |
| 952 | + |
| 953 | + //js_log("READY TO PLAY:"+_this.id); |
| 954 | + _this.ready_to_play=true; |
947 | 955 | _this.getDuration(); |
948 | 956 | _this.getHTML(); |
949 | 957 | }); |
— | — | @@ -953,61 +961,61 @@ |
954 | 962 | if(this.selected_player.id != player.id){ |
955 | 963 | this.selected_player = player; |
956 | 964 | this.inheritEmbedObj(); |
957 | | - } |
| 965 | + } |
958 | 966 | }, |
959 | | - doNativeWarningCheck:function(){ |
| 967 | + doNativeWarningCheck:function(){ |
960 | 968 | if( $j.cookie('dismissNativeWarn') && $j.cookie('dismissNativeWarn')===true){ |
961 | 969 | return false; |
962 | | - }else{ |
963 | | - //see if we have native support for ogg: |
964 | | - var supporting_players = embedTypes.players.getMIMETypePlayers( 'video/ogg' ); |
| 970 | + }else{ |
| 971 | + //see if we have native support for ogg: |
| 972 | + var supporting_players = embedTypes.players.getMIMETypePlayers( 'video/ogg' ); |
965 | 973 | for(var i=0; i < supporting_players.length; i++){ |
966 | 974 | if(supporting_players[i].id == 'videoElement'){ |
967 | 975 | return false; |
968 | | - } |
969 | | - } |
970 | | - //see if we are using mv_embed without a ogg source in which case no point in promoting firefox :P |
| 976 | + } |
| 977 | + } |
| 978 | + //see if we are using mv_embed without a ogg source in which case no point in promoting firefox :P |
971 | 979 | if(this.media_element && this.media_element.sources){ |
972 | 980 | var foundOgg = false; |
973 | 981 | var playable_sources = this.media_element.getPlayableSources(); |
974 | | - for(var sInx=0; sInx < playable_sources.length; sInx++){ |
| 982 | + for(var sInx=0; sInx < playable_sources.length; sInx++){ |
975 | 983 | var mime_type = playable_sources[sInx].mime_type; |
976 | 984 | if( mime_type=='video/ogg' ){ |
977 | | - //they have flash / h.264 fallback no need to push firefox :( |
| 985 | + //they have flash / h.264 fallback no need to push firefox :( |
978 | 986 | foundOgg = true; |
979 | 987 | } |
980 | 988 | } |
981 | 989 | //no ogg no point in download firefox |
982 | 990 | if(!foundOgg) |
983 | 991 | return false; |
984 | | - |
| 992 | + |
985 | 993 | } |
986 | 994 | } |
987 | | - return true; |
| 995 | + return true; |
988 | 996 | }, |
989 | 997 | getTimeReq:function(){ |
990 | 998 | var default_time_req = '0:00:00/' + seconds2npt(this.getDuration()); |
991 | 999 | if(!this.media_element) |
992 | 1000 | return default_time_req; |
993 | 1001 | if(!this.media_element.selected_source) |
994 | | - return default_time_req; |
| 1002 | + return default_time_req; |
995 | 1003 | if(!this.media_element.selected_source.end_ntp) |
996 | | - return default_time_req; |
| 1004 | + return default_time_req; |
997 | 1005 | return this.media_element.selected_source.start_ntp+'/'+this.media_element.selected_source.end_ntp; |
998 | | - }, |
999 | | - getDuration:function(){ |
1000 | | - //update some local pointers for the selected source: |
1001 | | - if(this.media_element && this.media_element.selected_source && this.media_element.selected_source.duration){ |
1002 | | - this.duration = this.media_element.selected_source.duration; |
| 1006 | + }, |
| 1007 | + getDuration:function(){ |
| 1008 | + //update some local pointers for the selected source: |
| 1009 | + if(this.media_element && this.media_element.selected_source && this.media_element.selected_source.duration){ |
| 1010 | + this.duration = this.media_element.selected_source.duration; |
1003 | 1011 | this.start_offset = this.media_element.selected_source.start_offset; |
1004 | 1012 | this.start_ntp = this.media_element.selected_source.start_ntp; |
1005 | | - this.end_ntp = this.media_element.selected_source.end_ntp; |
| 1013 | + this.end_ntp = this.media_element.selected_source.end_ntp; |
1006 | 1014 | } |
1007 | | - //update start end_ntp if duration !=0 (set from plugin) |
| 1015 | + //update start end_ntp if duration !=0 (set from plugin) |
1008 | 1016 | if(!this.start_ntp) |
1009 | 1017 | this.start_ntp = '0:0:0'; |
1010 | 1018 | if(!this.end_ntp && this.duration) |
1011 | | - this.end_ntp = seconds2npt( this.duration ); |
| 1019 | + this.end_ntp = seconds2npt( this.duration ); |
1012 | 1020 | //return the duration |
1013 | 1021 | return this.duration; |
1014 | 1022 | }, |
— | — | @@ -1015,48 +1023,48 @@ |
1016 | 1024 | * wrapEmebedContainer |
1017 | 1025 | * wraps the embed code into a container to better support playlist function |
1018 | 1026 | * (where embed element is swapped for next clip |
1019 | | - * (where plugin method does not support playlsits) |
| 1027 | + * (where plugin method does not support playlsits) |
1020 | 1028 | */ |
1021 | 1029 | wrapEmebedContainer:function(embed_code){ |
1022 | 1030 | //check if parent clip is set( ie we are in a playlist so name the embed container by playlistID) |
1023 | 1031 | var id = (this.pc!=null)?this.pc.pp.id:this.id; |
1024 | | - return '<div id="mv_ebct_'+id+'" style="width:'+this.width+'px;height:'+this.height+'px;">' + |
1025 | | - embed_code + |
| 1032 | + return '<div id="mv_ebct_'+id+'" style="width:'+this.width+'px;height:'+this.height+'px;">' + |
| 1033 | + embed_code + |
1026 | 1034 | '</div>'; |
1027 | | - }, |
| 1035 | + }, |
1028 | 1036 | getEmbedHTML : function(){ |
1029 | 1037 | //return this.wrapEmebedContainer( this.getEmbedObj() ); |
1030 | 1038 | return 'function getEmbedHTML should be overitten by embedLib '; |
1031 | 1039 | }, |
1032 | 1040 | //do seek function (should be overwritten by implementing embedLibs) |
1033 | | - // first check if seek can be done on locally downloaded content. |
1034 | | - doSeek : function( perc ){ |
1035 | | - if( this.supportsURLTimeEncoding() ){ |
| 1041 | + // first check if seek can be done on locally downloaded content. |
| 1042 | + doSeek : function( perc ){ |
| 1043 | + if( this.supportsURLTimeEncoding() ){ |
1036 | 1044 | //make sure this.seek_time_sec is up-to-date: |
1037 | 1045 | this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() ); |
1038 | 1046 | js_log('updated seek_time_sec: ' + seconds2npt ( this.seek_time_sec) ); |
1039 | | - this.stop(); |
| 1047 | + this.stop(); |
1040 | 1048 | this.didSeekJump=true; |
1041 | 1049 | //update the slider |
1042 | | - this.setSliderValue( perc ); |
1043 | | - } |
1044 | | - //do play in 100ms (give things time to clear) |
| 1050 | + this.setSliderValue( perc ); |
| 1051 | + } |
| 1052 | + //do play in 100ms (give things time to clear) |
1045 | 1053 | setTimeout('$j(\'#' + this.id + '\').get(0).play()',100); |
1046 | 1054 | }, |
1047 | 1055 | /* |
1048 | | - * seeks to the requested time and issues a callback when ready |
| 1056 | + * seeks to the requested time and issues a callback when ready |
1049 | 1057 | * (should be overwitten by client that supports frame serving) |
1050 | | - */ |
| 1058 | + */ |
1051 | 1059 | setCurrentTime:function( time, callback){ |
1052 | 1060 | js_log('error: base embed setCurrentTime can not frame serve (overide via plugin)'); |
1053 | 1061 | }, |
1054 | 1062 | addPresTimeOffset:function(){ |
1055 | | - //add in the offset: |
| 1063 | + //add in the offset: |
1056 | 1064 | if(this.seek_time_sec && this.seek_time_sec!=0){ |
1057 | 1065 | this.currentTime+=this.seek_time_sec; |
1058 | | - }else if(this.start_offset && this.start_offset!=0){ |
1059 | | - this.currentTime = parseFloat(this.currentTime) + parseFloat(this.start_offset); |
1060 | | - } |
| 1066 | + }else if(this.start_offset && this.start_offset!=0){ |
| 1067 | + this.currentTime = parseFloat(this.currentTime) + parseFloat(this.start_offset); |
| 1068 | + } |
1061 | 1069 | }, |
1062 | 1070 | doEmbedHTML:function() |
1063 | 1071 | { |
— | — | @@ -1066,90 +1074,179 @@ |
1067 | 1075 | this.closeDisplayedHTML(); |
1068 | 1076 | |
1069 | 1077 | // if(!this.selected_player){ |
1070 | | -// return this.getPluginMissingHTML(); |
| 1078 | +// return this.getPluginMissingHTML(); |
1071 | 1079 | //Set "loading" here |
1072 | 1080 | $j('#mv_embedded_player_'+_this.id).html(''+ |
1073 | | - '<div style="color:black;width:'+this.width+'px;height:'+this.height+'px;">' + |
1074 | | - gM('mwe-loading_plugin') + |
1075 | | - '</div>' |
| 1081 | + '<div style="color:black;width:'+this.width+'px;height:'+this.height+'px;">' + |
| 1082 | + gM('mwe-loading_plugin') + |
| 1083 | + '</div>' |
1076 | 1084 | ); |
1077 | 1085 | // schedule embedding |
1078 | 1086 | this.selected_player.load(function() |
1079 | 1087 | { |
1080 | | - js_log('performing embed for ' + _this.id); |
1081 | | - var embed_code = _this.getEmbedHTML(); |
| 1088 | + js_log('performing embed for ' + _this.id); |
| 1089 | + var embed_code = _this.getEmbedHTML(); |
1082 | 1090 | //js_log('shopuld embed:' + embed_code); |
1083 | | - $j('#mv_embedded_player_'+_this.id).html(embed_code); |
| 1091 | + $j('#mv_embedded_player_'+_this.id).html(embed_code); |
1084 | 1092 | }); |
1085 | 1093 | }, |
| 1094 | + mvVideoAudioSearch:function(){ |
| 1095 | + var _this = this; |
| 1096 | + js_log('switch video Relational' ); |
| 1097 | + var reqObj = { |
| 1098 | + 'action':'query', |
| 1099 | + 'titles': this.wikiTitleKey, |
| 1100 | + 'generator':'categories' |
| 1101 | + }; |
| 1102 | + var req_categories= new Array(); |
| 1103 | + do_api_req( { |
| 1104 | + 'data':reqObj, |
| 1105 | + 'url': commons_api_url |
| 1106 | + }, function(data){ |
| 1107 | + req_categories = Array(); |
| 1108 | + if(data.query && data.query.pages){ |
| 1109 | + for(var pageid in data.query.pages){ |
| 1110 | + if(data.query.pages[pageid].title) |
| 1111 | + req_categories.push(data.query.pages[pageid].title); |
| 1112 | + } |
| 1113 | + } |
| 1114 | + _this.getRelatedFromCat( req_categories ); |
| 1115 | + }); |
| 1116 | + }, |
| 1117 | + getRelatedFromCat:function(catAry){ |
| 1118 | + js_log('getRelatedFromCat'); |
| 1119 | + var _this = this; |
| 1120 | + for ( var i= 0 ; i <= catAry.length ;i++ ){ |
| 1121 | + if(!catAry[i]) |
| 1122 | + continue; |
| 1123 | + var reqObj = { |
| 1124 | + 'action' : 'query', |
| 1125 | + 'generator' : 'categorymembers' , |
| 1126 | + 'gcmtitle' : catAry[i], |
| 1127 | + 'prop' : 'imageinfo', |
| 1128 | + 'iiprop' : 'url', |
| 1129 | + 'iiurlwidth': '80' |
| 1130 | + }; |
| 1131 | + do_api_req({ |
| 1132 | + 'data':reqObj, |
| 1133 | + 'url': commons_api_url |
| 1134 | + }, function(data){ |
| 1135 | + //empty the videos: |
| 1136 | + $j('#dc_'+ _this.id + ' .related_vids ul').html(' '); |
| 1137 | + var leyenda=""; |
| 1138 | + var titule=""; |
| 1139 | + |
| 1140 | + for(var j in data.query.pages){ |
| 1141 | + //setup poster default: |
| 1142 | + var local_poster ="http://upload.wikimedia.org/wikipedia/commons/7/79/Wiki-commons.png"; |
| 1143 | + //make sure it exists: |
| 1144 | + var page = data.query.pages[j]; |
| 1145 | + if( j > 0 && page && page['imageinfo'] ){ |
| 1146 | + if( page['imageinfo'][0].thumburl ){ |
| 1147 | + local_poster = page['imageinfo'][0].thumburl; |
| 1148 | + } |
| 1149 | + var descriptionurl = page['imageinfo'][0].descriptionurl; |
| 1150 | + var title_str = page.title.replace( /File:|.ogv$|.oga$|.ogg$/gi, "" ); |
| 1151 | + //only link to other videos: |
| 1152 | + if ( descriptionurl.match( /\.ogg$|\.ogv$|\.oga$/gi ) != null) { |
| 1153 | + var liout = '<li>' + |
| 1154 | + '<a href="' + descriptionurl + '" >' + |
| 1155 | + '<img src="' + local_poster + '">' + |
| 1156 | + '</a>' + |
| 1157 | + '<div>' + |
| 1158 | + '<a title="' + title_str + '" target="_blank" ' + |
| 1159 | + 'href="'+ descriptionurl +'">' + title_str + '</a>' + |
| 1160 | + '</div>' + |
| 1161 | + '</li>'; |
| 1162 | + $j('#dc_'+ _this.id + ' .related_vids ul').append(liout) ; |
| 1163 | + } |
| 1164 | + } |
| 1165 | + }; |
| 1166 | + js_log( 'content: ' + $j('#dc_'+ _this.id + ' .related_vids ul').html() ); |
| 1167 | + }); //end do_api_req |
| 1168 | + }; |
| 1169 | + }, |
1086 | 1170 | onClipDone:function(){ |
1087 | | - js_log('base:onClipDone'); |
1088 | | - //stop the clip (load the thumbnail etc) |
1089 | | - this.stop(); |
1090 | | - this.seek_time_sec = 0; |
1091 | | - this.setSliderValue(0); |
1092 | | - var _this = this; |
1093 | | - |
1094 | | - //if the clip resolution is < 320 don't do fancy onClipDone stuff |
1095 | | - if(this.width < 300){ |
1096 | | - return ; |
1097 | | - } |
1098 | | - this.onClipDone_disp=true; |
1099 | | - this.thumbnail_disp=true; |
1100 | | - //make sure we are not in preview mode( no end clip actions in preview mode) |
1101 | | - if( this.preview_mode ) |
1102 | | - return ; |
1103 | | - |
1104 | | - $j('#img_thumb_'+this.id).css('zindex',1); |
1105 | | - $j('#big_play_link_'+this.id).hide(); |
1106 | | - //add the liks_info_div black back |
1107 | | - $j('#dc_'+this.id).append('<div id="liks_info_'+this.id+'" ' + |
1108 | | - 'style="width:' +parseInt(parseInt(this.width)/2)+'px;'+ |
1109 | | - 'height:'+ parseInt(parseInt(this.height)) +'px;'+ |
1110 | | - 'position:absolute;top:10px;overflow:auto'+ |
1111 | | - 'width: '+parseInt( ((parseInt(this.width)/2)-15) ) + 'px;'+ |
1112 | | - 'left:'+ parseInt( ((parseInt(this.width)/2)+15) ) +'px;">'+ |
1113 | | - '</div>' + |
1114 | | - '<div id="black_back_'+this.id+'" ' + |
1115 | | - 'style="z-index:-2;position:absolute;background:#000;' + |
1116 | | - 'top:0px;left:0px;width:'+parseInt(this.width)+'px;' + |
1117 | | - 'height:'+parseInt(this.height)+'px;">' + |
1118 | | - '</div>' |
1119 | | - ); |
1120 | | - |
1121 | | - //start animation (make thumb small in upper left add in div for "loading" |
1122 | | - $j('#img_thumb_'+this.id).animate({ |
1123 | | - width:parseInt(parseInt(_this.width)/2), |
1124 | | - height:parseInt(parseInt(_this.height)/2), |
1125 | | - top:20, |
1126 | | - left:10 |
1127 | | - }, |
1128 | | - 1000, |
1129 | | - function(){ |
1130 | | - //animation done.. add "loading" to div if empty |
1131 | | - if($j('#liks_info_'+_this.id).html()==''){ |
1132 | | - $j('#liks_info_'+_this.id).html(gM('mwe-loading_txt')); |
| 1171 | + js_log('base:onClipDone'); |
| 1172 | + //stop the clip (load the thumbnail etc) |
| 1173 | + this.stop(); |
| 1174 | + this.seek_time_sec = 0; |
| 1175 | + this.setSliderValue(0); |
| 1176 | + var _this = this; |
| 1177 | + |
| 1178 | + if(this.width < 300){ |
| 1179 | + return ; |
| 1180 | + } |
| 1181 | + this.onClipDone_disp=true; |
| 1182 | + this.thumbnail_disp=true; |
| 1183 | + //make sure we are not in preview mode( no end clip actions in preview mode) |
| 1184 | + if( this.preview_mode ) |
| 1185 | + return ; |
| 1186 | + |
| 1187 | + $j('#img_thumb_'+this.id).css('zindex',1); |
| 1188 | + $j('#big_play_link_'+this.id).hide(); |
| 1189 | + |
| 1190 | + //add black background |
| 1191 | + $j('#dc_'+this.id).append('<div id="black_back_'+this.id+'" ' + |
| 1192 | + 'style="z-index:-2;position:absolute;background:#000;' + |
| 1193 | + 'top:0px;left:0px;width:'+parseInt(this.width)+'px;' + |
| 1194 | + 'height:'+parseInt(this.height)+'px;">' + |
| 1195 | + '</div>'); |
| 1196 | + |
| 1197 | + if( this.wikiTitleKey){ |
| 1198 | + $j('#dc_'+this.id).append( |
| 1199 | + '<div class="related_vids" >' + |
| 1200 | + '<h1>' + gM('mwe_related_videos') + '</h1>'+ |
| 1201 | + '<ul>' + |
| 1202 | + '</ul>' + |
| 1203 | + '</div>'); |
| 1204 | + $j('#img_thumb_' + this.id).fadeOut("fast"); |
| 1205 | + $j('#dc_'+ _this.id + ' .related_vids ul').html( gM('mwe-loading_txt') ); |
| 1206 | + this.mvVideoAudioSearch(); |
| 1207 | + }else{ |
| 1208 | + //add the liks_info_div black back |
| 1209 | + $j('#dc_'+this.id).append('<div id="liks_info_'+this.id+'" ' + |
| 1210 | + 'style="width:' +parseInt(parseInt(this.width)/2)+'px;'+ |
| 1211 | + 'height:'+ parseInt(parseInt(this.height)) +'px;'+ |
| 1212 | + 'position:absolute;top:10px;overflow:auto'+ |
| 1213 | + 'width: '+parseInt( ((parseInt(this.width)/2)-15) ) + 'px;'+ |
| 1214 | + 'left:'+ parseInt( ((parseInt(this.width)/2)+15) ) +'px;">'+ |
| 1215 | + '</div>' |
| 1216 | + ); |
| 1217 | + //start animation (make thumb small in upper left add in div for "loading" |
| 1218 | + $j('#img_thumb_'+this.id).animate({ |
| 1219 | + width:parseInt(parseInt(_this.width)/2), |
| 1220 | + height:parseInt(parseInt(_this.height)/2), |
| 1221 | + top:20, |
| 1222 | + left:10 |
| 1223 | + }, |
| 1224 | + 1000, |
| 1225 | + function(){ |
| 1226 | + //animation done.. add "loading" to div if empty |
| 1227 | + if($j('#liks_info_'+_this.id).html()==''){ |
| 1228 | + $j('#liks_info_'+_this.id).html(gM('mwe-loading_txt')); |
| 1229 | + } |
| 1230 | + } |
| 1231 | + ) |
| 1232 | + //now load roe if run the showNextPrevLinks |
| 1233 | + if(this.roe && this.media_element.addedROEData==false){ |
| 1234 | + do_request(this.roe, function(data) |
| 1235 | + { |
| 1236 | + _this.media_element.addROE(data); |
| 1237 | + _this.getNextPrevLinks(); |
| 1238 | + }); |
| 1239 | + }else{ |
| 1240 | + this.getNextPrevLinks(); |
1133 | 1241 | } |
1134 | | - } |
1135 | | - ) |
1136 | | - //now load roe if run the showNextPrevLinks |
1137 | | - if(this.roe && this.media_element.addedROEData==false){ |
1138 | | - do_request(this.roe, function(data) |
1139 | | - { |
1140 | | - _this.media_element.addROE(data); |
1141 | | - _this.getNextPrevLinks(); |
1142 | | - }); |
1143 | | - }else{ |
1144 | | - this.getNextPrevLinks(); |
1145 | | - } |
1146 | | - }, |
1147 | | - //@@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them. |
| 1242 | + } |
| 1243 | + }, |
| 1244 | + //@@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them. |
1148 | 1245 | getNextPrevLinks:function(){ |
1149 | 1246 | js_log('f:getNextPrevLinks'); |
1150 | 1247 | var anno_track_url = null; |
1151 | | - var _this = this; |
| 1248 | + var _this = this; |
1152 | 1249 | //check for annoative track |
1153 | | - $j.each(this.media_element.sources, function(inx, n){ |
| 1250 | + $j.each(this.media_element.sources, function(inx, n){ |
1154 | 1251 | if(n.mime_type=='text/cmml'){ |
1155 | 1252 | if( n.id == 'Anno_en'){ |
1156 | 1253 | anno_track_url = n.src; |
— | — | @@ -1161,28 +1258,28 @@ |
1162 | 1259 | //zero out seconds (should improve cache hit rate and generally expands metadata search) |
1163 | 1260 | //@@todo this could be repalced with a regExp |
1164 | 1261 | var annoURL = parseUri(anno_track_url); |
1165 | | - var times = annoURL.queryKey['t'].split('/'); |
1166 | | - var stime_parts = times[0].split(':'); |
1167 | | - var etime_parts = times[1].split(':'); |
| 1262 | + var times = annoURL.queryKey['t'].split('/'); |
| 1263 | + var stime_parts = times[0].split(':'); |
| 1264 | + var etime_parts = times[1].split(':'); |
1168 | 1265 | //zero out the hour: |
1169 | 1266 | var new_start = stime_parts[0]+':'+'0:0'; |
1170 | 1267 | //zero out the end sec |
1171 | 1268 | var new_end = (etime_parts[0]== stime_parts[0])? (etime_parts[0]+1)+':0:0' :etime_parts[0]+':0:0'; |
1172 | | - |
| 1269 | + |
1173 | 1270 | var etime_parts = times[1].split(':'); |
1174 | | - |
| 1271 | + |
1175 | 1272 | var new_anno_track_url = annoURL.protocol +'://'+ annoURL.host + annoURL.path +'?'; |
1176 | 1273 | $j.each(annoURL.queryKey, function(i, val){ |
1177 | 1274 | new_anno_track_url +=(i=='t')?'t='+new_start+'/'+new_end +'&' : |
1178 | 1275 | i+'='+ val+'&'; |
1179 | 1276 | }); |
1180 | 1277 | var request_key = new_start+'/'+new_end; |
1181 | | - //check the anno_data cache: |
1182 | | - //@@todo search cache see if current is in range. |
| 1278 | + //check the anno_data cache: |
| 1279 | + //@@todo search cache see if current is in range. |
1183 | 1280 | if(this.anno_data_cache){ |
1184 | 1281 | js_log('anno data found in cache: '+request_key); |
1185 | 1282 | this.showNextPrevLinks(); |
1186 | | - }else{ |
| 1283 | + }else{ |
1187 | 1284 | do_request(new_anno_track_url, function(cmml_data){ |
1188 | 1285 | js_log('raw response: '+ cmml_data); |
1189 | 1286 | if(typeof cmml_data == 'string') |
— | — | @@ -1193,8 +1290,8 @@ |
1194 | 1291 | } |
1195 | 1292 | //init anno_data_cache |
1196 | 1293 | if(!_this.anno_data_cache) |
1197 | | - _this.anno_data_cache={}; |
1198 | | - //grab all metadata and put it into the anno_data_cache: |
| 1294 | + _this.anno_data_cache={}; |
| 1295 | + //grab all metadata and put it into the anno_data_cache: |
1199 | 1296 | $j.each(cmml_data.getElementsByTagName('clip'), function(inx, clip){ |
1200 | 1297 | _this.anno_data_cache[ $j(clip).attr("id") ]={ |
1201 | 1298 | 'start_time_sec':npt2seconds($j(clip).attr("start").replace('npt:','')), |
— | — | @@ -1203,32 +1300,32 @@ |
1204 | 1301 | }; |
1205 | 1302 | //grab all its meta |
1206 | 1303 | _this.anno_data_cache[ $j(clip).attr("id") ]['meta']={}; |
1207 | | - $j.each(clip.getElementsByTagName('meta'),function(imx, meta){ |
| 1304 | + $j.each(clip.getElementsByTagName('meta'),function(imx, meta){ |
1208 | 1305 | //js_log('adding meta: '+ $j(meta).attr("name")+ ' = '+ $j(meta).attr("content")); |
1209 | 1306 | _this.anno_data_cache[$j(clip).attr("id")]['meta'][$j(meta).attr("name")]=$j(meta).attr("content"); |
1210 | 1307 | }); |
1211 | 1308 | }); |
1212 | | - _this.showNextPrevLinks(); |
| 1309 | + _this.showNextPrevLinks(); |
1213 | 1310 | }); |
1214 | 1311 | } |
1215 | 1312 | }else{ |
1216 | 1313 | js_log('no annotative track found'); |
1217 | 1314 | $j('#liks_info_'+this.id).html('no metadata found for related links'); |
1218 | 1315 | } |
1219 | | - //query current request time +|- 60s to get prev next speech links. |
| 1316 | + //query current request time +|- 60s to get prev next speech links. |
1220 | 1317 | }, |
1221 | 1318 | showNextPrevLinks:function(){ |
1222 | 1319 | //js_log('f:showNextPrevLinks'); |
1223 | | - //int requested links: |
| 1320 | + //int requested links: |
1224 | 1321 | var link = { |
1225 | 1322 | 'prev':'', |
1226 | 1323 | 'current':'', |
1227 | 1324 | 'next':'' |
1228 | | - } |
| 1325 | + } |
1229 | 1326 | var curTime = this.getTimeReq().split('/'); |
1230 | | - |
| 1327 | + |
1231 | 1328 | var s_sec = npt2seconds(curTime[0]); |
1232 | | - var e_sec = npt2seconds(curTime[1]); |
| 1329 | + var e_sec = npt2seconds(curTime[1]); |
1233 | 1330 | js_log('showNextPrevLinks: req time: '+ s_sec + ' to ' + e_sec); |
1234 | 1331 | //now we have all the data in anno_data_cache |
1235 | 1332 | var current_done=false; |
— | — | @@ -1240,52 +1337,52 @@ |
1241 | 1338 | link.prev = clip_id; |
1242 | 1339 | js_log('showNextPrevLinks: ' + s_sec + ' < ' + clip.end_time_sec + ' set prev'); |
1243 | 1340 | } |
1244 | | - |
| 1341 | + |
1245 | 1342 | if(e_sec==clip.end_time_sec && s_sec== clip.start_time_sec) |
1246 | 1343 | current_done = true; |
1247 | 1344 | //current clip is not done: |
1248 | 1345 | if( e_sec < clip.end_time_sec && link.current=='' && !current_done){ |
1249 | 1346 | link.current = clip_id; |
1250 | | - js_log('showNextPrevLinks: ' + e_sec + ' < ' + clip.end_time_sec + ' set current'); |
| 1347 | + js_log('showNextPrevLinks: ' + e_sec + ' < ' + clip.end_time_sec + ' set current'); |
1251 | 1348 | } |
1252 | | - |
| 1349 | + |
1253 | 1350 | //set end clip (first clip where start time is > end_time of req |
1254 | 1351 | if( e_sec < clip.start_time_sec && link.next==''){ |
1255 | 1352 | link.next = clip_id; |
1256 | 1353 | js_log('showNextPrevLinks: '+ e_sec + ' < '+ clip.start_time_sec + ' && ' + link.next ); |
1257 | 1354 | } |
1258 | | - } |
1259 | | - var html=''; |
| 1355 | + } |
| 1356 | + var html=''; |
1260 | 1357 | if(link.prev=='' && link.current=='' && link.next==''){ |
1261 | 1358 | html='<p><a href="'+this.media_element.linkbackgetMsg+'">clip page</a>'; |
1262 | | - }else{ |
| 1359 | + }else{ |
1263 | 1360 | for(var link_type in link){ |
1264 | | - var link_id = link[link_type]; |
| 1361 | + var link_id = link[link_type]; |
1265 | 1362 | if(link_id!=''){ |
1266 | | - var clip = this.anno_data_cache[link_id]; |
| 1363 | + var clip = this.anno_data_cache[link_id]; |
1267 | 1364 | var title_msg=''; |
1268 | 1365 | for(var j in clip['meta']){ |
1269 | 1366 | title_msg+=j.replace(/_/g,' ') +': ' +clip['meta'][j].replace(/_/g,' ') +" <br>"; |
1270 | | - } |
| 1367 | + } |
1271 | 1368 | var time_req = clip.time_req; |
1272 | | - if(link_type=='current') //if current start from end of current clip play to end of current meta: |
| 1369 | + if(link_type=='current') //if current start from end of current clip play to end of current meta: |
1273 | 1370 | time_req = curTime[1]+ '/' + seconds2npt( clip.end_time_sec ); |
1274 | | - |
1275 | | - //do special linkbacks for metavid content: |
1276 | | - var regTimeCheck = new RegExp(/[0-9]+:[0-9]+:[0-9]+\/[0-9]+:[0-9]+:[0-9]+/); |
| 1371 | + |
| 1372 | + //do special linkbacks for metavid content: |
| 1373 | + var regTimeCheck = new RegExp(/[0-9]+:[0-9]+:[0-9]+\/[0-9]+:[0-9]+:[0-9]+/); |
1277 | 1374 | html+='<p><a '; |
1278 | 1375 | if( regTimeCheck.test( this.media_element.linkback ) ){ |
1279 | | - html+=' href="'+ this.media_element.linkback.replace(regTimeCheck,time_req) +'" '; |
| 1376 | + html+=' href="'+ this.media_element.linkback.replace(regTimeCheck,time_req) +'" '; |
1280 | 1377 | }else{ |
1281 | | - html+=' href="#" onClick="$j(\'#'+this.id+'\').get(0).playByTimeReq(\''+ |
1282 | | - time_req + '\'); return false; "'; |
| 1378 | + html+=' href="#" onClick="$j(\'#'+this.id+'\').get(0).playByTimeReq(\''+ |
| 1379 | + time_req + '\'); return false; "'; |
1283 | 1380 | } |
1284 | | - html+=' title="' + title_msg + '">' + |
1285 | | - gM('mwe-'+link_type+'_clip_msg') + |
| 1381 | + html+=' title="' + title_msg + '">' + |
| 1382 | + gM(link_type+'_clip_msg') + |
1286 | 1383 | '</a><br><span style="font-size:small">'+ title_msg +'<span></p>'; |
1287 | | - } |
| 1384 | + } |
1288 | 1385 | } |
1289 | | - } |
| 1386 | + } |
1290 | 1387 | //js_og("should set html:"+ html); |
1291 | 1388 | $j('#liks_info_'+this.id).html(html); |
1292 | 1389 | }, |
— | — | @@ -1293,15 +1390,15 @@ |
1294 | 1391 | js_log('f:playByTimeReq: '+time_req ); |
1295 | 1392 | this.stop(); |
1296 | 1393 | this.updateVideoTimeReq(time_req); |
1297 | | - this.play(); |
| 1394 | + this.play(); |
1298 | 1395 | }, |
1299 | 1396 | doThumbnailHTML:function() |
1300 | | - { |
| 1397 | + { |
1301 | 1398 | var _this = this; |
1302 | | - js_log('f:doThumbnailHTML'+ this.thumbnail_disp); |
1303 | | - this.closeDisplayedHTML(); |
| 1399 | + js_log('f:doThumbnailHTML'+ this.thumbnail_disp); |
| 1400 | + this.closeDisplayedHTML(); |
1304 | 1401 | $j( '#mv_embedded_player_' + this.id ).html( this.getThumbnailHTML() ); |
1305 | | - this.paused = true; |
| 1402 | + this.paused = true; |
1306 | 1403 | this.thumbnail_disp = true; |
1307 | 1404 | }, |
1308 | 1405 | refreshControlsHTML:function(){ |
— | — | @@ -1312,40 +1409,40 @@ |
1313 | 1410 | return; |
1314 | 1411 | }else{ |
1315 | 1412 | $j('#mv_embedded_controls_'+this.id).html( this.getControlsHTML() ); |
1316 | | - ctrlBuilder.addControlHooks(this); |
1317 | | - } |
1318 | | - }, |
| 1413 | + ctrlBuilder.addControlHooks(this); |
| 1414 | + } |
| 1415 | + }, |
1319 | 1416 | getControlsHTML:function() |
1320 | | - { |
| 1417 | + { |
1321 | 1418 | return ctrlBuilder.getControls( this ); |
1322 | | - }, |
1323 | | - getHTML : function (){ |
1324 | | - //@@todo check if we have sources avaliable |
1325 | | - js_log('embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type); |
1326 | | - var _this = this; |
1327 | | - var html_code = ''; |
1328 | | - html_code = '<div id="videoPlayer_'+this.id+'" style="width:'+this.width+'px;position:relative;" class="videoPlayer">'; |
| 1419 | + }, |
| 1420 | + getHTML : function (){ |
| 1421 | + //@@todo check if we have sources avaliable |
| 1422 | + js_log('embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type); |
| 1423 | + var _this = this; |
| 1424 | + var html_code = ''; |
| 1425 | + html_code = '<div id="videoPlayer_'+this.id+'" style="width:'+this.width+'px;position:relative;" class="videoPlayer">'; |
1329 | 1426 | html_code += '<div style="width:'+parseInt(this.width)+'px;height:'+parseInt(this.height)+'px;" id="mv_embedded_player_'+this.id+'">' + |
1330 | | - this.getThumbnailHTML() + |
1331 | | - '</div>'; |
1332 | | - //js_log("mvEmbed:controls "+ typeof this.controls); |
| 1427 | + this.getThumbnailHTML() + |
| 1428 | + '</div>'; |
| 1429 | + //js_log("mvEmbed:controls "+ typeof this.controls); |
1333 | 1430 | if( this.controls ) |
1334 | 1431 | { |
1335 | 1432 | js_log("f:getHTML:AddControls"); |
1336 | 1433 | html_code +='<div id="mv_embedded_controls_' + this.id + '" class="ui-widget ui-corner-bottom ui-state-default controls" >'; |
1337 | | - html_code += this.getControlsHTML(); |
1338 | | - html_code +='</div>'; |
1339 | | - //block out some space by encapulating the top level div |
| 1434 | + html_code += this.getControlsHTML(); |
| 1435 | + html_code +='</div>'; |
| 1436 | + //block out some space by encapulating the top level div |
1340 | 1437 | $j(this).wrap('<div style="width:'+parseInt(this.width)+'px;height:' |
1341 | | - +(parseInt(this.height)+ctrlBuilder.height)+'px"></div>'); |
| 1438 | + +(parseInt(this.height)+ctrlBuilder.height)+'px"></div>'); |
1342 | 1439 | } |
1343 | | - html_code += '</div>'; //videoPlayer div close |
| 1440 | + html_code += '</div>'; //videoPlayer div close |
1344 | 1441 | //js_log('should set: '+this.id); |
1345 | | - $j(this).html( html_code ); |
| 1442 | + $j(this).html( html_code ); |
1346 | 1443 | //add hooks once Controls are in DOM |
1347 | | - ctrlBuilder.addControlHooks(this); |
1348 | | - |
1349 | | - //js_log('set this to: ' + $j(this).html() ); |
| 1444 | + ctrlBuilder.addControlHooks(this); |
| 1445 | + |
| 1446 | + //js_log('set this to: ' + $j(this).html() ); |
1350 | 1447 | //alert('stop'); |
1351 | 1448 | //if auto play==true directly embed the plugin |
1352 | 1449 | if(this.autoplay) |
— | — | @@ -1375,7 +1472,7 @@ |
1376 | 1473 | this.updateVideoTime(time_parts[0], time_parts[1]); |
1377 | 1474 | }, |
1378 | 1475 | //update video time |
1379 | | - updateVideoTime:function(start_ntp, end_ntp){ |
| 1476 | + updateVideoTime:function(start_ntp, end_ntp){ |
1380 | 1477 | //update media |
1381 | 1478 | this.media_element.updateSourceTimes( start_ntp, end_ntp ); |
1382 | 1479 | //update mv_time |
— | — | @@ -1387,11 +1484,11 @@ |
1388 | 1485 | this.seek_time_sec=0; |
1389 | 1486 | else |
1390 | 1487 | this.seek_time_sec=npt2seconds(start_ntp); |
1391 | | - }, |
1392 | | - //@@todo overwite by embed library if we can render frames natavily |
| 1488 | + }, |
| 1489 | + //@@todo overwite by embed library if we can render frames natavily |
1393 | 1490 | renderTimelineThumbnail:function( options ){ |
1394 | 1491 | var my_thumb_src = this.media_element.getThumbnailURL(); |
1395 | | - //check if our thumbnail has a time attribute: |
| 1492 | + //check if our thumbnail has a time attribute: |
1396 | 1493 | if( my_thumb_src.indexOf('t=') !== -1){ |
1397 | 1494 | var time_ntp = seconds2npt ( options.time + parseInt(this.start_offset) ); |
1398 | 1495 | my_thumb_src = getURLParamReplace( my_thumb_src, { 't':time_ntp, 'size': options.size } ); |
— | — | @@ -1399,7 +1496,7 @@ |
1400 | 1497 | var thumb_class = (typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : ''; |
1401 | 1498 | return '<div class="ui-corner-all ' + thumb_class + '" src="' + my_thumb_src + '" '+ |
1402 | 1499 | 'style="height:' + options.height + 'px;' + |
1403 | | - 'width:' + options.width + 'px" >' + |
| 1500 | + 'width:' + options.width + 'px" >' + |
1404 | 1501 | '<img src="' + my_thumb_src +'" '+ |
1405 | 1502 | 'style="height:' + options.height + 'px;' + |
1406 | 1503 | 'width:' + options.width + 'px">' + |
— | — | @@ -1410,58 +1507,58 @@ |
1411 | 1508 | }, |
1412 | 1509 | updateThumbTime:function( float_sec ){ |
1413 | 1510 | //js_log('updateThumbTime:'+float_sec); |
1414 | | - var _this = this; |
1415 | | - if( typeof this.org_thum_src=='undefined' ){ |
| 1511 | + var _this = this; |
| 1512 | + if( typeof this.org_thum_src=='undefined' ){ |
1416 | 1513 | this.org_thum_src = this.media_element.getThumbnailURL(); |
1417 | | - } |
| 1514 | + } |
1418 | 1515 | if( this.org_thum_src.indexOf('t=') !== -1){ |
1419 | | - this.last_thumb_url = getURLParamReplace(this.org_thum_src, |
1420 | | - { 't' : seconds2npt( float_sec + parseInt(this.start_offset)) } ); |
1421 | | - if(!this.thumbnail_updating){ |
| 1516 | + this.last_thumb_url = getURLParamReplace(this.org_thum_src, |
| 1517 | + { 't' : seconds2npt( float_sec + parseInt(this.start_offset)) } ); |
| 1518 | + if(!this.thumbnail_updating){ |
1422 | 1519 | this.updateThumbnail(this.last_thumb_url ,false); |
1423 | 1520 | this.last_thumb_url =null; |
1424 | 1521 | } |
1425 | 1522 | } |
1426 | 1523 | }, |
1427 | 1524 | //for now provide a src url .. but need to figure out how to copy frames from video for plug-in based thumbs |
1428 | | - updateThumbPerc:function( perc ){ |
| 1525 | + updateThumbPerc:function( perc ){ |
1429 | 1526 | return this.updateThumbTime( (this.getDuration() * perc) ); |
1430 | 1527 | }, |
1431 | 1528 | //updates the thumbnail if the thumbnail is being displayed |
1432 | | - updateThumbnail : function(src, quick_switch){ |
1433 | | - //make sure we don't go to the same url if we are not already updating: |
| 1529 | + updateThumbnail : function(src, quick_switch){ |
| 1530 | + //make sure we don't go to the same url if we are not already updating: |
1434 | 1531 | if( !this.thumbnail_updating && $j('#img_thumb_'+this.id).attr('src')== src ) |
1435 | 1532 | return false; |
1436 | | - //if we are already updating don't issue a new update: |
| 1533 | + //if we are already updating don't issue a new update: |
1437 | 1534 | if( this.thumbnail_updating && $j('#new_img_thumb_'+this.id).attr('src')== src ) |
1438 | 1535 | return false; |
1439 | | - |
| 1536 | + |
1440 | 1537 | js_log('update thumb: ' + src); |
1441 | | - |
| 1538 | + |
1442 | 1539 | if(quick_switch){ |
1443 | 1540 | $j('#img_thumb_'+this.id).attr('src', src); |
1444 | 1541 | }else{ |
1445 | | - var _this = this; |
| 1542 | + var _this = this; |
1446 | 1543 | //if still animating remove new_img_thumb_ |
1447 | 1544 | if(this.thumbnail_updating==true) |
1448 | | - $j('#new_img_thumb_'+this.id).stop().remove(); |
1449 | | - |
| 1545 | + $j('#new_img_thumb_'+this.id).stop().remove(); |
| 1546 | + |
1450 | 1547 | if(this.thumbnail_disp){ |
1451 | 1548 | js_log('set to thumb:'+ src); |
1452 | 1549 | this.thumbnail_updating=true; |
1453 | 1550 | $j('#dc_'+this.id).append('<img src="'+src+'" ' + |
1454 | 1551 | 'style="display:none;position:absolute;zindex:2;top:0px;left:0px;" ' + |
1455 | 1552 | 'width="'+this.width+'" height="'+this.height+'" '+ |
1456 | | - 'id = "new_img_thumb_'+this.id+'" />'); |
1457 | | - //js_log('appended: new_img_thumb_'); |
1458 | | - $j('#new_img_thumb_'+this.id).fadeIn("slow", function(){ |
| 1553 | + 'id = "new_img_thumb_'+this.id+'" />'); |
| 1554 | + //js_log('appended: new_img_thumb_'); |
| 1555 | + $j('#new_img_thumb_'+this.id).fadeIn("slow", function(){ |
1459 | 1556 | //once faded in remove org and rename new: |
1460 | 1557 | $j('#img_thumb_'+_this.id).remove(); |
1461 | 1558 | $j('#new_img_thumb_'+_this.id).attr('id', 'img_thumb_'+_this.id); |
1462 | 1559 | $j('#img_thumb_'+_this.id).css('zindex','1'); |
1463 | | - _this.thumbnail_updating=false; |
| 1560 | + _this.thumbnail_updating=false; |
1464 | 1561 | //js_log("done fadding in "+ $j('#img_thumb_'+_this.id).attr("src")); |
1465 | | - |
| 1562 | + |
1466 | 1563 | //if we have a thumb queued update to that |
1467 | 1564 | if(_this.last_thumb_url){ |
1468 | 1565 | var src_url =_this.last_thumb_url; |
— | — | @@ -1478,7 +1575,7 @@ |
1479 | 1576 | download, and embed code. |
1480 | 1577 | */ |
1481 | 1578 | getThumbnailHTML : function () |
1482 | | - { |
| 1579 | + { |
1483 | 1580 | js_log('embedVideo:getThumbnailHTML::' + this.id); |
1484 | 1581 | var thumb_html = ''; |
1485 | 1582 | var class_atr=''; |
— | — | @@ -1493,10 +1590,10 @@ |
1494 | 1591 | ' overflow:hidden; top:0px; left:0px; width:'+this.playerPixelWidth()+'px; height:'+this.playerPixelHeight()+'px; z-index:0;">'+ |
1495 | 1592 | '<img width="'+this.playerPixelWidth()+'" height="'+this.playerPixelHeight()+'" style="position:relative;width:'+this.playerPixelWidth()+';height:'+this.playerPixelHeight()+'"' + |
1496 | 1593 | ' id="img_thumb_'+this.id+'" src="' + this.thumbnail + '">'; |
1497 | | - |
| 1594 | + |
1498 | 1595 | if(this.play_button == true && this.controls == true) |
1499 | 1596 | thumb_html+=this.getPlayButton(); |
1500 | | - |
| 1597 | + |
1501 | 1598 | thumb_html+='</div>'; |
1502 | 1599 | return thumb_html; |
1503 | 1600 | }, |
— | — | @@ -1550,16 +1647,16 @@ |
1551 | 1648 | this.displayHTML(gM('mwe-loading_txt')); |
1552 | 1649 | do_request(this.roe, function(data) |
1553 | 1650 | { |
1554 | | - _this.media_element.addROE(data); |
| 1651 | + _this.media_element.addROE(data); |
1555 | 1652 | _this.doLinkBack(); |
1556 | | - }); |
| 1653 | + }); |
1557 | 1654 | }else{ |
1558 | | - if(this.media_element.linkback){ |
| 1655 | + if(this.media_element.linkback){ |
1559 | 1656 | window.location = this.media_element.linkback; |
1560 | 1657 | }else{ |
1561 | 1658 | this.displayHTML(gM('mwe-could_not_find_linkback')); |
1562 | 1659 | } |
1563 | | - } |
| 1660 | + } |
1564 | 1661 | }, |
1565 | 1662 | //display the code to remotely embed this video: |
1566 | 1663 | showEmbedCode : function(embed_code){ |
— | — | @@ -1584,42 +1681,42 @@ |
1585 | 1682 | this.displayHTML(o); |
1586 | 1683 | }, |
1587 | 1684 | copyText:function(){ |
1588 | | - $j('#embedding_user_html_'+this.id).focus().select(); |
1589 | | - if(document.selection){ |
1590 | | - CopiedTxt = document.selection.createRange(); |
| 1685 | + $j('#embedding_user_html_'+this.id).focus().select(); |
| 1686 | + if(document.selection){ |
| 1687 | + CopiedTxt = document.selection.createRange(); |
1591 | 1688 | CopiedTxt.execCommand("Copy"); |
1592 | 1689 | } |
1593 | 1690 | }, |
1594 | | - showTextInterface:function(){ |
| 1691 | + showTextInterface:function(){ |
1595 | 1692 | var _this = this; |
1596 | | - //display the text container with loading text: |
| 1693 | + //display the text container with loading text: |
1597 | 1694 | //@@todo support position config |
1598 | | - var loc = $j(this).position(); |
| 1695 | + var loc = $j(this).position(); |
1599 | 1696 | if($j('#metaBox_'+this.id).length==0){ |
1600 | 1697 | $j(this).after('<div class="ui-widget ui-widget-content ui-corner-all" style="position:absolute;z-index:10;'+ |
1601 | 1698 | 'top:' + (loc.top) + 'px;' + |
1602 | 1699 | 'left:' + (parseInt( loc.left ) + parseInt(this.width) + 10 )+'px;' + |
1603 | | - 'height:'+ parseInt( this.height )+'px;width:400px;' + |
| 1700 | + 'height:'+ parseInt( this.height )+'px;width:400px;' + |
1604 | 1701 | 'display:none;" ' + |
1605 | 1702 | 'id="metaBox_' + this.id + '">'+ |
1606 | 1703 | gM('mwe-loading_txt') + |
1607 | | - '</div>'); |
| 1704 | + '</div>'); |
1608 | 1705 | } |
1609 | 1706 | //fade in the text display |
1610 | | - $j('#metaBox_'+this.id).fadeIn("fast"); |
| 1707 | + $j('#metaBox_'+this.id).fadeIn("fast"); |
1611 | 1708 | //check if textObj present: |
1612 | 1709 | if(typeof this.textInterface == 'undefined' ){ |
1613 | 1710 | //load the default text interface: |
1614 | 1711 | mvJsLoader.doLoad([ |
1615 | | - 'mvTextInterface', |
| 1712 | + 'mvTextInterface', |
1616 | 1713 | '$j.fn.hoverIntent' |
1617 | | - ], function(){ |
1618 | | - _this.textInterface = new mvTextInterface( _this ); |
| 1714 | + ], function(){ |
| 1715 | + _this.textInterface = new mvTextInterface( _this ); |
1619 | 1716 | //show interface |
1620 | 1717 | _this.textInterface.show(); |
1621 | 1718 | js_log("NEW TEXT INTERFACE"); |
1622 | 1719 | for(var i in _this.textInterface.availableTracks){ |
1623 | | - js_log("tracks in new interface: "+_this.id+ ' tid:' + i); |
| 1720 | + js_log("tracks in new interface: "+_this.id+ ' tid:' + i); |
1624 | 1721 | } |
1625 | 1722 | } |
1626 | 1723 | ); |
— | — | @@ -1636,26 +1733,26 @@ |
1637 | 1734 | }, |
1638 | 1735 | /** Generic function to display custom HTML inside the mv_embed element. |
1639 | 1736 | The code should call the closeDisplayedHTML function to close the |
1640 | | - display of the custom HTML and restore the regular mv_embed display. |
| 1737 | + display of the custom HTML and restore the regular mv_embed display. |
1641 | 1738 | @param {String} HTML code for the selection list. |
1642 | 1739 | */ |
1643 | 1740 | displayHTML:function(html_code) |
1644 | 1741 | { |
1645 | 1742 | var sel_id = (this.pc!=null)?this.pc.pp.id:this.id; |
1646 | | - |
| 1743 | + |
1647 | 1744 | if(!this.supports['overlays']) |
1648 | 1745 | this.stop(); |
1649 | | - |
| 1746 | + |
1650 | 1747 | //put select list on-top |
1651 | 1748 | //make sure the parent is relatively positioned: |
1652 | 1749 | $j('#'+sel_id).css('position', 'relative'); |
1653 | 1750 | //set height width (check for playlist container) |
1654 | 1751 | var width = (this.pc)?this.pc.pp.width:this.playerPixelWidth(); |
1655 | 1752 | var height = (this.pc)?this.pc.pp.height:this.playerPixelHeight(); |
1656 | | - |
| 1753 | + |
1657 | 1754 | if(this.pc) |
1658 | 1755 | height+=(this.pc.pp.pl_layout.title_bar_height + this.pc.pp.pl_layout.control_height); |
1659 | | - |
| 1756 | + |
1660 | 1757 | var fade_in = true; |
1661 | 1758 | if($j('#blackbg_'+sel_id).length!=0) |
1662 | 1759 | { |
— | — | @@ -1667,11 +1764,11 @@ |
1668 | 1765 | 'style="height:'+parseInt(height)+'px;width:'+parseInt(width)+'px;">'+ |
1669 | 1766 | '<div class="videoOptionsComplete">'+ |
1670 | 1767 | //@@TODO: this style should go to .css |
1671 | | - '<span style="float:right;margin-right:10px">' + |
| 1768 | + '<span style="float:right;margin-right:10px">' + |
1672 | 1769 | '<a href="#" style="color:white;" onClick="$j(\'#'+sel_id+'\').get(0).closeDisplayedHTML();return false;">close</a>' + |
1673 | 1770 | '</span>'+ |
1674 | 1771 | '<div id="mv_disp_inner_'+sel_id+'" style="padding-top:10px;">'+ |
1675 | | - html_code |
| 1772 | + html_code |
1676 | 1773 | +'</div>'+ |
1677 | 1774 | '</div></div>'; |
1678 | 1775 | $j('#'+sel_id).prepend(div_code); |
— | — | @@ -1691,43 +1788,43 @@ |
1692 | 1789 | }); |
1693 | 1790 | return false; //onclick action return false |
1694 | 1791 | }, |
1695 | | - selectPlaybackMethod:function(){ |
| 1792 | + selectPlaybackMethod:function(){ |
1696 | 1793 | //get id (in case where we have a parent container) |
1697 | 1794 | var this_id = (this.pc!=null)?this.pc.pp.id:this.id; |
1698 | | - |
1699 | | - var _this=this; |
| 1795 | + |
| 1796 | + var _this=this; |
1700 | 1797 | var out= '<span style="color:#FFF;background-color:black;"><blockquote style="background-color:black;">'; |
1701 | 1798 | var _this=this; |
1702 | 1799 | //js_log('selected src'+ _this.media_element.selected_source.url); |
1703 | | - $j.each( this.media_element.getPlayableSources(), function(source_id, source){ |
1704 | | - var default_player = embedTypes.players.defaultPlayer( source.getMIMEType() ); |
1705 | | - |
| 1800 | + $j.each( this.media_element.getPlayableSources(), function(source_id, source){ |
| 1801 | + var default_player = embedTypes.players.defaultPlayer( source.getMIMEType() ); |
| 1802 | + |
1706 | 1803 | var is_selected = (source == _this.media_element.selected_source); |
1707 | 1804 | var image_src = mv_skin_img_path ; |
1708 | | - |
1709 | | - //set the Playable source type: |
| 1805 | + |
| 1806 | + //set the Playable source type: |
1710 | 1807 | if( source.mime_type == 'video/x-flv' ){ |
1711 | 1808 | image_src += 'flash_icon_'; |
1712 | 1809 | }else if( source.mime_type == 'video/h264'){ |
1713 | | - //for now all mp4 content is pulled from archive.org (so use archive.org icon) |
| 1810 | + //for now all mp4 content is pulled from archive.org (so use archive.org icon) |
1714 | 1811 | image_src += 'archive_org_'; |
1715 | 1812 | }else{ |
1716 | 1813 | image_src += 'fish_xiph_org_'; |
1717 | 1814 | } |
1718 | 1815 | image_src += is_selected ? 'color':'bw'; |
1719 | | - image_src += '.png'; |
1720 | | - |
| 1816 | + image_src += '.png'; |
| 1817 | + |
1721 | 1818 | if (default_player) |
1722 | 1819 | { |
1723 | 1820 | out += '<img src="'+image_src+'"/>'; |
1724 | 1821 | if( ! is_selected ) |
1725 | 1822 | out+='<a href="#" class="sel_source" id="sc_' + source_id + '_' + default_player.id +'">'; |
1726 | 1823 | out += source.getTitle()+ (is_selected?'</a>':'') + ' '; |
1727 | | - |
1728 | | - //output the player select code: |
1729 | | - var supporting_players = embedTypes.players.getMIMETypePlayers( source.getMIMEType() ); |
| 1824 | + |
| 1825 | + //output the player select code: |
| 1826 | + var supporting_players = embedTypes.players.getMIMETypePlayers( source.getMIMEType() ); |
1730 | 1827 | out+='<div id="player_select_list_' + source_id + '" class="player_select_list"><ul>'; |
1731 | | - for(var i=0; i < supporting_players.length ; i++){ |
| 1828 | + for(var i=0; i < supporting_players.length ; i++){ |
1732 | 1829 | if( _this.selected_player.id == supporting_players[i].id && is_selected ){ |
1733 | 1830 | out+='<li style="border-style:dashed;margin-left:20px;">'+ |
1734 | 1831 | '<img border="0" width="16" height="16" src="' + mv_skin_img_path + 'plugin.png">' + |
— | — | @@ -1743,36 +1840,36 @@ |
1744 | 1841 | '</li>'; |
1745 | 1842 | } |
1746 | 1843 | } |
1747 | | - out+='</ul></div>'; |
| 1844 | + out+='</ul></div>'; |
1748 | 1845 | }else |
1749 | 1846 | out+= source.getTitle() + ' - no player available'; |
1750 | 1847 | }); |
1751 | 1848 | out+='</blockquote></span>'; |
1752 | 1849 | this.displayHTML(out); |
1753 | | - |
| 1850 | + |
1754 | 1851 | //set up the click bindings: |
1755 | 1852 | $j('.sel_source').each(function(){ |
1756 | 1853 | $j(this).click(function(){ |
1757 | 1854 | var iparts = $j(this).attr( 'id' ).replace(/sc_/,'').split('_'); |
1758 | 1855 | var source_id = iparts[0]; |
1759 | 1856 | var default_player_id = iparts[1]; |
1760 | | - js_log('source id: ' + source_id + ' player id: ' + default_player_id); |
1761 | | - |
1762 | | - $j('#' + this_id ).get(0).closeDisplayedHTML(); |
| 1857 | + js_log('source id: ' + source_id + ' player id: ' + default_player_id); |
| 1858 | + |
| 1859 | + $j('#' + this_id ).get(0).closeDisplayedHTML(); |
1763 | 1860 | $j('#' + _this.id ).get(0).media_element.selectSource( source_id ); |
1764 | | - |
| 1861 | + |
1765 | 1862 | embedTypes.players.userSelectPlayer( default_player_id, |
1766 | 1863 | _this.media_element.sources[ source_id ].getMIMEType() ); |
1767 | | - |
| 1864 | + |
1768 | 1865 | //be sure to issue a stop |
1769 | 1866 | $j('#' + this_id ).get(0).stop(); |
1770 | | - |
| 1867 | + |
1771 | 1868 | //don't follow the empty # link: |
1772 | 1869 | return false; |
1773 | 1870 | }); |
1774 | 1871 | }); |
1775 | | - }, |
1776 | | - showVideoDownload:function(){ |
| 1872 | + }, |
| 1873 | + showVideoDownload:function(){ |
1777 | 1874 | //load the roe if available (to populate out download options: |
1778 | 1875 | //js_log('f:showVideoDownload '+ this.roe + ' ' + this.media_element.addedROEData); |
1779 | 1876 | if(this.roe && this.media_element.addedROEData == false){ |
— | — | @@ -1780,23 +1877,23 @@ |
1781 | 1878 | this.displayHTML(gM('mwe-loading_txt')); |
1782 | 1879 | do_request(this.roe, function(data) |
1783 | 1880 | { |
1784 | | - _this.media_element.addROE(data); |
| 1881 | + _this.media_element.addROE(data); |
1785 | 1882 | $j('#mv_disp_inner_'+_this.id).html( _this.getShowVideoDownload() ); |
1786 | | - }); |
| 1883 | + }); |
1787 | 1884 | }else{ |
1788 | 1885 | this.displayHTML( this.getShowVideoDownload() ); |
1789 | | - } |
| 1886 | + } |
1790 | 1887 | }, |
1791 | | - getShowVideoDownload:function(){ |
| 1888 | + getShowVideoDownload:function(){ |
1792 | 1889 | var out='<div style="color:white">' + |
1793 | 1890 | '<b style="color:white;">'+gM('mwe-download_segment')+'</b><br>'; |
1794 | 1891 | out+='<blockquote style="background:#000">'+ |
1795 | 1892 | gM('mwe-download_right_click') + '</blockquote><br>'; |
1796 | 1893 | var dl_list=''; |
1797 | | - var dl_txt_list=''; |
| 1894 | + var dl_txt_list=''; |
1798 | 1895 | $j.each(this.media_element.getSources(), function(index, source){ |
1799 | 1896 | var dl_line = '<li>' + '<a style="color:white" href="' + source.getURI() +'"> ' |
1800 | | - + source.getTitle()+'</a> '+ '</li>'+"\n"; |
| 1897 | + + source.getTitle()+'</a> '+ '</li>'+"\n"; |
1801 | 1898 | if( source.getURI().indexOf('?t=')!==-1){ |
1802 | 1899 | out+=dl_line; |
1803 | 1900 | }else if( this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt" ){ |
— | — | @@ -1804,8 +1901,8 @@ |
1805 | 1902 | }else{ |
1806 | 1903 | dl_list+=dl_line; |
1807 | 1904 | } |
1808 | | - }); |
1809 | | - |
| 1905 | + }); |
| 1906 | + |
1810 | 1907 | if(dl_list!='') |
1811 | 1908 | out+=gM('mwe-download_full') + '<blockquote style="background:#000">' + dl_list + '</blockquote>'; |
1812 | 1909 | if(dl_txt_list!='') |
— | — | @@ -1819,11 +1916,11 @@ |
1820 | 1917 | */ |
1821 | 1918 | play:function(){ |
1822 | 1919 | var this_id = (this.pc!=null)?this.pc.pp.id:this.id; |
1823 | | - |
1824 | | - //js_log( "mv_embed play:" + this.id); |
| 1920 | + |
| 1921 | + //js_log( "mv_embed play:" + this.id); |
1825 | 1922 | //js_log('thum disp:'+this.thumbnail_disp); |
1826 | 1923 | //check if thumbnail is being displayed and embed html |
1827 | | - if( this.thumbnail_disp ){ |
| 1924 | + if( this.thumbnail_disp ){ |
1828 | 1925 | if( !this.selected_player ){ |
1829 | 1926 | js_log('no selected_player'); |
1830 | 1927 | //this.innerHTML = this.getPluginMissingHTML(); |
— | — | @@ -1831,21 +1928,21 @@ |
1832 | 1929 | $j('#'+this.id).html( this.getPluginMissingHTML() ); |
1833 | 1930 | }else{ |
1834 | 1931 | this.doEmbedHTML(); |
1835 | | - this.onClipDone_disp=false; |
1836 | | - this.paused=false; |
1837 | | - this.thumbnail_disp=false; |
| 1932 | + this.onClipDone_disp=false; |
| 1933 | + this.paused=false; |
| 1934 | + this.thumbnail_disp=false; |
1838 | 1935 | } |
1839 | 1936 | }else{ |
1840 | | - //the plugin is already being displayed |
| 1937 | + //the plugin is already being displayed |
1841 | 1938 | this.paused=false; //make sure we are not "paused" |
1842 | 1939 | this.seeking=false; |
1843 | | - } |
1844 | | - |
1845 | | - $j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-play').addClass('ui-icon-pause'); |
1846 | | - $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ |
| 1940 | + } |
| 1941 | + |
| 1942 | + $j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-play').addClass('ui-icon-pause'); |
| 1943 | + $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ |
1847 | 1944 | $j('#' + this_id ).get(0).pause(); |
1848 | 1945 | }).attr('title', gM('mwe-pause_clip')); |
1849 | | - |
| 1946 | + |
1850 | 1947 | }, |
1851 | 1948 | load:function(){ |
1852 | 1949 | //should be done by child (no base way to load assets) |
— | — | @@ -1853,41 +1950,41 @@ |
1854 | 1951 | }, |
1855 | 1952 | getSrc:function(){ |
1856 | 1953 | return this.media_element.selected_source.getURI( this.seek_time_sec ); |
1857 | | - }, |
| 1954 | + }, |
1858 | 1955 | /* |
1859 | 1956 | * base embed pause |
1860 | 1957 | * there is no general way to pause the video |
1861 | 1958 | * must be overwritten by embed object to support this functionality. |
1862 | 1959 | */ |
1863 | 1960 | pause: function(){ |
1864 | | - var this_id = (this.pc!=null)?this.pc.pp.id:this.id; |
1865 | | - //js_log('mv_embed:do pause'); |
1866 | | - //(playing) do pause |
1867 | | - this.paused = true; |
1868 | | - //update the ctrl "paused state" |
| 1961 | + var this_id = (this.pc!=null)?this.pc.pp.id:this.id; |
| 1962 | + //js_log('mv_embed:do pause'); |
| 1963 | + //(playing) do pause |
| 1964 | + this.paused = true; |
| 1965 | + //update the ctrl "paused state" |
1869 | 1966 | $j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-pause').addClass('ui-icon-play'); |
1870 | | - $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ |
| 1967 | + $j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){ |
1871 | 1968 | $j('#'+this_id).get(0).play(); |
1872 | 1969 | }).attr('title', gM('mwe-play_clip')); |
1873 | | - }, |
| 1970 | + }, |
1874 | 1971 | /* |
1875 | 1972 | * base embed stop (can be overwritten by the plugin) |
1876 | 1973 | */ |
1877 | 1974 | stop: function(){ |
1878 | 1975 | var _this = this; |
1879 | 1976 | js_log('mvEmbed:stop:'+this.id); |
1880 | | - |
| 1977 | + |
1881 | 1978 | //no longer seeking: |
1882 | 1979 | this.didSeekJump=false; |
1883 | | - |
1884 | | - //first issue pause to update interface (only call the parent) |
| 1980 | + |
| 1981 | + //first issue pause to update interface (only call the parent) |
1885 | 1982 | if(this['parent_pause']){ |
1886 | 1983 | this.parent_pause(); |
1887 | 1984 | }else{ |
1888 | 1985 | this.pause(); |
1889 | | - } |
1890 | | - |
1891 | | - //reset the currentTime: |
| 1986 | + } |
| 1987 | + |
| 1988 | + //reset the currentTime: |
1892 | 1989 | this.currentTime=0; |
1893 | 1990 | //check if thumbnail is being displayed in which case do nothing |
1894 | 1991 | if( this.thumbnail_disp ){ |
— | — | @@ -1900,12 +1997,12 @@ |
1901 | 1998 | this.setSliderValue(0); |
1902 | 1999 | this.setStatus( this.getTimeReq() ); |
1903 | 2000 | } |
1904 | | - |
1905 | | - //make sure the big playbutton is has click action: |
| 2001 | + |
| 2002 | + //make sure the big playbutton is has click action: |
1906 | 2003 | $j('#big_play_link_' + _this.id).unbind('click').click(function(){ |
1907 | 2004 | $j('#' +_this.id).get(0).play(); |
1908 | 2005 | }); |
1909 | | - |
| 2006 | + |
1910 | 2007 | if(this.update_interval) |
1911 | 2008 | { |
1912 | 2009 | clearInterval(this.update_interval); |
— | — | @@ -1913,19 +2010,19 @@ |
1914 | 2011 | } |
1915 | 2012 | }, |
1916 | 2013 | toggleMute:function(){ |
1917 | | - var this_id = (this.pc!=null)?this.pc.pp.id:this.id; |
| 2014 | + var this_id = (this.pc!=null)?this.pc.pp.id:this.id; |
1918 | 2015 | if(this.muted){ |
1919 | 2016 | this.muted=false; |
1920 | 2017 | $j('#volume_control_'+this_id + ' span').removeClass('ui-icon-volume-off').addClass('ui-icon-volume-on'); |
1921 | | - $j('#volume_bar_'+this_id).slider('value', 100); |
| 2018 | + $j('#volume_bar_'+this_id).slider('value', 100); |
1922 | 2019 | this.updateVolumen(1); |
1923 | 2020 | }else{ |
1924 | 2021 | this.muted=true; |
1925 | 2022 | $j('#volume_control_'+this_id + ' span').removeClass('ui-icon-volume-on').addClass('ui-icon-volume-off'); |
1926 | 2023 | $j('#volume_bar_'+this_id).slider('value', 0); |
1927 | | - this.updateVolumen(0); |
| 2024 | + this.updateVolumen(0); |
1928 | 2025 | } |
1929 | | - js_log('f:toggleMute::' + this.muted); |
| 2026 | + js_log('f:toggleMute::' + this.muted); |
1930 | 2027 | }, |
1931 | 2028 | updateVolumen:function(perc){ |
1932 | 2029 | js_log('update volume not supported with current playback type'); |
— | — | @@ -1959,19 +2056,19 @@ |
1960 | 2057 | postEmbedJS:function(){ |
1961 | 2058 | return ''; |
1962 | 2059 | }, |
1963 | | - //do common monitor code like update the playhead and play status |
| 2060 | + //do common monitor code like update the playhead and play status |
1964 | 2061 | //plugin objects are responsible for updating currentTime |
1965 | 2062 | monitor:function(){ |
1966 | 2063 | if( this.currentTime && this.currentTime > 0 && this.duration){ |
1967 | 2064 | if( !this.userSlide ){ |
1968 | | - if( this.start_offset ){ |
1969 | | - //if start offset include that calculation |
1970 | | - this.setSliderValue( ( this.currentTime - this.start_offset ) / this.duration ); |
1971 | | - this.setStatus( seconds2npt(this.currentTime) + '/'+ seconds2npt(parseFloat(this.start_offset)+parseFloat(this.duration) )); |
| 2065 | + if( this.start_offset ){ |
| 2066 | + //if start offset include that calculation |
| 2067 | + this.setSliderValue( ( this.currentTime - this.start_offset ) / this.duration ); |
| 2068 | + this.setStatus( seconds2npt(this.currentTime) + '/'+ seconds2npt(parseFloat(this.start_offset)+parseFloat(this.duration) )); |
1972 | 2069 | }else{ |
1973 | 2070 | this.setSliderValue( this.currentTime / this.duration ); |
1974 | 2071 | this.setStatus( seconds2npt(this.currentTime) + '/' + seconds2npt(this.duration )); |
1975 | | - } |
| 2072 | + } |
1976 | 2073 | } |
1977 | 2074 | }else{ |
1978 | 2075 | //js_log(' ct:' + this.currentTime + ' dur: ' + this.duration); |
— | — | @@ -1980,25 +2077,30 @@ |
1981 | 2078 | }else if( this.isPaused() ){ |
1982 | 2079 | this.setStatus( "paused" ); |
1983 | 2080 | }else if( this.isPlaying() ){ |
1984 | | - if( this.currentTime && ! this.duration ) |
| 2081 | + if( this.currentTime && ! this.duration ) |
1985 | 2082 | this.setStatus( seconds2npt( this.currentTime ) + ' /' ); |
1986 | | - else |
| 2083 | + else |
1987 | 2084 | this.setStatus(" - - - "); |
1988 | 2085 | }else{ |
1989 | 2086 | this.setStatus( this.getTimeReq() ); |
1990 | | - } |
| 2087 | + } |
1991 | 2088 | } |
1992 | | - //update buffer information |
| 2089 | + //update buffer information |
1993 | 2090 | this.updateBufferStatus(); |
1994 | | - |
| 2091 | + |
| 2092 | + //check if we passed duration |
| 2093 | + if( this.duration && (this.currentTime > this.duration) ){ |
| 2094 | + this.onClipDone(); |
| 2095 | + } |
| 2096 | + |
1995 | 2097 | //update monitorTimerId to call child monitor |
1996 | 2098 | if( ! this.monitorTimerId ){ |
1997 | | - //make sure an instance of this.id exists: |
| 2099 | + //make sure an instance of this.id exists: |
1998 | 2100 | if( document.getElementById(this.id) ){ |
1999 | 2101 | this.monitorTimerId = setInterval('$j(\'#'+this.id+'\').get(0).monitor()', 250); |
2000 | 2102 | } |
2001 | 2103 | } |
2002 | | - }, |
| 2104 | + }, |
2003 | 2105 | stopMonitor:function(){ |
2004 | 2106 | if( this.monitorTimerId != 0 ) |
2005 | 2107 | { |
— | — | @@ -2007,18 +2109,18 @@ |
2008 | 2110 | } |
2009 | 2111 | }, |
2010 | 2112 | updateBufferStatus: function(){ |
2011 | | - |
2012 | | - //build the buffer targeet based for playlist vs clip |
2013 | | - var buffer_select = (this.pc) ? |
2014 | | - '#cl_status_' + this.id + ' .mv_buffer': |
| 2113 | + |
| 2114 | + //build the buffer targeet based for playlist vs clip |
| 2115 | + var buffer_select = (this.pc) ? |
| 2116 | + '#cl_status_' + this.id + ' .mv_buffer': |
2015 | 2117 | '#mv_play_head_' + this.id + ' .mv_buffer'; |
2016 | | - |
| 2118 | + |
2017 | 2119 | //update the buffer progress bar (if available ) |
2018 | 2120 | if( this.bufferedPercent != 0 ){ |
2019 | | - //js_log('bufferedPercent: ' + this.bufferedPercent); |
| 2121 | + //js_log('bufferedPercent: ' + this.bufferedPercent); |
2020 | 2122 | if(this.bufferedPercent > 1) |
2021 | | - this.bufferedPercent=1; |
2022 | | - |
| 2123 | + this.bufferedPercent=1; |
| 2124 | + |
2023 | 2125 | $j(buffer_select).css("width", (this.bufferedPercent*100) +'%' ); |
2024 | 2126 | }else{ |
2025 | 2127 | $j(buffer_select).css("width", '0px' ); |
— | — | @@ -2028,7 +2130,7 @@ |
2029 | 2131 | if(!this.start_offset) |
2030 | 2132 | this.start_offset =0; |
2031 | 2133 | var rt = this.currentTime - this.start_offset; |
2032 | | - if( rt < 0 ) //should not happen but does. |
| 2134 | + if( rt < 0 ) //should not happen but does. |
2033 | 2135 | return 0; |
2034 | 2136 | return rt; |
2035 | 2137 | }, |
— | — | @@ -2044,7 +2146,7 @@ |
2045 | 2147 | } |
2046 | 2148 | return null; |
2047 | 2149 | }, |
2048 | | - //HELPER Functions for selected source |
| 2150 | + //HELPER Functions for selected source |
2049 | 2151 | /* |
2050 | 2152 | * returns the selected source url for players to play |
2051 | 2153 | */ |
— | — | @@ -2055,12 +2157,12 @@ |
2056 | 2158 | //do head request if on the same domain |
2057 | 2159 | return this.media_element.selected_source.URLTimeEncoding; |
2058 | 2160 | }, |
2059 | | - setSliderValue: function(perc, hide_progress){ |
2060 | | - if(this.controls){ |
| 2161 | + setSliderValue: function(perc, hide_progress){ |
| 2162 | + if(this.controls){ |
2061 | 2163 | var this_id = (this.pc)?this.pc.pp.id:this.id; |
2062 | | - var val = parseInt( perc*1000 ); |
| 2164 | + var val = parseInt( perc*1000 ); |
2063 | 2165 | $j('#mv_play_head_'+this_id).slider('value', val); |
2064 | | - |
| 2166 | + |
2065 | 2167 | //js_log("embed video set: " + '#mv_play_head_'+this_id + ' to ' + val); |
2066 | 2168 | } |
2067 | 2169 | //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 @@ |
2071 | 2173 | js_log('highlightPlaySection'); |
2072 | 2174 | var this_id = (this.pc)?this.pc.pp.id:this.id; |
2073 | 2175 | var dur = this.getDuration(); |
2074 | | - var hide_progress = true; |
2075 | | - //set the left percet and update the slider: |
| 2176 | + var hide_progress = true; |
| 2177 | + //set the left percet and update the slider: |
2076 | 2178 | rel_start_sec = npt2seconds( options['start']); |
2077 | | - //remove the start_offset if relevent: |
| 2179 | + //remove the start_offset if relevent: |
2078 | 2180 | if(this.start_offset) |
2079 | 2181 | rel_start_sec = rel_start_sec - this.start_offset |
2080 | | - |
| 2182 | + |
2081 | 2183 | var slider_perc=0; |
2082 | 2184 | if( rel_start_sec <= 0 ){ |
2083 | | - left_perc =0; |
| 2185 | + left_perc =0; |
2084 | 2186 | options['start'] = seconds2npt( this.start_offset ); |
2085 | | - rel_start_sec=0; |
| 2187 | + rel_start_sec=0; |
2086 | 2188 | this.setSliderValue( 0 , hide_progress); |
2087 | 2189 | }else{ |
2088 | | - left_perc = parseInt( (rel_start_sec / dur)*100 ) ; |
| 2190 | + left_perc = parseInt( (rel_start_sec / dur)*100 ) ; |
2089 | 2191 | slider_perc = (left_perc / 100); |
2090 | | - } |
2091 | | - js_log("slider perc:" + slider_perc); |
| 2192 | + } |
| 2193 | + js_log("slider perc:" + slider_perc); |
2092 | 2194 | if( ! this.isPlaying() ){ |
2093 | | - this.setSliderValue( slider_perc , hide_progress); |
| 2195 | + this.setSliderValue( slider_perc , hide_progress); |
2094 | 2196 | } |
2095 | | - |
2096 | | - width_perc = parseInt( (( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur)*100 ) ; |
| 2197 | + |
| 2198 | + width_perc = parseInt( (( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur)*100 ) ; |
2097 | 2199 | if( (width_perc + left_perc) > 100 ){ |
2098 | | - width_perc = 100 - left_perc; |
2099 | | - } |
2100 | | - //js_log('should hl: '+rel_start_sec+ '/' + dur + ' re:' + rel_end_sec+' lp:' + left_perc + ' width: ' + width_perc); |
| 2200 | + width_perc = 100 - left_perc; |
| 2201 | + } |
| 2202 | + //js_log('should hl: '+rel_start_sec+ '/' + dur + ' re:' + rel_end_sec+' lp:' + left_perc + ' width: ' + width_perc); |
2101 | 2203 | $j('#mv_seeker_' + this_id + ' .mv_highlight').css({ |
2102 | 2204 | 'left':left_perc+'%', |
2103 | | - 'width':width_perc+'%' |
2104 | | - }).show(); |
2105 | | - |
| 2205 | + 'width':width_perc+'%' |
| 2206 | + }).show(); |
| 2207 | + |
2106 | 2208 | this.jump_time = options['start']; |
2107 | 2209 | this.seek_time_sec = npt2seconds( options['start']); |
2108 | | - //trim output to |
| 2210 | + //trim output to |
2109 | 2211 | this.setStatus( gM('mwe-seek_to')+' '+ seconds2npt( this.seek_time_sec ) ); |
2110 | 2212 | js_log('DO update: ' + this.jump_time); |
2111 | | - this.updateThumbTime( rel_start_sec ); |
| 2213 | + this.updateThumbTime( rel_start_sec ); |
2112 | 2214 | }, |
2113 | 2215 | hideHighlight:function(){ |
2114 | 2216 | var this_id = (this.pc)?this.pc.pp.id:this.id; |
— | — | @@ -2119,7 +2221,7 @@ |
2120 | 2222 | var id = (this.pc)?this.pc.pp.id:this.id; |
2121 | 2223 | //update status: |
2122 | 2224 | $j('#mv_time_'+id).html(value); |
2123 | | - } |
| 2225 | + } |
2124 | 2226 | } |
2125 | 2227 | |
2126 | 2228 | |
— | — | @@ -2146,9 +2248,9 @@ |
2147 | 2249 | supported_types:null, |
2148 | 2250 | library:null, |
2149 | 2251 | loaded:false, |
2150 | | - loading_callbacks:null, |
| 2252 | + loading_callbacks:null, |
2151 | 2253 | supportsMIMEType : function(type) |
2152 | | - { |
| 2254 | + { |
2153 | 2255 | for (var i=0; i < this.supported_types.length; i++) |
2154 | 2256 | if(this.supported_types[i] == type) |
2155 | 2257 | return true; |
— | — | @@ -2164,17 +2266,17 @@ |
2165 | 2267 | js_log('plugin loaded, do callback:'); |
2166 | 2268 | callback(); |
2167 | 2269 | }else{ |
2168 | | - var _this = this; |
2169 | | - //jQuery based get script does not work so well. |
2170 | | - mvJsLoader.doLoad([ |
| 2270 | + var _this = this; |
| 2271 | + //jQuery based get script does not work so well. |
| 2272 | + mvJsLoader.doLoad([ |
2171 | 2273 | libName |
2172 | 2274 | ],function(){ |
2173 | | - callback(); |
| 2275 | + callback(); |
2174 | 2276 | }); |
2175 | 2277 | } |
2176 | | - } |
| 2278 | + } |
2177 | 2279 | } |
2178 | | -/* players and supported mime types |
| 2280 | +/* players and supported mime types |
2179 | 2281 | @@todo ideally we query the plugin to get what mime types it supports in practice not always reliable/avaliable |
2180 | 2282 | */ |
2181 | 2283 | var flowPlayer = new mediaPlayer('flowplayer',['video/x-flv', 'video/h264'],'flash'); |
— | — | @@ -2191,7 +2293,7 @@ |
2192 | 2294 | //add generic |
2193 | 2295 | var oggPluginPlayer = new mediaPlayer('oggPlugin',['video/ogg'],'generic'); |
2194 | 2296 | |
2195 | | -//depricate quicktime in favor of safari native |
| 2297 | +//depricate quicktime in favor of safari native |
2196 | 2298 | //var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime'); |
2197 | 2299 | //var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime'); |
2198 | 2300 | |
— | — | @@ -2216,24 +2318,24 @@ |
2217 | 2319 | { |
2218 | 2320 | this.players = new Array(); |
2219 | 2321 | this.loadPreferences(); |
2220 | | - |
2221 | | - //set up default players order for each library type |
| 2322 | + |
| 2323 | + //set up default players order for each library type |
2222 | 2324 | this.default_players['video/x-flv'] = ['flash','vlc']; |
2223 | 2325 | this.default_players['video/h264'] = ['flash', 'vlc']; |
2224 | | - |
2225 | | - this.default_players['video/ogg'] = ['native','vlc','java', 'generic']; |
2226 | | - this.default_players['application/ogg'] = ['native','vlc','java', 'generic']; |
2227 | | - this.default_players['audio/ogg'] = ['native','vlc', 'java', 'omtk' ]; |
| 2326 | + |
| 2327 | + this.default_players['video/ogg'] = ['native','vlc','java', 'generic']; |
| 2328 | + this.default_players['application/ogg'] = ['native','vlc','java', 'generic']; |
| 2329 | + this.default_players['audio/ogg'] = ['native','vlc', 'java', 'omtk' ]; |
2228 | 2330 | this.default_players['video/mp4'] = ['vlc']; |
2229 | | - |
| 2331 | + |
2230 | 2332 | this.default_players['text/html'] = ['html']; |
2231 | 2333 | this.default_players['image/jpeg'] = ['html']; |
2232 | 2334 | this.default_players['image/png'] = ['html']; |
2233 | 2335 | this.default_players['image/svg'] = ['html']; |
2234 | | - |
| 2336 | + |
2235 | 2337 | }, |
2236 | 2338 | addPlayer : function(player, mime_type) |
2237 | | - { |
| 2339 | + { |
2238 | 2340 | //js_log('Adding ' + player.id + ' with mime_type ' + mime_type); |
2239 | 2341 | for (var i =0; i < this.players.length; i++){ |
2240 | 2342 | if (this.players[i].id == player.id) |
— | — | @@ -2241,52 +2343,52 @@ |
2242 | 2344 | if(mime_type!=null) |
2243 | 2345 | { |
2244 | 2346 | //make sure the mime_type is not already there: |
2245 | | - var add_mime = true; |
| 2347 | + var add_mime = true; |
2246 | 2348 | for(var j=0; j < this.players[i].supported_types.length; j++ ){ |
2247 | 2349 | if( this.players[i].supported_types[j]== mime_type) |
2248 | 2350 | add_mime=false; |
2249 | | - } |
| 2351 | + } |
2250 | 2352 | if(add_mime) |
2251 | 2353 | this.players[i].supported_types.push(mime_type); |
2252 | 2354 | } |
2253 | 2355 | return; |
2254 | 2356 | } |
2255 | 2357 | } |
2256 | | - //player not found: |
| 2358 | + //player not found: |
2257 | 2359 | if(mime_type!=null) |
2258 | | - player.supported_types.push(mime_type); |
2259 | | - |
| 2360 | + player.supported_types.push(mime_type); |
| 2361 | + |
2260 | 2362 | this.players.push( player ); |
2261 | 2363 | }, |
2262 | 2364 | getMIMETypePlayers : function(mime_type) |
2263 | | - { |
| 2365 | + { |
2264 | 2366 | var mime_players = new Array(); |
2265 | 2367 | var _this = this; |
2266 | 2368 | var inx = 0; |
2267 | | - if( this.default_players[mime_type] ){ |
2268 | | - $j.each( this.default_players[mime_type], function(d, lib){ |
2269 | | - var library = _this.default_players[mime_type][d]; |
2270 | | - for ( var i=0; i < _this.players.length; i++ ){ |
| 2369 | + if( this.default_players[mime_type] ){ |
| 2370 | + $j.each( this.default_players[mime_type], function(d, lib){ |
| 2371 | + var library = _this.default_players[mime_type][d]; |
| 2372 | + for ( var i=0; i < _this.players.length; i++ ){ |
2271 | 2373 | if ( _this.players[i].library == library && _this.players[i].supportsMIMEType(mime_type) ){ |
2272 | | - mime_players[ inx ] = _this.players[i]; |
| 2374 | + mime_players[ inx ] = _this.players[i]; |
2273 | 2375 | inx++; |
2274 | 2376 | } |
2275 | 2377 | } |
2276 | 2378 | }); |
2277 | | - } |
| 2379 | + } |
2278 | 2380 | return mime_players; |
2279 | 2381 | }, |
2280 | 2382 | defaultPlayer : function(mime_type) |
2281 | | - { |
2282 | | - js_log("get defaultPlayer for " + mime_type); |
2283 | | - var mime_players = this.getMIMETypePlayers(mime_type); |
| 2383 | + { |
| 2384 | + js_log("get defaultPlayer for " + mime_type); |
| 2385 | + var mime_players = this.getMIMETypePlayers(mime_type); |
2284 | 2386 | if( mime_players.length > 0) |
2285 | 2387 | { |
2286 | 2388 | // check for prior preference for this mime type |
2287 | 2389 | for( var i=0; i < mime_players.length; i++ ){ |
2288 | 2390 | if( mime_players[i].id==this.preference[mime_type] ) |
2289 | 2391 | return mime_players[i]; |
2290 | | - } |
| 2392 | + } |
2291 | 2393 | // otherwise just return the first compatible player |
2292 | 2394 | // (it will be chosen according to the default_players list |
2293 | 2395 | return mime_players[0]; |
— | — | @@ -2326,7 +2428,7 @@ |
2327 | 2429 | }, |
2328 | 2430 | loadPreferences : function() |
2329 | 2431 | { |
2330 | | - this.preference = new Object(); |
| 2432 | + this.preference = new Object(); |
2331 | 2433 | // see if we have a cookie set to a clientSupported type: |
2332 | 2434 | var cookieVal = $j.cookie( 'ogg_player_exp' ); |
2333 | 2435 | if (cookieVal) |
— | — | @@ -2342,11 +2444,11 @@ |
2343 | 2445 | }, |
2344 | 2446 | savePreferences : function() |
2345 | 2447 | { |
2346 | | - var cookieVal = ''; |
| 2448 | + var cookieVal = ''; |
2347 | 2449 | for(var i in this.preference) |
2348 | 2450 | cookieVal+= i + '='+ this.preference[i] + '&'; |
2349 | | - |
2350 | | - cookieVal=cookieVal.substr(0, cookieVal.length-1); |
| 2451 | + |
| 2452 | + cookieVal=cookieVal.substr(0, cookieVal.length-1); |
2351 | 2453 | var week = 7*86400*1000; |
2352 | 2454 | $j.cookie( 'ogg_player_exp', cookieVal, { 'expires':week } ); |
2353 | 2455 | } |
— | — | @@ -2360,7 +2462,7 @@ |
2361 | 2463 | var embedTypes = { |
2362 | 2464 | // List of players |
2363 | 2465 | players: null, |
2364 | | - detect_done:false, |
| 2466 | + detect_done:false, |
2365 | 2467 | init: function(){ |
2366 | 2468 | //detect supported types |
2367 | 2469 | this.detect(); |
— | — | @@ -2380,7 +2482,7 @@ |
2381 | 2483 | js_log("running detect"); |
2382 | 2484 | this.players = new mediaPlayers(); |
2383 | 2485 | //every browser supports html rendering: |
2384 | | - this.players.addPlayer( htmlPlayer ); |
| 2486 | + this.players.addPlayer( htmlPlayer ); |
2385 | 2487 | // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to |
2386 | 2488 | // search navigator.mimeTypes to see if it's installed |
2387 | 2489 | var javaEnabled = navigator.javaEnabled(); |
— | — | @@ -2392,28 +2494,28 @@ |
2393 | 2495 | // And it doesn't register an application/x-java-applet mime type like Mozilla does. |
2394 | 2496 | if ( invisibleJava && javaEnabled ) |
2395 | 2497 | this.players.addPlayer( cortadoPlayer ); |
2396 | | - |
| 2498 | + |
2397 | 2499 | // ActiveX plugins |
2398 | 2500 | if($j.browser.msie){ |
2399 | | - // check for flash |
2400 | | - if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash')){ |
2401 | | - //try to get the flash version for omtk include: |
| 2501 | + // check for flash |
| 2502 | + if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash')){ |
| 2503 | + //try to get the flash version for omtk include: |
2402 | 2504 | try { |
2403 | 2505 | a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7"); |
2404 | 2506 | d = a.GetVariable("$version"); // Will crash fp6.0.21/23/29 |
2405 | 2507 | if (d) { |
2406 | | - d = d.split(" ")[1].split(","); |
| 2508 | + d = d.split(" ")[1].split(","); |
2407 | 2509 | //we need flash version 10 or greater: |
2408 | 2510 | if(parseInt( d[0]) >=10){ |
2409 | 2511 | this.players.addPlayer( omtkPlayer ); |
2410 | 2512 | } |
2411 | | - |
2412 | | - } |
2413 | | - }catch(e) {} |
2414 | | - |
2415 | | - //flowplayer has pretty good compatiablity |
| 2513 | + |
| 2514 | + } |
| 2515 | + }catch(e) {} |
| 2516 | + |
| 2517 | + //flowplayer has pretty good compatiablity |
2416 | 2518 | // (but if we wanted to be fancy we would check for version of flash and update the mp4/h.264 support |
2417 | | - this.players.addPlayer( flowPlayer ); |
| 2519 | + this.players.addPlayer( flowPlayer ); |
2418 | 2520 | } |
2419 | 2521 | // VLC |
2420 | 2522 | if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) ) |
— | — | @@ -2423,14 +2525,14 @@ |
2424 | 2526 | this.players.addPlayer(cortadoPlayer); |
2425 | 2527 | // quicktime |
2426 | 2528 | //if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) ) |
2427 | | - // this.players.addPlayer(quicktimeActiveXPlayer); |
2428 | | - } |
| 2529 | + // this.players.addPlayer(quicktimeActiveXPlayer); |
| 2530 | + } |
2429 | 2531 | // <video> element |
2430 | 2532 | if ( typeof HTMLVideoElement == 'object' // Firefox, Safari |
2431 | 2533 | || typeof HTMLVideoElement == 'function' ) // Opera |
2432 | 2534 | { |
2433 | | - //do another test for safari: |
2434 | | - if( $j.browser.safari ){ |
| 2535 | + //do another test for safari: |
| 2536 | + if( $j.browser.safari ){ |
2435 | 2537 | try{ |
2436 | 2538 | var dummyvid = document.createElement("video"); |
2437 | 2539 | if (dummyvid.canPlayType && dummyvid.canPlayType("video/ogg;codecs=\"theora,vorbis\"") == "probably") |
— | — | @@ -2441,7 +2543,7 @@ |
2442 | 2544 | but xiph qt registers mimetype via quicktime plugin */ |
2443 | 2545 | this.players.addPlayer( videoElementPlayer ); |
2444 | 2546 | } else { |
2445 | | - //@@todo add some user nagging to install the xiph qt |
| 2547 | + //@@todo add some user nagging to install the xiph qt |
2446 | 2548 | } |
2447 | 2549 | }catch(e){ |
2448 | 2550 | js_log('could not run canPlayType in safari'); |
— | — | @@ -2449,8 +2551,8 @@ |
2450 | 2552 | }else{ |
2451 | 2553 | this.players.addPlayer( videoElementPlayer ); |
2452 | 2554 | } |
2453 | | - } |
2454 | | - |
| 2555 | + } |
| 2556 | + |
2455 | 2557 | // Mozilla plugins |
2456 | 2558 | if( navigator.mimeTypes && navigator.mimeTypes.length > 0) { |
2457 | 2559 | for ( var i = 0; i < navigator.mimeTypes.length; i++ ) { |
— | — | @@ -2464,17 +2566,17 @@ |
2465 | 2567 | if ( !pluginName ) { |
2466 | 2568 | // In case it is null or undefined |
2467 | 2569 | pluginName = ''; |
2468 | | - } |
| 2570 | + } |
2469 | 2571 | if ( pluginName.toLowerCase() == 'vlc multimedia plugin' || pluginName.toLowerCase() == 'vlc multimedia plug-in' ) { |
2470 | 2572 | this.players.addPlayer(vlcMozillaPlayer, type); |
2471 | 2573 | continue; |
2472 | 2574 | } |
2473 | | - |
| 2575 | + |
2474 | 2576 | if ( javaEnabled && type == 'application/x-java-applet' ) { |
2475 | 2577 | this.players.addPlayer(cortadoPlayer); |
2476 | 2578 | continue; |
2477 | | - } |
2478 | | - |
| 2579 | + } |
| 2580 | + |
2479 | 2581 | if ( type == 'application/ogg' ) { |
2480 | 2582 | if ( pluginName.toLowerCase() == 'vlc multimedia plugin' ){ |
2481 | 2583 | this.players.addPlayer(vlcMozillaPlayer, type); |
— | — | @@ -2493,14 +2595,14 @@ |
2494 | 2596 | continue; |
2495 | 2597 | } |
2496 | 2598 | } |
2497 | | - |
| 2599 | + |
2498 | 2600 | /*if ( type == 'video/quicktime' ) { |
2499 | 2601 | this.players.addPlayer(vlcMozillaPlayer, type); |
2500 | 2602 | continue; |
2501 | 2603 | }*/ |
2502 | 2604 | if(type=='application/x-shockwave-flash'){ |
2503 | 2605 | this.players.addPlayer( flowPlayer ); |
2504 | | - |
| 2606 | + |
2505 | 2607 | //check version to add omtk: |
2506 | 2608 | var flashDescription = navigator.plugins["Shockwave Flash"].description; |
2507 | 2609 | var descArray = flashDescription.split(" "); |
— | — | @@ -2509,7 +2611,7 @@ |
2510 | 2612 | //js_log("version of flash: " + versionMajor); |
2511 | 2613 | if(versionMajor >= 10){ |
2512 | 2614 | this.players.addPlayer( omtkPlayer ); |
2513 | | - } |
| 2615 | + } |
2514 | 2616 | continue; |
2515 | 2617 | } |
2516 | 2618 | } |
— | — | @@ -2528,5 +2630,5 @@ |
2529 | 2631 | hasObj = false; |
2530 | 2632 | } |
2531 | 2633 | return hasObj; |
2532 | | - } |
| 2634 | + } |
2533 | 2635 | }; |
Index: trunk/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html |
— | — | @@ -0,0 +1,29 @@ |
| 2 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 3 | +"http://www.w3.org/TR/html4/loose.dtd"> |
| 4 | +<html> |
| 5 | +<head> |
| 6 | + <title>Simple Video Tag Usage</title> |
| 7 | + <script type="text/javascript" src="../mv_embed.js"></script> |
| 8 | +</head> |
| 9 | +<body> |
| 10 | +<h3> Simple Video Relational Audio and Video the Commons </h3> |
| 11 | +This Example search primitive video in the Wikimedia Commons |
| 12 | +<span id="default_attr"> |
| 13 | +</span> <br /> |
| 14 | +<br /> |
| 15 | + <table border="1" cellpadding="6" width="600"> |
| 16 | + <tr> |
| 17 | + <td valign="top"> |
| 18 | + <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></td> |
| 19 | + <td valign="top"><b>Sample Relational Video And Audio</b><br /> |
| 20 | + <pre>The Example Code ::: </pre> |
| 21 | + <video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" |
| 22 | + poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" |
| 23 | + src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video> |
| 24 | + </br> |
| 25 | + </td> |
| 26 | + </table> |
| 27 | + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> |
| 28 | + </body> |
| 29 | +</html> |
| 30 | + |