r49843 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49842‎ | r49843 | r49844 >
Date:21:49, 24 April 2009
Author:dale
Status:deferred
Tags:
Comment:
some fixes for frame-by-frame output
* activeClips object (stores list of active clips at any given time)
* update playlist pause, play and stop buttons propagate across active clips.
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_baseEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_nativeEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mvPlayList.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mvSequencer.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mvPlayList.js
@@ -51,6 +51,8 @@
5252 loading:true,
5353 loading_external_data:true, //if we are loading external data (set to loading by default)
5454
 55+ activeClipList:null,
 56+
5557 interface_url:null, //the interface url
5658 tracks:{},
5759 default_track:null, // the default track to add clips to.
@@ -70,7 +72,8 @@
7173 js_log('mvPlayList:init:');
7274 this.tracks={};
7375 this.default_track=null;
74 -
 76+
 77+ this.activeClipList = new activeClipList();
7578 //add default track & default track pointer:
7679 this.tracks[0]= new trackObj();
7780 this.default_track = this.tracks[0];
@@ -233,10 +236,14 @@
234237
235238 var durSum=0;
236239 $j.each( this.default_track.clips, function( i, clip ){
237 - if( clip.embed ){
238 - js_log('plDUR:add : '+ clip.getDuration() + ' src:' + clip.embed.src);
 240+ if( clip.embed ){
239241 clip.dur_offset = durSum;
240 - durSum += clip.getDuration();
 242+ if( clip.embed.supports['playlist_swap_loader'] ){
 243+ //don't include transition time (for playlist_swap_loader compatible clips) should have a better name for that
 244+ durSum += clip.getSoloDuration();
 245+ }else{
 246+ durSum += clip.getDuration();
 247+ }
241248 }else{
242249 js_log("ERROR: clip " +clip.id + " not ready");
243250 }
@@ -530,14 +537,21 @@
531538 //@@todo where the plugin supports pre_loading future clips and manage that in javascript
532539 //stop current clip
533540 this.cur_clip.embed.stop();
534 - this.updateCurrentClip(next_clip);
 541+
 542+ this.updateCurrentClip(next_clip);
 543+
535544 this.cur_clip.embed.play();
536545 },
537 - updateCurrentClip:function(new_clip){
538 - js_log('f:updateCurrentClip:'+new_clip.id);
 546+ updateCurrentClip:function(new_clip){
 547+ js_log('f:updateCurrentClip:'+new_clip.id);
 548+ //keep the active play clip in sync:
 549+ if( this.cur_clip )
 550+ this.activeClipList.remove(this.cur_clip )
 551+ this.activeClipList.add( new_clip );
 552+
539553 //do swap:
540554 $j('#clipDesc_'+this.cur_clip.id).hide();
541 - this.cur_clip=new_clip;
 555+ this.cur_clip=new_clip;
542556 $j('#clipDesc_'+this.cur_clip.id).show();
543557 //update the playhead:
544558 this.setSliderValue( this.cur_clip.dur_offset / this.getDuration() );
@@ -573,33 +587,38 @@
574588 //playlist play
575589 play: function(){
576590 var plObj=this;
577 - js_log('pl play');
 591+ //js_log('pl play');
578592 //hide the playlist play button:
579593 $j('#big_play_link_'+this.id).hide();
580594
581595 //un-pause if paused:
582596 if(this.paused)
583 - this.paused=false;
 597+ this.paused=false;
584598
585 - //update the control:
586 -
 599+ //update the control:
587600 this.start_clip = this.cur_clip;
588601 this.start_clip_src= this.cur_clip.src;
589602
590603 if(this.cur_clip.embed.supports['playlist_swap_loader'] ){
 604+ //set the cur_clip to active
 605+ this.activeClipList.add(this.cur_clip);
 606+
591607 //navtive support:
592608 // * pre-loads clips
593609 // * mv_playlist smil extension, manages transitions animations overlays etc.
594 - js_log('clip obj supports playlist swap_loader (ie playlist controlled playback)');
595 - //@@todo pre-load each clip:
596 - this.cur_clip.embed.play();
 610+ //js_log('clip obj supports playlist swap_loader (ie playlist controlled playback)');
 611+ //@@todo pre-load each clip:
 612+ //play all active clips (playlist_swap_loader can have more than one clip active)
 613+ $j.each(this.activeClipList.getClipList(), function(inx, clip){
 614+ clip.embed.play();
 615+ });
597616 }else if(this.cur_clip.embed.supports['playlist_driver']){
598 - js_log('playlist_driver');
 617+ //js_log('playlist_driver');
599618 //embedObject is feed the playlist info directly and manages next/prev
600 - this.cur_clip.embed.playMovieAt(this.cur_clip.order);
 619+ this.cur_clip.embed.playMovieAt( this.cur_clip.order );
601620 }else{
602621 //not much playlist support just play the first clip:
603 - js_log('basic play');
 622+ //js_log('basic play');
604623 //play cur_clip
605624 this.cur_clip.embed.play();
606625 }
@@ -610,18 +629,23 @@
611630 this.cur_clip.embed.toggleMute();
612631 },
613632 pause:function(){
614 - js_log('f:pause: playlist');
 633+ //js_log('f:pause: playlist');
615634 var ct = new Date();
616635 this.pauseTime = this.currentTime;
617636 this.paused=true;
618 - js_log('pause time: '+ this.pauseTime + ' call embed pause:');
619 - this.cur_clip.embed.pause();
 637+ //js_log('pause time: '+ this.pauseTime + ' call embed pause:');
 638+
 639+ //pause all the active clips:
 640+ $j.each(this.activeClipList.getClipList(), function(inx, clip){
 641+ clip.embed.pause();
 642+ });
620643 },
621644 fullscreen:function(){
622645 this.cur_clip.embed.fullscreen();
623646 },
624647 //playlist stops playback for the current clip (and resets state for start clips)
625648 stop:function(){
 649+ var _this = this;
626650 /*js_log("pl stop:"+ this.start_clip.id + ' c:'+this.cur_clip.id);
627651 //if start clip
628652 if(this.start_clip.id!=this.cur_clip.id){
@@ -635,15 +659,34 @@
636660 this.start_clip.embed.thumbnail_disp=true;
637661 }
638662 //empty the play-back container
639 - $j('#mv_ebct_'+this.id).empty();*/
 663+ $j('#mv_ebct_'+this.id).empty();*/
640664
 665+ //stop all the clips: monitor:
 666+ window.clearInterval( this.smil_monitorTimerId );
 667+ /*for (var i=0;i<this.clips.length;i++){
 668+ var clip = this.clips[i];
 669+ if(clip){
 670+ clip.embed.stop();
 671+ $j('#clipDesc_'+clip.id).hide();
 672+ }
 673+ }*/
 674+ //stop, hide and remove all active clips:
 675+ $j.each(this.activeClipList.getClipList(), function(inx, clip){
 676+ if(clip){
 677+ clip.embed.stop();
 678+ $j('#clipDesc_'+clip.id).hide();
 679+ _this.activeClipList.remove(clip);
 680+ }
 681+ });
 682+ //set the current clip to the first clip:
 683+ this.cur_clip = this.start_clip;
 684+ //display the first clip thumb:
 685+ this.cur_clip.embed.stop();
641686 //make sure the current clip is vissable:
642 - $j('#clipDesc_'+this.cur_clip.id).css({display:'inline'});
643 -
644 - //do stop current clip
645 - this.cur_clip.embed.stop();
646 - //stop the monitor:
647 - window.clearInterval( this.smil_monitorTimerId );
 687+ $j('#clipDesc_'+this.cur_clip.id).show();
 688+ //reset the currentTime:
 689+ this.currentTime = 0;
 690+ //FIXME still some issues with "stoping" and reseting the playlist
648691 },
649692 doSeek:function(v){
650693 js_log('pl:doSeek:'+v);
@@ -738,7 +781,7 @@
739782
740783 var cov = parseInt( this.cur_clip.order ) + parseInt( clip_offset );
741784 var cmax = this.getClipCount()-1;
742 - js_log( 'f:getClip: '+clip_offset + ' cov:'+cov +' cmax:'+ cmax);
 785+ //js_log( 'f:getClip: '+clip_offset + ' cov:'+cov +' cmax:'+ cmax);
743786
744787 //force first or last clip if offset is outOfBounds
745788 if( cov >= 0 && cov <= cmax ){
@@ -1074,7 +1117,7 @@
10751118 }*/
10761119 },
10771120 play:function(){
1078 - js_log('pl eb play');
 1121+ //js_log('pl eb play');
10791122 var plObj = this.pc.pp;
10801123 //check if we are already playing
10811124 if( !this.thumbnail_disp ){
@@ -1262,6 +1305,16 @@
12631306 this.stop();
12641307
12651308 //update the playlist current time:
 1309+ //check for a trsnOut from the previus clip to subtract
 1310+ /*var prev_clip = this.getClip(-1);
 1311+ var transOffset = 0;
 1312+ if( prev_clip.id != this.cur_clip.id ){
 1313+ if( prev_clip.transOut ){
 1314+ transOffset = prev_clip.transOut.getDuration();
 1315+ js_log("should add: " + transOffset + " off:" + this.cur_clip.dur_offset+ " to " +this.cur_clip.embed.currentTime +
 1316+ ' = ' + ( this.cur_clip.dur_offset + this.cur_clip.embed.currentTime + transOffset) );
 1317+ }
 1318+ }*/
12661319 this.currentTime = this.cur_clip.dur_offset + this.cur_clip.embed.currentTime;
12671320
12681321 //update slider:
@@ -1390,8 +1443,11 @@
13911444 if(typeof(other_pClip)=='undefined' || other_pClip.id == tObj.pClip.pp.cur_clip.id)
13921445 js_log('Error: crossfade without media asset');
13931446 //if not sliding start playback:
1394 - if(!tObj.pClip.pp.userSlide)
1395 - other_pClip.embed.play();
 1447+ if(!tObj.pClip.pp.userSlide){
 1448+ other_pClip.embed.play();
 1449+ //manualy ad the extra layer to the activeClipList
 1450+ tObj.pClip.pp.activeClipList.add( other_pClip );
 1451+ }
13961452 tObj.overlay_selector_id = 'clipDesc_'+other_pClip.id;
13971453 }else{
13981454 tObj.overlay_selector_id =this.getOverlaySelector(tObj);
@@ -1672,12 +1728,22 @@
16731729 * getDuration
16741730 * @returns duration in int
16751731 */
1676 - getDuration:function(){
 1732+ getDuration:function(){
16771733 //check for smil dur:
16781734 if( this.dur )
16791735 return this.dur;
16801736 return this.embed.getDuration();
1681 - }
 1737+ },
 1738+ //gets the duration of the clip subracting transitions
 1739+ getSoloDuration:function(){
 1740+ var fulldur = this.getDuration();
 1741+ //see if we need to subtract from time eating transitions (transOut)
 1742+ if(this.transOut)
 1743+ fulldur -= this.transOut.getDuration();
 1744+
 1745+ js_log("getSoloDuration:: td: " + this.getDuration() + ' sd:' + fulldur);
 1746+ return fulldur;
 1747+ }
16821748 }
16831749 /* object to manage embedding html with smil timings
16841750 * grabs settings from parent clip
@@ -1712,6 +1778,9 @@
17131779 if(_this.dur)
17141780 _this.dur = smilParseTime(_this.dur);
17151781 },
 1782+ getDuration:function(){
 1783+ return this.dur;
 1784+ },
17161785 //returns the values of supported_attributes:
17171786 getAttributeObj:function(){
17181787 var elmObj = {};
@@ -1811,9 +1880,38 @@
18121881 function smilParseTime(time_str){
18131882 return parseInt(time_str.replace('s', ''));
18141883 }
1815 -/***************************
1816 - * end SMIL specific code
1817 - ***************************/
 1884+//stores a list pointers to active clips (maybe this should just be a property of clips (but results in lots of seeks)
 1885+var activeClipList = function(){
 1886+ return this.init();
 1887+}
 1888+activeClipList.prototype = {
 1889+ init:function(){
 1890+ this.clipList = new Array();
 1891+ },
 1892+ add:function( clip ){
 1893+ //make sure the clip is not already active:
 1894+ for(var i =0;i < this.clipList.lenght; i++){
 1895+ var active_clip = this.clipList[i];
 1896+ if(clip.id == active_clip.id) //clip already active:
 1897+ return false;
 1898+ }
 1899+ this.clipList.push( clip );
 1900+ return true;
 1901+ },
 1902+ remove:function( clip ){
 1903+ for(var i = 0; i < this.clipList.length; i++){
 1904+ var active_clip = this.clipList[i];
 1905+ if(clip.id == active_clip.id){
 1906+ this.clipList.splice(i, 1);
 1907+ return true;
 1908+ }
 1909+ }
 1910+ return false;
 1911+ },
 1912+ getClipList:function(){
 1913+ return this.clipList;
 1914+ }
 1915+}
18181916 var trackObj = function( initObj ){
18191917 return this.init( initObj );
18201918 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mvSequencer.js
@@ -252,10 +252,10 @@
253253 rewrite_by_id( this.plObj_id );
254254 setTimeout(this.instance_name +'.checkReadyPlObj()', 25);
255255 },
256 - updateSeqSaveButtons:function(){
257 - var cancel_button = '<a style="border:' +
258 - 'solid gray;font-size:1.2em;" onClick="window.confirm("' + gM('edit_cancel_confirm') + '\")" '+
259 - 'href="javascript:'+this.instance_name+'.closeModEditor()">'+
 256+ updateSeqSaveButtons:function(){
 257+ var _this = this;
 258+ var cancel_button = '<a id="mv_cancel_seq_button" href="#" style="border:' +
 259+ 'solid gray;font-size:1.2em;" ">' +
260260 gM('edit_cancel') + '</a> ';
261261 if( this.sequenceEditToken ){
262262 $j('#'+this.sequence_container_id+'_save_cancel').html( cancel_button +
@@ -268,6 +268,15 @@
269269 }else{
270270 $j('#'+this.sequence_container_id+'_save_cancel').html( cancel_button + gM('no_edit_permissions') );
271271 }
 272+ //assing bindings
 273+ $j('#mv_cancel_seq_button').unbind().click(function(){
 274+ var x = window.confirm( gM('edit_cancel_confirm') );
 275+ if( x ){
 276+ _this.closeModEditor();
 277+ }else{
 278+ //close request canceled.
 279+ }
 280+ });
272281 },
273282 //display a menu item (hide the rest)
274283 disp:function( item ){
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_nativeEmbed.js
@@ -13,11 +13,10 @@
1414 'overlays':true,
1515 'playlist_swap_loader':true //if the object supports playlist functions
1616 },
17 - getEmbedHTML : function (){
18 - var id = (this.pc!=null)?this.pc.pp.id:this.id;
 17+ getEmbedHTML : function (){
1918 var embed_code = this.getEmbedObj();
2019 js_log("embed code: " + embed_code)
21 - setTimeout('$j(\'#' + id + '\').get(0).postEmbedJS()', 150);
 20+ setTimeout('$j(\'#' + this.id + '\').get(0).postEmbedJS()', 150);
2221 return this.wrapEmebedContainer( embed_code);
2322 },
2423 getEmbedObj:function(){
@@ -81,8 +80,8 @@
8281 //update duration if not set (for now trust the getDuration more than this.vid.duration
8382 this.duration = ( this.getDuration() ) ?this.getDuration() : this.vid.duration;
8483
85 - //update currentTime
86 - this.currentTime = this.vid.currentTime;
 84+ //update currentTime
 85+ this.currentTime = this.vid.currentTime;
8786
8887 //once currentTime is updated call parent_monitor
8988 this.parent_monitor();
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_baseEmbed.js
@@ -1775,8 +1775,8 @@
17761776 */
17771777 play:function(){
17781778 var this_id = (this.pc!=null)?this.pc.pp.id:this.id;
1779 - js_log( "mv_embed play:" + this.id);
1780 - js_log('thum disp:'+this.thumbnail_disp);
 1779+ //js_log( "mv_embed play:" + this.id);
 1780+ //js_log('thum disp:'+this.thumbnail_disp);
17811781 //check if thumbnail is being displayed and embed html
17821782 if( this.thumbnail_disp ){
17831783 if( !this.selected_player ){
@@ -1807,7 +1807,7 @@
18081808 */
18091809 pause: function(){
18101810 var this_id = (this.pc!=null)?this.pc.pp.id:this.id;
1811 - js_log('mv_embed:do pause');
 1811+ //js_log('mv_embed:do pause');
18121812 //(playing) do pause
18131813 this.paused=true;
18141814 //update the ctrl "paused state"

Status & tagging log