70d1af8b2b4ddfcfcaaccbb7540b175f89c3b920
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:
133 $j(this).css({'width':this.pc
.pp
.width
, 'height':this.pc
.pp
.height
, 'overflow':"hidden"});
134 //@@todo support more smil animation layout stuff:
136 //wrap output in videoPlayer_ div:
137 $j(this).html('<div id="videoPlayer_'+ this.id
+'">'+this.getThumbnailHTML()+'</div>');
139 getThumbnailHTML:function( opt
){
143 var height
= (opt
.height
)?opt
.height
:this.pc
.pp
.height
;
144 var width
= (opt
.width
)?opt
.width
: this.pc
.pp
.width
;
145 js_log('1req '+ opt
.height
+ ' but got: ' + height
);
146 if( this.pc
.type
=='image/jpeg'){
147 js_log('should put src: '+this.pc
.src
);
148 out
= '<img style="width:'+width
+'px;height:'+height
+'px" src="'+this.pc
.src
+'">';
150 out
= this.pc
.wholeText
;
152 //js_log('f:getThumbnailHTML: got thumb: '+out);
155 doThumbnailHTML:function(){
156 js_log('f:htmlEmbed:doThumbnailHTML');
159 /* since its just html display get the "embed" right away */
161 js_log('getHTML: htmlEmbed');
164 getDuration:function(){
167 //return default value:
168 return pcHtmlEmbedDefaults
.dur
;
170 updateVideoTime:function(start_ntp
, end_ntp
){
171 //since we don't really have timeline for html elements just take the delta and set it as the duration
172 this.pc
.dur
= npt2seconds(end_ntp
) - npt2seconds(start_ntp
);
174 //gives a chance to make any nesseary external requests
175 //@@todo we can "start loading images" if we want
176 on_dom_swap:function(){
177 this.loading_external_data
=false
178 this.ready_to_play
=true;