2 * used to embed HTML as a movie clip
3 * for use with mv_playlist SMIL additions
4 * (we make assumptions about this.pc (parent clip) being available)
6 var pcHtmlEmbedDefaults={
7 'dur':4 //default duration of 4 seconds
15 'volume_control':true,
18 'playlist_swap_loader':true //if the object supports playlist functions
29 js_log('f:play: htmlEmbedWrapper');
31 this.clockStartTime = ct.getTime();
38 //window.clearInterval( this.monitorTimerId );
41 js_log('f:pause: htmlEmbedWrapper');
43 this.pauseTime = this.currentTime;
44 js_log('pause time: '+ this.pauseTime);
46 window.clearInterval( this.monitorTimerId );
48 //monitor just needs to keep track of time (do it at frame rate time) .
50 //js_log('html:monitor: '+ this.currentTime);
52 this.currentTime =( ( ct.getTime() - this.clockStartTime )/1000 ) +this.pauseTime;
54 //js_log('mvPlayList:monitor trueTime: '+ this.currentTime);
56 if( ! this.monitorTimerId ){
57 if(document.getElementById(this.id)){
58 if( !MV_ANIMATION_CB_RATE )
59 var MV_ANIMATION_CB_RATE= 33;
60 this.monitorTimerId = window.setInterval('$j(\'#'+this.id+'\').get(0).monitor()', 250);
64 //set up minimal media_element emulation:
66 autoSelectSource:function(){
75 timedTextSources:function(){
79 inheritEmbedObj:function(){
82 renderTimelineThumbnail:function( options ){
83 js_log("HTMLembed req w, height: " + options.width + ' ' + options.height);
84 //generate a scaled down version _that_ we can clone if nessisary
85 //add a not vissiable container to the body:
86 var do_refresh = (typeof options['refresh'] != 'undefined')?true:false;
88 var thumb_render_id = this.id +'_thumb_render_'+ options.height;
89 if( $j('#' + thumb_render_id ).length == 0 || do_refresh ){
90 //set the font scale down percentage: (kind of arbitrary)
91 var scale_perc = options.width / this.pc.pp.width;
92 js_log('scale_perc:'+options.width + ' / '+ $j(this).width()+ ' = '+scale_perc );
93 //min scale font percent of 70 (overflow is hidden)
94 var font_perc = ( Math.round( scale_perc*100 ) < 80 ) ? 80 : Math.round( scale_perc*100 );
95 var thumb_class = (typeof options['thumb_class'] !='undefined')? options['thumb_class'] : '';
96 $j('body').append( '<div id="' + thumb_render_id + '" style="display:none">'+
97 '<div class="' + thumb_class + '" '+
98 'style="width:'+options.width+'px;height:'+options.height+'px;" >'+
99 this.getThumbnailHTML({
100 'width': options.width,
101 'height': options.height
106 //scale down the fonts:
107 $j('#' + thumb_render_id + ' *').filter('span,div,p,h,h1,h2,h3,h4,h5,h6').css('font-size',font_perc+'%')
110 $j('#' + thumb_render_id +' a').each(function(){
111 $j(this).replaceWith("<span>" + $j(this).html() + "</span>");
114 //scale images that have width or height:
115 $j('#' + thumb_render_id + ' img').filter('[width]').each(function(){
117 'width': Math.round( $j(this).attr('width') * scale_perc ),
118 'height': Math.round( $j(this).attr('height') * scale_perc )
123 return $j('#' + thumb_render_id ).html();
125 //nothing to update in static html display: (return a static representation)
126 //@@todo render out a mini text "preview"
127 updateThumbTime:function( float_time ){
130 getEmbedHTML:function(){
131 js_log('f:html:getEmbedHTML: ' + this.id);
132 //set up the css for our parent div:
134 'width':this.pc.pp.width,
135 'height':this.pc.pp.height,
138 //@@todo support more smil animation layout stuff:
140 //wrap output in videoPlayer_ div:
141 $j(this).html('<div id="videoPlayer_'+ this.id+'">'+this.getThumbnailHTML()+'</div>');
143 getThumbnailHTML:function( opt ){
147 var height = (opt.height)?opt.height:this.pc.pp.height;
148 var width = (opt.width)?opt.width: this.pc.pp.width;
149 js_log('1req '+ opt.height + ' but got: ' + height);
150 if( this.pc.type =='image/jpeg' || this.pc.type == 'image/png' ){
151 js_log('should put src: '+this.pc.src);
152 out = '<img style="width:'+width+'px;height:'+height+'px" src="'+this.pc.src+'">';
154 out = this.pc.wholeText;
156 //js_log('f:getThumbnailHTML: got thumb: '+out);
159 doThumbnailHTML:function(){
160 js_log('htmlEmbed:doThumbnailHTML()');
163 /* since its just html display get the "embed" right away */
165 js_log('htmlEmbed::getHTML() ' + this.id);
168 getDuration:function(){
171 //return default value:
172 return pcHtmlEmbedDefaults.dur;
174 updateVideoTime:function(start_ntp, end_ntp){
175 //since we don't really have timeline for html elements just take the delta and set it as the duration
176 this.pc.dur = npt2seconds(end_ntp) - npt2seconds(start_ntp);
178 //gives a chance to make any nesseary external requests
179 //@@todo we can "start loading images" if we want
180 on_dom_swap:function(){
181 this.loading_external_data=false
182 this.ready_to_play=true;