From a5d9ee156c47e7deb5b117a26a79125ba7dbafa7 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Fri, 7 Aug 2009 22:59:49 +0000 Subject: [PATCH] * sequence fixes for adding new media ( was adding new clips with generic playback library instead of type based playback lib clips) * 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 | 18 +++-- .../libAddMedia/seqRemoteSearchDriver.js | 8 +-- js2/mwEmbed/libEmbedVideo/embedVideo.js | 50 ++++++------- js2/mwEmbed/libSequencer/mvPlayList.js | 72 ++++++++++--------- js2/mwEmbed/libSequencer/mvSequencer.js | 24 +++++-- 5 files changed, 96 insertions(+), 76 deletions(-) diff --git a/js2/editPage.js b/js2/editPage.js index 13e5552732..d9e90cb973 100644 --- a/js2/editPage.js +++ b/js2/editPage.js @@ -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(''); - $j('#btn-add-media-wiz').addMediaWiz( - mwAddMediaConfig - ); - } + + //add the add-media-wizard button for old toolbar: + $j('#toolbar').append(''); + $j('#btn-add-media-wiz').addMediaWiz( + mwAddMediaConfig + ); + + //add to new toolbar (need to use api) + //$j('[rel=insert] .tool-file').addMediaWiz( + // mwAddMediaConfig + //); } } diff --git a/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js b/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js index 9f3dd1e44d..944a254923 100644 --- a/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js @@ -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: "); diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index bd9e9a358d..1c4958275f 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -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 = '
'; - html_code += '
' + - this.getThumbnailHTML() + - '
'; - //js_log("mvEmbed:controls "+ typeof this.controls); - if(this.controls) - { - js_log("f:getHTML:AddControls"); - html_code +='
'; - html_code += this.getControlsHTML(); - html_code +='
'; - //block out some space by encapulating the top level div - $j(this).wrap('
'); - } + html_code += '
' + + this.getThumbnailHTML() + + '
'; + //js_log("mvEmbed:controls "+ typeof this.controls); + if(this.controls) + { + js_log("f:getHTML:AddControls"); + html_code +='
'; + html_code += this.getControlsHTML(); + html_code +='
'; + //block out some space by encapulating the top level div + $j(this).wrap('
'); + } html_code += '
'; //videoPlayer div close //js_log('should set: '+this.id); $j(this).html( html_code ); @@ -2129,7 +2131,7 @@ embedVideo.prototype = { + source.getTitle()+' '+ ''+"\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(){ diff --git a/js2/mwEmbed/libSequencer/mvPlayList.js b/js2/mwEmbed/libSequencer/mvPlayList.js index df9d2fbb39..0f80723e21 100644 --- a/js2/mwEmbed/libSequencer/mvPlayList.js +++ b/js2/mwEmbed/libSequencer/mvPlayList.js @@ -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); diff --git a/js2/mwEmbed/libSequencer/mvSequencer.js b/js2/mwEmbed/libSequencer/mvSequencer.js index 625dff6736..62dba9bc6a 100644 --- a/js2/mwEmbed/libSequencer/mvSequencer.js +++ b/js2/mwEmbed/libSequencer/mvSequencer.js @@ -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; -- 2.20.1