* sequence fixes for adding new media ( was adding new clips with generic playback...
authorMichael Dale <dale@users.mediawiki.org>
Fri, 7 Aug 2009 22:59:49 +0000 (22:59 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Fri, 7 Aug 2009 22:59:49 +0000 (22:59 +0000)
* fixed bug where drag and drop of clips did not work where you re-arranged clips while not displaying the add-media-wizard tab
* fixed display of sequence playhead on clip click
* added deselect of clips on escape
* Other minor code cleanup

js2/editPage.js
js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js
js2/mwEmbed/libEmbedVideo/embedVideo.js
js2/mwEmbed/libSequencer/mvPlayList.js
js2/mwEmbed/libSequencer/mvSequencer.js

index 13e5552..d9e90cb 100644 (file)
@@ -24,12 +24,16 @@ var mwEditPageHelper = {
        init:function(){
                var _this = this;
                //@@todo check for new version of toolbar and via toolbar api:
-               if(typeof $j.fn.toolbar == 'undefined'){                        
-                       //add the add-media-wizard button for old toolbar: 
-                       $j('#toolbar').append('<img style="cursor:pointer" id="btn-add-media-wiz" src="' + mv_skin_img_path + 'Button_add_media.png">');
-                       $j('#btn-add-media-wiz').addMediaWiz( 
-                                       mwAddMediaConfig 
-                       );              
-               }
+                                       
+               //add the add-media-wizard button for old toolbar: 
+               $j('#toolbar').append('<img style="cursor:pointer" id="btn-add-media-wiz" src="' + mv_skin_img_path + 'Button_add_media.png">');
+               $j('#btn-add-media-wiz').addMediaWiz( 
+                               mwAddMediaConfig 
+               );              
+                               
+               //add to new toolbar (need to use api) 
+               //$j('[rel=insert] .tool-file').addMediaWiz( 
+               //              mwAddMediaConfig 
+               //);                            
        }
 }
index 9f3dd1e..944a254 100644 (file)
@@ -34,10 +34,8 @@ seqRemoteSearchDriver.prototype = {
                                js_log("seqRemoteSearchDriver::" + _this.pSeq.disp_menu_item);
                                //call the parent
                                _this.pSeq.parent_do_refresh_timeline();
-                               //add our local bindings if our window is 'active'
-                               if(_this.pSeq.disp_menu_item == 'cliplib'){
-                                       _this.addResultBindings();
-                               }
+                               //add our local bindings                                
+                               _this.addResultBindings();                              
                                return true;
                        }
                }
@@ -121,7 +119,7 @@ seqRemoteSearchDriver.prototype = {
                        }                       
                        
                        //create the media element (target order+1 (since we insert (after)             
-                       _this.pSeq.plObj.tryAddMediaObj( clipConfig, (parseInt(target_order) + 1) );            
+                       _this.pSeq.plObj.tryAddMediaObj( clipConfig, (parseInt(target_order) + 1) );                                                                            
                        //refresh the timeline: 
                        _this.pSeq.do_refresh_timeline();
                        js_log("run close all: ");                                              
index bd9e9a3..1c49582 100644 (file)
@@ -225,15 +225,17 @@ mvEmbed = {
                }       
                ///js_log('did vI style');  
                //now swap out the video element for the embed_video obj:         
-                 $j(video_element).after(embed_video).remove();        
-                 //js_log('did swap');           
-                 $j('#'+embed_video.id).get(0).on_dom_swap();            
+               $j(video_element).after(embed_video).remove();  
+               //js_log('did swap');             
+               $j('#'+embed_video.id).get(0).on_dom_swap();    
+                         
                // now that "embed_video" is stable, do more initialization (if we are ready)
                if($j('#'+embed_video.id).get(0).loading_external_data==false && 
                           $j('#'+embed_video.id).get(0).init_with_sources_loadedDone==false){
                        //load and set ready state since source are available: 
                        $j('#'+embed_video.id).get(0).init_with_sources_loaded();
-               }   
+               }
+               
                js_log('done with child: ' + embed_video.id + ' len:' + global_player_list.length);
                return true;
        },
@@ -1185,7 +1187,7 @@ embedVideo.prototype = {
                                js_log('set loading_external_data=false');       
                                _this.loading_external_data=false;                                                         
                                
-                               _this.init_with_sources_loaded();                               
+                               _this.init_with_sources_loaded();               
                        });
                }
        },
@@ -1222,7 +1224,7 @@ embedVideo.prototype = {
                        var missing_type ='';
                        var or ='';  
                        for( var i=0; i < this.media_element.sources.length; i++){
-                               missing_type+=or + this.media_element.sources[i].mime_type;
+                               missing_type+= or + this.media_element.sources[i].mime_type;
                                or=' or ';
                        }                       
                        if( this.pc )
@@ -1231,7 +1233,7 @@ embedVideo.prototype = {
                           this.load_error= this.getPluginMissingHTML(missing_type);                                                                               
                }               
        },
