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
16 'volume_control':true,
19 'playlist_swap_loader':true // if the object supports playlist functions
30 js_log( 'f:play: htmlEmbedWrapper' );
32 this.clockStartTime = ct.getTime();
40 // window.clearInterval( this.monitorTimerId );
43 js_log( 'f:pause: htmlEmbedWrapper' );
45 this.pauseTime = this.currentTime;
46 js_log( 'pause time: ' + this.pauseTime );
48 window.clearInterval( this.monitorTimerId );
50 doSeek:function( perc ){
51 this.pauseTime = perc * this.getDuration();
54 setCurrentTime:function( perc, callback ){
55 this.pauseTime = perc * this.getDuration();
59 // Monitor just needs to keep track of time
61 //js_log('html:monitor: '+ this.currentTime);
63 this.currentTime = ( ( ct.getTime() - this.clockStartTime ) / 1000 ) + this.pauseTime;
65 // js_log('mvPlayList:monitor trueTime: '+ this.currentTime);
67 // Once currentTime is updated call parent_monitor
68 this.parent_monitor();
70 // set up minimal media_element emulation:
72 autoSelectSource:function() {
81 timedTextSources:function() {
85 inheritEmbedObj:function() {
88 renderTimelineThumbnail:function( options ) {
89 js_log( "HTMLembed req w, height: " + options.width + ' ' + options.height );
90 // generate a scaled down version _that_ we can clone if nessisary
91 // add a not vissiable container to the body:
92 var do_refresh = ( typeof options['refresh'] != 'undefined' ) ? true:false;
94 var thumb_render_id = this.id + '_thumb_render_' + options.height;
95 if ( $j( '#' + thumb_render_id ).length == 0 || do_refresh ) {
96 // set the font scale down percentage: (kind of arbitrary)
97 var scale_perc = options.width / this.pc.pp.width;
98 js_log( 'scale_perc:' + options.width + ' / ' + $j( this ).width() + ' = ' + scale_perc );
99 // min scale font percent of 70 (overflow is hidden)
100 var font_perc = ( Math.round( scale_perc * 100 ) < 80 ) ? 80 : Math.round( scale_perc * 100 );
101 var thumb_class = ( typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : '';
102 $j( 'body' ).append( '<div id="' + thumb_render_id + '" style="display:none">' +
103 '<div class="' + thumb_class + '" ' +
104 'style="width:' + options.width + 'px;height:' + options.height + 'px;" >' +
105 this.getThumbnailHTML( {
106 'width': options.width,
107 'height': options.height
112 // scale down the fonts:
113 $j( '#' + thumb_render_id + ' *' ).filter( 'span,div,p,h,h1,h2,h3,h4,h5,h6' ).css( 'font-size', font_perc + '%' )
115 // replace out links:
116 $j( '#' + thumb_render_id + ' a' ).each( function() {
117 $j( this ).replaceWith( "<span>" + $j( this ).html() + "</span>" );
120 // scale images that have width or height:
121 $j( '#' + thumb_render_id + ' img' ).filter( '[width]' ).each( function() {
123 'width': Math.round( $j( this ).attr( 'width' ) * scale_perc ),
124 'height': Math.round( $j( this ).attr( 'height' ) * scale_perc )
129 return $j( '#' + thumb_render_id ).html();
131 // nothing to update in static html display: (return a static representation)
132 // @@todo render out a mini text "preview"
133 updateThumbTime:function( float_time ) {
136 getEmbedHTML:function() {
137 js_log( 'f:html:getEmbedHTML: ' + this.id );
138 // set up the css for our parent div:
140 'width':this.pc.pp.width,
141 'height':this.pc.pp.height,
144 // @@todo support more smil animation layout stuff:
146 // wrap output in videoPlayer_ div:
147 $j( this ).html( '<div id="videoPlayer_' + this.id + '">' + this.getThumbnailHTML() + '</div>' );
149 getThumbnailHTML:function( opt ) {
153 var height = ( opt.height ) ? opt.height:this.pc.pp.height;
154 var width = ( opt.width ) ? opt.width: this.pc.pp.width;
155 js_log( '1req ' + opt.height + ' but got: ' + height );
156 if ( this.pc.type == 'image/jpeg' || this.pc.type == 'image/png' ) {
157 js_log( 'should put src: ' + this.pc.src );
158 out = '<img style="width:' + width + 'px;height:' + height + 'px" src="' + this.pc.src + '">';
160 out = this.pc.wholeText;
162 // js_log('f:getThumbnailHTML: got thumb: '+out);
165 doThumbnailHTML:function() {
166 js_log( 'htmlEmbed:doThumbnailHTML()' );
169 /* since its just html display get the "embed" right away */
171 js_log( 'htmlEmbed::getHTML() ' + this.id );
174 getDuration:function() {
175 if( !this.duration ){
177 this.duration = this.pc.dur;
178 }else if( pcHtmlEmbedDefaults.dur ){
179 this.duration =pcHtmlEmbedDefaults.dur ;
182 return this.parent_getDuration();
184 updateVideoTime:function( start_ntp, end_ntp ) {
185 // since we don't really have timeline for html elements just take the delta and set it as the duration
186 this.pc.dur = npt2seconds( end_ntp ) - npt2seconds( start_ntp );
188 // gives a chance to make any nesseary external requests
189 // @@todo we can "start loading images" if we want
190 on_dom_swap:function() {
191 this.loading_external_data = false
192 this.ready_to_play = true;