-       inheritEmbedObj:function(){       
+       inheritEmbedObj:function(){             
                js_log("inheritEmbedObj:duration is: " +  this.duration);  
                //@@note: tricky cuz direct overwrite is not so ideal.. since the extended object is already tied to the dom
                //clear out any non-base embedObj stuff:
@@ -1651,24 +1653,24 @@ embedVideo.prototype = {
        },      
        getHTML : function (){          
                //@@todo check if we have sources avaliable     
-               js_log('embedVideo:getHTML : ' + this.id );                     
+               js_log('embedVideo:getHTML : ' + this.id  + ' resource type: ' + this.type);                    
                var _this = this;                                
                var html_code = '';             
                html_code = '<div id="videoPlayer_'+this.id+'" style="width:'+this.width+'px;" class="videoPlayer">';           
-                       html_code += '<div style="width:'+parseInt(this.width)+'px;height:'+parseInt(this.height)+'px;"  id="mv_embedded_player_'+this.id+'">' +
-                                                       this.getThumbnailHTML() + 
-                                               '</div>';                                                                                       
-                       //js_log("mvEmbed:controls "+ typeof this.controls);                                                                    
-                       if(this.controls)
-                       {
-                               js_log("f:getHTML:AddControls");
-                               html_code +='<div id="mv_embedded_controls_' + this.id + '" class="ui-widget ui-corner-bottom ui-state-default controls" >';
-                               html_code += this.getControlsHTML();       
-                               html_code +='</div>';     
-                               //block out some space by encapulating the top level div 
-                               $j(this).wrap('<div style="width:'+parseInt(this.width)+'px;height:'
-                                               +(parseInt(this.height)+ctrlBuilder.height)+'px"></div>');                                      
-                       }
+               html_code += '<div style="width:'+parseInt(this.width)+'px;height:'+parseInt(this.height)+'px;"  id="mv_embedded_player_'+this.id+'">' +
+                                               this.getThumbnailHTML() + 
+                                       '</div>';                                                                                       
+               //js_log("mvEmbed:controls "+ typeof this.controls);                                                                    
+               if(this.controls)
+               {
+                       js_log("f:getHTML:AddControls");
+                       html_code +='<div id="mv_embedded_controls_' + this.id + '" class="ui-widget ui-corner-bottom ui-state-default controls" >';
+                       html_code += this.getControlsHTML();       
+                       html_code +='</div>';     
+                       //block out some space by encapulating the top level div 
+                       $j(this).wrap('<div style="width:'+parseInt(this.width)+'px;height:'
+                                       +(parseInt(this.height)+ctrlBuilder.height)+'px"></div>');                                      
+               }
                html_code += '</div>'; //videoPlayer div close          
                //js_log('should set: '+this.id);
                $j(this).html( html_code );                                     
@@ -2129,7 +2131,7 @@ embedVideo.prototype = {
                                + source.getTitle()+'</a> '+ '</li>'+"\n";                      
                        if(      source.getURI().indexOf('?t=')!==-1){
                                out+=dl_line;
-                       }else if(this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt"){
+                       }else if( this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt" ){
                                dl_txt_list+=dl_line;
                        }else{
                                dl_list+=dl_line;
@@ -2186,7 +2188,7 @@ embedVideo.prototype = {
        }, 
        /*
         * base embed pause
-        *       there is no general way to pause the video
+        *      there is no general way to pause the video
         *  must be overwritten by embed object to support this functionality.
         */
        pause: function(){
index df9d2fb..0f80723 100644 (file)
@@ -541,12 +541,10 @@ mvPlayList.prototype = {
        setStatus:function(value){
                $j('#mv_time_'+this.id).html( value );
        },
-       setSliderValue:function(value){         
-               if( this.controls ){
-                       //slider is on 1000 scale: 
-                       var val = parseInt( value *1000 );                      
-                       $j('#mv_play_head_' + this.id).slider('value', val);
-               }
+       setSliderValue:function(value){                         
+               //slider is on 1000 scale: 
+               var val = parseInt( value *1000 );                      
+               $j('#mv_play_head_' + this.id).slider('value', val);            
        },      
        getPlayHeadPos: function(prec_done){
                var     _this = this;
@@ -648,10 +646,12 @@ mvPlayList.prototype = {
                this.cur_clip.embed.stop();
        },
        updateCurrentClip:function( new_clip ){                         
-               js_log('f:updateCurrentClip:'+new_clip.id);
+               js_log('f:updateCurrentClip:'+new_clip.id);             
                //make sure we are not switching to the current
-               if( this.cur_clip.id == new_clip.id )
-                       return js_log('trying to updateCurrentClip to same clip');
+               if( this.cur_clip.id == new_clip.id ){
+                       js_log('trying to updateCurrentClip to same clip');
+                       return false;
+               }
                        
                //keep the active play clip in sync (stop the other clip) 
                if( this.cur_clip ){
@@ -1099,8 +1099,7 @@ mvClip.prototype = {
        //setup the embed object:
        setUpEmbedObj:function(){       
                js_log('mvClip:setUpEmbedObj()');       
-               //init:
-               //debugger;
+               //init:         
                
                
                this.embed=null;                
@@ -1111,8 +1110,8 @@ mvClip.prototype = {
                        src:this.src
                };
 
-               this.setBaseEmbedDim(init_pl_embed);
-               //always display controls for playlists: 
+               this.setBaseEmbedDim( init_pl_embed );
+
                
                //if in sequence mode hide controls / embed links                
                //                      init_pl_embed.play_button=false;
@@ -1124,9 +1123,9 @@ mvClip.prototype = {
                if(this.poster)init_pl_embed['thumbnail']=this.poster;
                
                if( this.type )init_pl_embed['type'] = this.type;
-               
-               this.embed = new PlMvEmbed( init_pl_embed );
                                
+               this.embed = new PlMvEmbed( init_pl_embed );    
+                                       
                //js_log('media Duration:' + this.embed.getDuration() );
                //js_log('media element:'+ this.embed.media_element.length);
                //js_log('type of embed:' + typeof(this.embed) + ' seq:' + this.pp.sequencer+' pb:'+ this.embed.play_button);           
@@ -1299,12 +1298,12 @@ PlMvEmbed.prototype = {
                                        
                var th=Math.round( _this.pl_layout.clip_desc * _this.height );  
                var tw=Math.round( th * _this.pl_layout.clip_aspect );
+               
                //run the parent stop:
                this.pe_stop();
                var pl_height = (_this.sequencer=='true')?_this.height+27:_this.height;
                
                this.getHTML();
-                               
        },
        play:function(){
                //js_log('pl eb play');         
@@ -1328,8 +1327,8 @@ PlMvEmbed.prototype = {
                //setup hover images (for playhead and next/prev buttons)
                this.pc.pp.setUpHover();
                //call the parent postEmbedJS
-                this.pe_postEmbedJS();
-                mv_lock_vid_updates=false;
+               this.pe_postEmbedJS();
+               mv_lock_vid_updates=false;
        },
        getPlayButton:function(){
                return this.pe_getPlayButton(this.pc.pp.id);
@@ -1338,6 +1337,7 @@ PlMvEmbed.prototype = {
                //status updates handled by playlist obj
        },
        setSliderValue:function(value){
+               js_log('PlMvEmbed:setSliderValue:' + value);
                //setSlider value handled by playlist obj       
        }       
 }
@@ -1353,8 +1353,8 @@ var m3uPlaylist = {
                //js_log('data:'+ this.data.toString());
                $j.each(this.data.split("\n"), function(i,n){                   
                        //js_log('on line '+i+' val:'+n+' len:'+n.length);
-                       if(n.charAt(0)!='#'){
-                               if(n.length>3){ 
+                       if( n.charAt(0) != '#' ){
+                               if( n.length > 3 ){ 
                                        //@@todo make sure its a valid url
                                        //js_log('add url: '+i + ' '+ n);
                                        var cur_clip = new mvClip({type:'srcClip',id:'p_'+this_pl.id+'_c_'+inx,pp:this_pl,src:n,order:inx});
@@ -1883,9 +1883,9 @@ var smilPlaylist ={
                        'title':'',
                        'interface_url':"", 
                        'linkback':"",
-                        'mTitle':"", 
-                        'mTalk':"", 
-                        'mTouchedTime':""
+                       'mTitle':"", 
+                       'mTalk':"", 
+                       'mTouchedTime':""
                }; 
                $j.each(meta_tags, function(i,meta_elm){
                        //js_log( "on META tag: "+ $j(meta_elm).attr('name') );
@@ -1926,13 +1926,14 @@ var smilPlaylist ={
                js_log("done proc seq tags");           
                return true;
        },
-       tryAddMediaObj:function(mConfig, order, track_id){
-               var mediaElement = document.createElement('ref');       
+       tryAddMediaObj:function(mConfig, order, track_id){              
+               js_log('tryAddMediaObj::');             
+               var mediaElement = document.createElement('div');       
                for(var i =0; i < mv_smil_ref_supported_attributes.length;i++){         
                        var attr =      mv_smil_ref_supported_attributes[i];
                        if(mConfig[attr])
-                               $j(mediaElement).attr(attr, mConfig[attr]);
-               }                       
+                               $j(mediaElement).attr( attr, mConfig[attr] );
+               }               
                this.tryAddMedia(mediaElement, order, track_id);
        },
        tryAddMedia:function(mediaElement, order, track_id){    
@@ -1944,21 +1945,24 @@ var smilPlaylist ={
                                                "id":'p_' + _this.id + '_c_' + order,
                                                "pp":this, //set the parent playlist object pointer
                                                "order": order                                                                  
-                                       };              
+                                       };                              
                var clipObj = new mvSMILClip(mediaElement, cConfig );
                        
                //set optional params track                                                                              
                if( typeof track_id != 'undefined')
                        clipObj["track_id"]     = track_id;
                         
-               //debugger;
+               
                if ( clipObj ){
                        //set up embed:                                         
-                       clipObj.setUpEmbedObj();                                                                
+                       clipObj.setUpEmbedObj();        
+                       //inhreit embedObject (only called on "new media" 
+                       clipObj.embed.init_with_sources_loaded();                                       
                        //add clip to track: 
                        this.addCliptoTrack( clipObj , order);          
+                       
                        return true;
-               }       
+               }                       
                //@@todo we could throw error details here once we integrate try catches everywhere :P
                return false;
        } 
@@ -1992,8 +1996,7 @@ mvSMILClip.prototype = {
                _this = this;                   
                this.params     = {};           
                //make new mvCLip with ClipInit vals  
-               var myMvClip = new mvClip( mvClipInit );
-               
+               var myMvClip = new mvClip( mvClipInit );                
                //inherit mvClip                
                for(var method in myMvClip){                    
                        if(typeof this[method] != 'undefined' ){                                
@@ -2095,7 +2098,8 @@ mvSMILClip.prototype = {
  * http://www.w3.org/TR/SMIL3/smil-timing.html#Timing-ClockValueSyntax
  * (probably have to use a Time object to fully support the smil spec
  */
-function smilParseTime(time_str){
+function smilParseTime( time_str ){
+       time_str = time_str + '';
        //first check for hh:mm:ss time: 
        if(time_str.split(':').length == 3){
                return npt2seconds(time_str);
index 625dff6..62dba9b 100644 (file)
@@ -620,9 +620,14 @@ mvSequencer.prototype = {
                        if( e.which == 16 )
                                _this.key_shift_down = false;
                                
-                       if( e.which == 17)
+                       if( e.which == 17 )
                                _this.key_ctrl_down = false;                                                    
                        
+                       //escape key (for now deselect)  
+                       if( e.which == 27 )
+                               _this.deselectClip();
+                       
+                       
                        //backspace or delete key while not focused on a text area: 
                        if( (e.which == 8 || e.which == 46) && !_this.inputFocus)                                                               
                                _this.removeSelectedClips();                                    
@@ -1331,10 +1336,14 @@ mvSequencer.prototype = {
                return insert_key;
        },
        deselectClip:function( clipElm ){
-               $j(clipElm).removeClass("mv_selected_clip");
-               //make sure the transition sibling is removed:
-               $j(clipElm).siblings('.clip_trans_box').removeClass( 'mv_selected_transition' );
-               $j('#' + $j(clipElm).parent().attr("id") + '_adj').fadeOut("fast");
+               if(!clipElm){
+                       $j('.mv_selected_clip').removeClass("mv_selected_clip");        
+               }else{
+                       $j(clipElm).removeClass("mv_selected_clip");
+                       //make sure the transition sibling is removed:
+                       $j(clipElm).siblings('.clip_trans_box').removeClass( 'mv_selected_transition' );
+                       $j('#' + $j(clipElm).parent().attr("id") + '_adj').fadeOut("fast");
+               }
        },
        getClipFromSeqID:function( clip_seq_id ){
                js_log('get id from: ' + clip_seq_id);
@@ -1512,20 +1521,23 @@ var mvSeqPlayList = function( element ){
 mvSeqPlayList.prototype = {
        init:function(element){
                var myPlObj = new mvPlayList(element);
+               
                //inherit mvClip                
                for(var method in myPlObj){                     
                        if(typeof this[method] != 'undefined' ){                                
-                               this['parent_'+method]=myPlObj[method];                         
+                               this[ 'parent_' + method ]=myPlObj[method];                             
                        }else{          
                                this[method] = myPlObj[method];
                        }               
                }               
+               
                this.org_control_height = this.pl_layout.control_height;                
                //do specific mods:(controls and title are managed by the sequencer)  
                this.pl_layout.title_bar_height=0;
                this.pl_layout.control_height=0;                                
        },      
        setSliderValue:function( perc ){
+               js_log('setSliderValue::'+ perc);
                //get the track_clipThumb_height from parent mvSequencer        
                var frame_width = Math.round( this.pSeq.track_clipThumb_height * 1.3333333 );
                var container_width = frame_width+60;