* some sequence render fixes
authorMichael Dale <dale@users.mediawiki.org>
Sun, 15 Nov 2009 17:20:46 +0000 (17:20 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Sun, 15 Nov 2009 17:20:46 +0000 (17:20 +0000)
* some IE regression fixes and skin compatibility update
* fixed showShare for IE kskin

js2/mwEmbed/example_usage/Player_Themable.html
js2/mwEmbed/example_usage/media/sample_smil.xml
js2/mwEmbed/libAddMedia/remoteSearchDriver.js
js2/mwEmbed/libEmbedVideo/embedVideo.js
js2/mwEmbed/libEmbedVideo/htmlEmbed.js
js2/mwEmbed/libEmbedVideo/nativeEmbed.js
js2/mwEmbed/libSequencer/mvFirefoggRender.js
js2/mwEmbed/libSequencer/mvPlayList.js
js2/mwEmbed/mv_embed.js
js2/mwEmbed/skins/ctrlBuilder.js
js2/remoteMwEmbed.js

index a17f857..eb9439b 100644 (file)
@@ -3,6 +3,7 @@
 <html>
 <head>
        <title>Sample Themed Player</title>
+       <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed,embedVideo&urid=1"></script> -->   
        <script type="text/javascript" src="../mv_embed.js?debug=true"></script>         
 </head>
 <script type="text/javascript">
index e141b36..25ffecc 100644 (file)
@@ -29,6 +29,7 @@
                transOut="xFade"        
                type="video/ogg"        
                fill="transition"
+               durationHint="15"
                dur="7s"
                poster="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Okapia_johnstoni5.ogg/mid-Okapia_johnstoni5.ogg.jpg"/> 
        
@@ -36,6 +37,7 @@
                region="video_region"                           
                fill="transition" 
                dur="10s"
+               durationHint="70"
                type="video/ogg" 
                poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg"/>     
     </seq>
index a909e25..82678c0 100644 (file)
@@ -1135,7 +1135,7 @@ remoteSearchDriver.prototype = {
                // Try and keep aspect ratio for the thumbnail that we clicked:         
                var tRatio = $j( rsdElement ).height() / $j( rsdElement ).width();
 
-               if (    ! tRatio )
+               if (! tRatio )
                        var tRatio = 1; // set ratio to 1 if tRatio did not work. 
 
                js_log( 'Set from ' +  tRatio + ' to init thumbimage to ' + maxWidth + ' x ' + parseInt( tRatio * maxWidth ) );
@@ -1146,7 +1146,7 @@ remoteSearchDriver.prototype = {
                        'left':'5px',
                        'width': maxWidth + 'px',
                        'height': parseInt( tRatio * maxWidth )  + 'px'
-               }, "slow" ); // do it slow to give it a chance to finish loading the HQ version
+               }, "slow" ); // Do it slow to give it a chance to finish loading the HQ version
 
                if ( mediaType == 'image' ) {
                        _this.loadHQImg( rObj, { 'width':maxWidth }, 'rsd_edit_img', function() {
@@ -1215,8 +1215,7 @@ remoteSearchDriver.prototype = {
                        .btnBind()
                        .click( function() {
                                $j( _this.target_container ).dialog( 'close' );
-                       } )
-
+                       } );
        },
        /* getClipEditControlActions
        * Set-up the control actions for clipEdit with relevant callbacks 
@@ -1727,8 +1726,14 @@ remoteSearchDriver.prototype = {
        closeAll:function() {
                 var _this = this;
                 js_log( "close all:: "  + _this.target_container );
-                _this.cancelClipEditCB();
-                $j( _this.target_container ).dialog( 'close' );
+                _this.cancelClipEditCB();               
+                // Give a chance for the events to complete
+                // (somehow at least in firefox a rare condition occurs where
+                // the modal of the edit-box stick around even after the 
+                // close request has been issued. )
+                setTimeout(function(){
+                       $j( _this.target_container ).dialog( 'close' );
+                },10);          
        },
        setResultBarControl:function( ) {
                var _this = this;
@@ -1738,10 +1743,10 @@ remoteSearchDriver.prototype = {
                var list_light_url       = mv_skin_img_path + 'list_layout_icon.png';
 
                var about_desc = '';
-               if ( this.content_providers[this.disp_item] ) {
+               if ( this.content_providers[ this.disp_item ] ) {
                        var cp = this.content_providers[this.disp_item];
                        about_desc = '<span style="position:relative;top:0px;font-style:italic;">' +
-                                       '<i>' + gM( 'mwe-results_from', [cp.homepage, gM( 'rsd-' + this.disp_item + '-title' ) ] ) + '</i></span>';
+                                       '<i>' + gM( 'mwe-results_from', [ cp.homepage, gM( 'rsd-' + this.disp_item + '-title' ) ] ) + '</i></span>';
                        $j( '#tab-' + this.disp_item ).append( '<div id="rds_results_bar">' +
                                '<span style="float:left;top:0px;font-style:italic;">' +
                                        gM( 'rsd_layout' ) + ' ' +
@@ -1758,7 +1763,7 @@ remoteSearchDriver.prototype = {
                                '<span id="rsd_paging_ctrl" style="float:right;"></span>' +
                                '</div>'
                        );
-                       // get paging with bindings:
+                       // Get paging with bindings:
                        this.getPaging( '#rsd_paging_ctrl' );
 
                        $j( '#msc_box_layout' ).hover( function() {
index 22da503..d193157 100644 (file)
@@ -74,7 +74,8 @@ var default_video_attributes = {
        
        // roe url (for xml based metadata)
        "roe" : null,
-       // if roe includes metadata tracks we can expose a link to metadata
+       
+       // If roe includes metadata tracks we can expose a link to metadata
        "show_meta_link" : true,
 
        // default state attributes per html5 spec:
@@ -93,7 +94,7 @@ var default_video_attributes = {
        "linkback" : null,
        "embed_link" : true,
        "download_link" : true,
-       "type" :null,    // the content type of the media 
+       "type" :null     // the content type of the media 
 };
 /*
  * the base source attribute checks
@@ -169,6 +170,7 @@ mvEmbed = {
                        $j( element ).attr( "id", 'v' + mw.player_list.length );
                }
                js_log( "mvEmbed::rewrite:: " + $j( element ).attr( "id" ) + ' tag: ' + element.tagName.toLowerCase() );
+               
                // Store a global reference to the id   
                mw.player_list.push( $j( element ).attr( "id" ) );
                        
@@ -534,16 +536,11 @@ mediaElement.prototype = {
                
                if ( $j( video_element ).attr( 'wikiTitleKey' ) )
                        this.wikiTitleKey = $j( video_element ).attr( 'wikiTitleKey' );
-       
+               
                if ( $j( video_element ).attr( 'durationHint' ) ) {
                        this.durationHint = $j( video_element ).attr( 'durationHint' );
                        // convert duration hint if needed:
-                       var sc = this.durationHint.split( ':' );
-                       if ( sc.length >= 1 ) {
-                               this.duration = npt2seconds( this.durationHint );
-                       } else {
-                               this.duration = parseFloat( this.durationHint );
-                       }
+                       this.duration = npt2seconds(  this.durationHint );
                }
                
                // Process the video_element as a source element:
@@ -856,7 +853,7 @@ embedVideo.prototype = {
                }
                
                // Set the skin name from the class  
-               var     sn = element.getAttribute( 'class' );
+               var     sn = $j(element).attr( 'class' );
                if ( sn && sn != '' ) {
                        for ( var n = 0; n < mw.valid_skins.length; n++ ) {
                                if ( sn.indexOf( mw.valid_skins[n] ) !== -1 ) {
@@ -1022,29 +1019,29 @@ embedVideo.prototype = {
        doNativeWarningCheck:function() {
                if ( $j.cookie( 'dismissNativeWarn' ) && $j.cookie( 'dismissNativeWarn' ) === true ) {
                        return false;
-               } else {
-                       // see if we have native support for ogg: 
-                       var supporting_players = embedTypes.players.getMIMETypePlayers( 'video/ogg' );
-                       for ( var i = 0; i < supporting_players.length; i++ ) {
-                               if ( supporting_players[i].id == 'videoElement' ) {
-                                       return false;
-                               }
+               }
+               
+               // See if we have native support for ogg: 
+               var supporting_players = embedTypes.players.getMIMETypePlayers( 'video/ogg' );
+               for ( var i = 0; i < supporting_players.length; i++ ) {
+                       if ( supporting_players[i].id == 'videoElement' ) {
+                               return false;
                        }
-                       // see if we are using mv_embed without a ogg source in which case no point in promoting firefox :P                     
-                       if ( this.media_element && this.media_element.sources ) {
-                               var foundOgg = false;
-                               var playable_sources = this.media_element.getPlayableSources();
-                               for ( var sInx = 0; sInx < playable_sources.length; sInx++ ) {
-                                       var mime_type = playable_sources[sInx].mime_type;
-                                       if ( mime_type == 'video/ogg' ) {
-                                               foundOgg = true;
-                                       }
+               }
+               // See if we are using mv_embed without a ogg source in which case no point in promoting firefox :P                     
+               if ( this.media_element && this.media_element.sources ) {
+                       var foundOgg = false;
+                       var playable_sources = this.media_element.getPlayableSources();
+                       for ( var sInx = 0; sInx < playable_sources.length; sInx++ ) {
+                               var mime_type = playable_sources[sInx].mime_type;
+                               if ( mime_type == 'video/ogg' ) {
+                                       foundOgg = true;
                                }
-                               // no ogg src... no point in download firefox link
-                               if ( !foundOgg )
-                                       return false;
-                                                                               
                        }
+                       // no ogg src... no point in download firefox link
+                       if ( !foundOgg )
+                               return false;
+                                                                       
                }
                return true;
        },
@@ -1061,19 +1058,19 @@ embedVideo.prototype = {
                return this.media_element.selected_source.start_ntp + et;
        },
        getDuration:function() {
-               // update some local pointers for the selected source:  
+               // Update some local pointers for the selected source:  
                if ( this.media_element && this.media_element.selected_source && this.media_element.selected_source.duration ) {
                        this.duration = this.media_element.selected_source.duration;
                        this.start_offset = this.media_element.selected_source.start_offset;
                        this.start_ntp = this.media_element.selected_source.start_ntp;
                        this.end_ntp = this.media_element.selected_source.end_ntp;
                }
-               // update start end_ntp if duration !=0 (set from plugin) 
+               // Update start end_ntp if duration !=0 (set from plugin) 
                if ( !this.start_ntp )
                        this.start_ntp = '0:0:0';
                if ( !this.end_ntp && this.duration )
                        this.end_ntp = seconds2npt( this.duration );
-               // return the duration
+               // Return the duration
                return this.duration;
        },
        /*
@@ -1096,6 +1093,7 @@ embedVideo.prototype = {
        // Do seek function (should be overwritten by implementing embedLibs)
        // to check if seek can be done on locally downloaded content. 
        doSeek : function( perc ) {
+               var _this = this;
                if ( this.supportsURLTimeEncoding() ) {
                        // make sure this.seek_time_sec is up-to-date:
                        this.seek_time_sec = npt2seconds( this.start_ntp ) + parseFloat( perc * this.getDuration() );
@@ -1106,7 +1104,9 @@ embedVideo.prototype = {
                        this.setSliderValue( perc );
                }
                // do play in 100ms (give things time to clear) 
-               setTimeout( '$j(\'#' + this.id + '\').get(0).play()', 100 );
+               setTimeout( function(){
+                       _this.play()
+               }, 100 );
        },
        /*
         * seeks to the requested time and issues a callback when ready 
@@ -1730,16 +1730,19 @@ embedVideo.prototype = {
                var _this = this;
         // @todo: hook events to two a's for swapping in and out code for link vs. embed;
         //       hook events for changing active class of li based on a.
+        var o = '';                                    
                o += '<h2>' + gM( 'mwe-share_this_video' ) + '</h2>' +
                        '<ul>' +
-                       '<li><a href="#" class="active">' + gM( 'mwe-embed_site_or_blog' ) + '</a></li>';
-               if ( this.linkback ) {
-                       o += '<li><a href="#" id="k-share-link">' + this.linkback + '</a></li>';
-        }
-               o +=    '</ul>' +
-                       '<div class="source_wrap"><textarea>' + embed_code + '</textarea></div>' +
-                               '<button class="ui-state-default ui-corner-all copycode">' + gM( 'mwe-copy-code' ) + '</button>' +
-                               '<div class="ui-state-highlight ui-corner-all">' + gM( 'mwe-read_before_embed' ) + '</div>' +
+                               '<li><a href="#" class="active">' + gM( 'mwe-embed_site_or_blog' ) + '</a></li>';
+                               if ( this.linkback )
+                                       o += '<li><a href="#" id="k-share-link">' + this.linkback + '</a></li>';
+               o +='</ul>' +
+                       '<div class="source_wrap">'+
+                               '<textarea>' + embed_code + '</textarea>'+
+                       '</div>' +
+                       '<button class="ui-state-default ui-corner-all copycode">' + gM( 'mwe-copy-code' ) + '</button>' +
+                       '<div class="ui-state-highlight ui-corner-all">' + 
+                               gM( 'mwe-read_before_embed' ) + 
                        '</div>';
                $target.html( o );
                $cpBtn = $j( '#' + this.id + ' .copycode' );
@@ -2110,7 +2113,7 @@ embedVideo.prototype = {
        * underling plugin objects are responsible for updating currentTime
        */
        monitor:function() {
-               // js_log(' ct: ' + this.currentTime + ' dur: ' + ( parseInt( this.duration ) + 1 )  + ' is seek: ' + this.seeking );
+               //js_log(' ct: ' + this.currentTime + ' dur: ' + ( parseInt( this.duration ) + 1 )  + ' is seek: ' + this.seeking );
                if ( this.currentTime && this.currentTime > 0 && this.duration ) {
                        if ( !this.userSlide && !this.seeking ) {
                                if ( this.start_offset  ) {
@@ -2562,7 +2565,7 @@ var embedTypes = {
                        }
                         // VLC
                         if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) )
-                                this.players.addPlayer( vlcActiveXPlayer );
+                                this.players.addPlayer( vlcPlayer );
                                 
                         // Java ActiveX
                         if ( this.testActiveX( 'JavaWebStart.isInstalled' ) )
index 0004d0d..fdb515a 100644 (file)
@@ -31,7 +31,7 @@ var htmlEmbed = {
                var ct = new Date();
                this.clockStartTime = ct.getTime();
 
-               // start up monitor:
+               // Start up monitor:
                this.monitor();
        },
        stop:function() {
@@ -44,32 +44,36 @@ var htmlEmbed = {
                var ct = new Date();
                this.pauseTime = this.currentTime;
                js_log( 'pause time: ' + this.pauseTime );
-
+               
                window.clearInterval( this.monitorTimerId );
        },
-       // monitor just needs to keep track of time (do it at frame rate time) .
+       doSeek:function( perc ){
+               this.pauseTime = perc * this.getDuration();
+               this.play();
+       },
+       setCurrentTime:function( perc, callback ){
+               this.pauseTime = perc * this.getDuration();
+               if( callback )
+                       callback();
+       },
+       // Monitor just needs to keep track of time 
        monitor:function() {
-               // js_log('html:monitor: '+ this.currentTime);
+               //js_log('html:monitor: '+ this.currentTime);           
                var ct = new Date();
                this.currentTime = ( ( ct.getTime() - this.clockStartTime ) / 1000 ) + this.pauseTime;
                var ct = new Date();
                // js_log('mvPlayList:monitor trueTime: '+ this.currentTime);
-
-               if ( ! this.monitorTimerId ) {
-                       if ( document.getElementById( this.id ) ) {
-                               if ( !MV_ANIMATION_CB_RATE )
-                                       var MV_ANIMATION_CB_RATE = 33;
-                               this.monitorTimerId = window.setInterval( '$j(\'#' + this.id + '\').get(0).monitor()', 250 );
-                       }
-               }
+               
+               // Once currentTime is updated call parent_monitor
+               this.parent_monitor();
        },
-       // set up minimal media_element emulation:
+       // set up minimal media_element emulation:       
        media_element: {
                autoSelectSource:function() {
                        return true;
                },
                selectedPlayer: {
-                       library:"html"
+                       library : "html"
                },
                selected_source: {
                        URLTimeEncoding:false
@@ -96,47 +100,48 @@ var htmlEmbed = {
                        var font_perc  = ( Math.round( scale_perc * 100 ) < 80 ) ? 80 : Math.round( scale_perc * 100 );
                        var thumb_class = ( typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : '';
                        $j( 'body' ).append( '<div id="' + thumb_render_id + '" style="display:none">' +
-                               '<div class="' + thumb_class + '" ' +
-                               'style="width:' + options.width + 'px;height:' + options.height + 'px;" >' +
-                               this.getThumbnailHTML( {
-                                       'width':  options.width,
-                                       'height': options.height
-                               } ) +
-                               '</div>' +
-                               '</div>'
-                       );
+                                                                       '<div class="' + thumb_class + '" ' +
+                                                                       'style="width:' + options.width + 'px;height:' + options.height + 'px;" >' +
+                                                                                       this.getThumbnailHTML( {
+                                                                                               'width':  options.width,
+                                                                                               'height': options.height
+                                                                                       } ) +
+                                                                       '</div>' +
+                                                               '</div>'
+                                                         );
                        // scale down the fonts:
                        $j( '#' + thumb_render_id + ' *' ).filter( 'span,div,p,h,h1,h2,h3,h4,h5,h6' ).css( 'font-size', font_perc + '%' )
-
+                       
                        // replace out links:
                        $j( '#' + thumb_render_id + ' a' ).each( function() {
                                $j( this ).replaceWith( "<span>" + $j( this ).html() + "</span>" );
                        } );
-
+                       
                        // scale images that have width or height:
                        $j( '#' + thumb_render_id + ' img' ).filter( '[width]' ).each( function() {
                                $j( this ).attr( {
-                                       'width': Math.round( $j( this ).attr( 'width' ) * scale_perc ),
-                                       'height': Math.round( $j( this ).attr( 'height' ) * scale_perc )
-                               } );
+                                               'width': Math.round( $j( this ).attr( 'width' ) * scale_perc ),
+                                               'height': Math.round( $j( this ).attr( 'height' ) * scale_perc )
+                                        }
+                               );
                        } );
                }
                return $j( '#' + thumb_render_id ).html();
        },
-       // nothing to update in static html display: (return a static representation)
+       // nothing to update in static html display: (return a static representation) 
        // @@todo render out a mini text "preview"
        updateThumbTime:function( float_time ) {
                return ;
        },
        getEmbedHTML:function() {
                js_log( 'f:html:getEmbedHTML: ' + this.id );
-               // set up the css for our parent div:
+               // set up the css for our parent div:            
                $j( this ).css( {
                        'width':this.pc.pp.width,
                        'height':this.pc.pp.height,
                        'overflow':"hidden"
                } );
-               // @@todo support more smil animation layout stuff:
+               // @@todo support more smil animation layout stuff: 
 
                // wrap output in videoPlayer_ div:
                $j( this ).html( '<div id="videoPlayer_' + this.id + '">' + this.getThumbnailHTML() + '</div>' );
@@ -167,10 +172,14 @@ var htmlEmbed = {
                this.getEmbedHTML();
        },
        getDuration:function() {
-               if ( this.pc.dur )
-                       return this.pc.dur;
-               // return default value:
-               return pcHtmlEmbedDefaults.dur;
+               if( !this.duration ){
+                       if( this.pc.dur ){
+                               this.duration = this.pc.dur;
+                       }else if( pcHtmlEmbedDefaults.dur ){
+                               this.duration =pcHtmlEmbedDefaults.dur ;
+                       } 
+               }  
+               return this.parent_getDuration(); 
        },
        updateVideoTime:function( start_ntp, end_ntp ) {
                // since we don't really have timeline for html elements just take the delta and set it as the duration
@@ -183,4 +192,4 @@ var htmlEmbed = {
                this.ready_to_play = true;
                return ;
        }
-};
+};
\ No newline at end of file
index b828a7b..4d1f457 100644 (file)
@@ -4,6 +4,7 @@ var nativeEmbed = {
        canPlayThrough:false,
        grab_try_count:0,
        onlyLoadFlag:false,
+       onLoadedCallback : new Array(),
        urlAppend:'',
        prevCurrentTime: -1,
        supports: {
@@ -65,9 +66,11 @@ var nativeEmbed = {
                        js_log( 'could not grab vid obj trying again:' + typeof this.vid );
                        this.grab_try_count++;
                        if (    this.grab_count == 20 ) {
-                               js_log( ' could not get vid object after 10 tries re-run: getEmbedObj()' ) ;
+                               js_log( ' could not get vid object after 20 tries re-run: getEmbedObj() ?' ) ;
                        } else {
-                               setTimeout( '$j(\'#' + this.id + '\').get(0).postEmbedJS()', 200 );
+                               setTimeout( function(){
+                                       _this.postEmbedJS();
+                               }, 200 );
                        }
                }
        },
@@ -77,6 +80,7 @@ var nativeEmbed = {
                this.setStatus( gM( 'mwe-seeking' ) );
        },
        onseeked: function() {
+               js_log("onseeked");
                this.seeking = false;
        },
        doSeek:function( perc ) {
@@ -130,32 +134,30 @@ var nativeEmbed = {
                }
                readyForSeek();
        },
-       setCurrentTime: function( pos, callback ) {
+       setCurrentTime: function( pos, callback ) {     
                var _this = this;
+               js_log( 'native:setCurrentTime::: ' + pos + ' :  dur: ' + _this.getDuration() );
                this.getVID();
                if ( !this.vid ) {
-                       this.load();
-                       var loaded = function( event ) {
-                               js_log( 'native:setCurrentTime (after load): ' + pos + ' :  dur: ' + this.getDuration() );
-                               _this.vid.currentTime = pos;
-                               var once = function( event ) {
-                                       callback();
-                                       _this.vid.removeEventListener( 'seeked', once, false )
-                               };
-                               _this.vid.addEventListener( 'seeked', once, false );
-                               _this.removeEventListener( 'loadedmetadata', loaded, false );
-                       };
-                       _this.addEventListener( 'loadedmetadata', loaded, false );
+                       this.load( function() {                         
+                               _this.doSeekedCb( pos, callback );              
+                       } );
                } else {
-                       // js_log('native:setCurrentTime: ' + pos + ' : '  + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec );
-                       _this.vid.currentTime = pos;
-                       var once = function( event ) {
-                               callback();
-                               _this.vid.removeEventListener( 'seeked', once, false )
-                       };
-                       _this.vid.addEventListener( 'seeked', once, false );
+                       _this.doSeekedCb( pos, callback );              
                }
        },
+       doSeekedCb : function( pos, cb ){
+               var _this = this;                       
+               this.getVID();          
+               var once = function( event ) {
+                       js_log("did seek cb");
+                       cb();
+                       _this.vid.removeEventListener( 'seeked', once, false );
+               };              
+               // Assume we will get to add the Listener before the seek is done
+               _this.vid.currentTime = pos;
+               _this.vid.addEventListener( 'seeked', once, false );                                            
+       },
        monitor : function() {
                this.getVID(); // make sure we have .vid obj
                if ( !this.vid ) {
@@ -170,7 +172,7 @@ var nativeEmbed = {
                                return true;
                }
                
-               // do a seek check (on seeked does not seem fire consistantly)  
+               // Do a seek check (on seeked does not seem fire consistently)  
                if ( this.prevCurrentTime != -1 && this.prevCurrentTime != 0
                        && this.prevCurrentTime < this.currentTime && this.seeking )
                        this.seeking = false;
@@ -196,10 +198,10 @@ var nativeEmbed = {
         * native callbacks for the video tag: 
         */
        oncanplaythrough : function() {
-               // js_log('f:oncanplaythrough');
+               js_log('f:oncanplaythrough');
                this.getVID();
                if ( ! this.paused )
-                       this.vid.play();
+                       this.vid.play();                
        },
        onloadedmetadata: function() {
                this.getVID();
@@ -209,6 +211,10 @@ var nativeEmbed = {
                        js_log( 'updaed duration via native video duration: ' + this.vid.duration )
                        this.duration = this.vid.duration;
                }
+               //fire "onLoaded" flags if set
+               while( this.onLoadedCallback.length ){
+                       this.onLoadedCallback.pop()();
+               }
        },
        onprogress: function( e ) {
                this.bufferedPercent =   e.loaded / e.total;
@@ -270,24 +276,23 @@ var nativeEmbed = {
                if ( this.vid )
                        return this.vid.duration;
        },
-       load:function() {
-               this.getVID();
+       load:function( callback ) {
+               this.getVID();          
                if ( !this.vid ) {
                        // no vid loaded
                        js_log( 'native::load() ... doEmbed' );
                        this.onlyLoadFlag = true;
                        this.doEmbedHTML();
+                       this.onLoadedCallback.push( callback );
                } else {
-                       // won't happen offten
+                       // should not happen offten
                        this.vid.load();
+                       if( callback)
+                               callback();
                }
        },
        // get the embed vlc object 
        getVID : function () {
                this.vid = $j( '#' + this.pid ).get( 0 );
-       },
-       /* 
-        * playlist driver        
-        * mannages native playlist calls                 
-        */
+       }
 };
index d4da1d5..b752407 100644 (file)
@@ -1,14 +1,12 @@
 /*
- * handles driving the firefogg render system 
+ * Handles driving the firefogg render system 
 */
 var mvFirefoggRender = function( iObj ) {
        return this.init( iObj );
 };
 var default_render_options = {
        "videoQuality" : 10,
-       "framerate"     : 30,
-       "width"         : 400,
-       "height"        : 300
+       "framerate"     : 30
 }
 var default_FirefoggRender_options = {
        start_time:0,
@@ -43,14 +41,17 @@ mvFirefoggRender.prototype = {
                this.player = $j( iObj.player_target ).get( 0 );
                this.player_target = iObj.player_target;
                
-               // setup the render options (with defaults) 
-               for ( var i in default_render_options ) {
-                       if ( iObj['render_options'][i] ) {
-                               this.renderOptions[ i ] = iObj['render_options'][i];
-                       } else {
-                               this.renderOptions[ i ] = default_render_options[i];
-                       }
+               // Extend the render options with any provided details
+               if( iObj['render_options'] )
+                       $j.extend(this.renderOptions, iObj['render_options']);
+               
+               // If no height width provided use target DOM width/height
+               if( !this.renderOptions.width && !this.renderOptions.height ){
+                       this.renderOptions.width = $j(this.player_target).width();
+                       this.renderOptions.height = $j(this.player_target).height();    
                }
+               
+               
                // Setup the application options (with defaults) 
                for ( var i in default_FirefoggRender_options ) {
                        if ( iObj[ i ] ) {
@@ -59,7 +60,7 @@ mvFirefoggRender.prototype = {
                                this[ i ] = default_FirefoggRender_options[i];
                        }
                }
-               // Set up targets and local vars                
+               // Should be exteranlly controlled              
                if ( iObj.target_startRender ) {
                        $j( iObj.target_startRender ).click( function() {
                                js_log( "Start render" );
@@ -84,7 +85,7 @@ mvFirefoggRender.prototype = {
                var interval =  1 / this.renderOptions.framerate
                
                // issue a load request on the player:
-               this.player.load();
+               //this.player.load();
                
                // init the Render
                this.fogg.initRender(  JSON.stringify( _this.renderOptions ), 'foggRender' );
@@ -92,7 +93,7 @@ mvFirefoggRender.prototype = {
                // add audio if we had any:
 
                // request a target (should support rendering to temp location too) 
-               this.fogg.saveVideoAs();
+               //this.fogg.saveVideoAs();
                
                // set the continue rendering flag to true:
                this.continue_rendering = true;
@@ -101,17 +102,18 @@ mvFirefoggRender.prototype = {
                var doNextFrame = function() {
                        $j( _this.target_timeStatus ).val( " on " + ( Math.round( t * 10 ) / 10 ) + " of " +
                                ( Math.round( _this.player.getDuration() * 10 ) / 10 ) );
-                       _this.player.setCurrentTime( t, function() {
-                               _this.fogg.addFrame( $j( _this.player_target ).attr( 'id' ) );
-                               t += interval;
+                       _this.player.setCurrentTime( t, function() {                                                            
+                               //_this.fogg.addFrame( $j( _this.player_target ).attr( 'id' ) );
+                               t += interval;                          
                                if ( t >= _this.player.getDuration() ) {
                                        _this.doFinalRender();
                                } else {
                                        if ( _this.continue_rendering ) {
                                                doNextFrame();
                                        } else {
+                                               js_log('done with render');
                                                // else quit:
-                                               _this.doFinalRender();
+                                               //_this.doFinalRender();
                                        }
                                }
                        } );
index 100fbff..12472a9 100644 (file)
@@ -448,6 +448,7 @@ mvPlayList.prototype = {
                                                
                // update the title and status bar
                this.updateBaseStatus();
+               this.doSmilActions( true );
        },
        setupClipDisplay:function() {
                js_log( 'mvPlaylist:setupClipDisplay:: clip len:' + this.default_track.clips.length );
@@ -516,7 +517,7 @@ mvPlayList.prototype = {
                this.cur_clip.embed.seek_time_sec = ( float_sec - pl_sum_time );
                
                // render effects ontop: (handled by doSmilActions)             
-               this.doSmilActions( single_line = true );
+               this.doSmilActions( true );
        },
        updateBaseStatus:function() {
                var _this = this;
@@ -547,10 +548,10 @@ mvPlayList.prototype = {
        setStatus:function( value ) {
                $j( '#' + this.id + ' .time-disp' ).text( value );
        },
-       setSliderValue:function( value ) {
+       setSliderValue:function( value ) {              
                // slider is on 1000 scale: 
                var val = parseInt( value * 1000 );
-               js_log( 'update slider: #' + this.id + ' .play_head to ' + val );
+               //js_log( 'update slider: #' + this.id + ' .play_head to ' + val );
                $j( '#' + this.id + ' .play_head' ).slider( 'value', val );
        },
        getPlayHeadPos: function( prec_done ) {
@@ -645,36 +646,47 @@ mvPlayList.prototype = {
                this.cur_clip.embed.stop();
                
                this.updateCurrentClip( next_clip );
-                               
+               //if part of a transition should continue playing where it left off     
                this.cur_clip.embed.play();
        },
        onClipDone:function() {
                js_log( "pl onClipDone" );
                this.cur_clip.embed.stop();
        },
-       updateCurrentClip:function( new_clip ) {
+       updateCurrentClip : function( new_clip , into_perc) {
                js_log( 'f:updateCurrentClip:' + new_clip.id );
-               // make sure we are not switching to the current
-               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 ) {
+                       // make sure we are not switching to the current
+                       if ( this.cur_clip.id == new_clip.id ) {
+                               js_log( 'trying to updateCurrentClip to same clip' );
+                               return false;
+                       }
+                       
                        if ( !this.cur_clip.embed.isStoped() )
                                 this.cur_clip.embed.stop();
                        this.activeClipList.remove( this.cur_clip )
-               }
-                                               
-               this.activeClipList.add( new_clip );
-                               
+                       
+                       //hide the current clip
+                       $j( '#clipDesc_' + this.cur_clip.id ).hide();
+               }                                               
+               this.activeClipList.add( new_clip );                            
                // do swap:             
-               $j( '#clipDesc_' + this.cur_clip.id ).hide();
                this.cur_clip = new_clip;
                $j( '#clipDesc_' + this.cur_clip.id ).show();
-               // update the playhead: 
-               this.setSliderValue( this.cur_clip.dur_offset / this.getDuration() );
+               
+               // Update the playhead:
+               if( this.controls ){
+                       // Check if we have into_perc 
+                       if( into_perc ){
+                               var clip_time =  this.cur_clip.dur_offset + ( into_perc * this.cur_clip.getDuration() );
+                       }else{
+                               var clip_time =  this.cur_clip.dur_offset;
+                       }
+                               
+                       this.setSliderValue( clip_time / this.getDuration() );
+               }
        },
        playPrev: function() {
                // advance the playhead to the previous clip                    
@@ -754,6 +766,7 @@ mvPlayList.prototype = {
         */
        load:function() {
                // do nothing right now)
+               alert('load pl');               
        },
        toggleMute:function() {
                this.cur_clip.embed.toggleMute();
@@ -846,8 +859,43 @@ mvPlayList.prototype = {
        doSeek:function( v ) {
                js_log( 'pl:doSeek:' + v + ' sts:' + this.seek_time_sec );
                var _this = this;
-               var prevClip = null;
                
+               var time = v * this.getDuration()
+               _this.currentTime = time;
+               var relative_perc = _this.updateClipByTime();
+               
+               // Update the clip relative seek_time_sec
+               _this.cur_clip.embed.doSeek( relative_perc );
+               _this.monitor();
+               
+               return '';
+       },
+       setCurrentTime: function( time, callback ) {
+               js_log( 'pl:setCurrentTime:' + time );
+               var _this = this;
+               _this.currentTime = time;
+               
+               var pl_perc =  time / this.getDuration();
+               var relative_perc = _this.updateClipByTime();   
+               var clip_time = relative_perc * _this.cur_clip.embed.getDuration();             
+               _this.cur_clip.embed.setCurrentTime( clip_time, function() {
+                       //update the smil actions: 
+                       _this.doSmilActions( true );
+                       //say we are "ready"
+                       if ( callback )
+                               callback();
+               } );                                    
+       },
+       /*
+       * updateClipByTime::
+       *
+       * @returns the relative offsets of the current clip (given the playlist time) 
+       */
+       updateClipByTime: function(){
+               var _this = this;
+               var prevClip = null;
+               //set the current percent done: 
+               var pt = this.currentTime / _this.getDuration();
                // jump to the clip in the current percent. 
                var perc_offset = 0;
                var next_perc_offset = 0;
@@ -855,47 +903,16 @@ mvPlayList.prototype = {
                        var clip = _this.default_track.clips[i];
                        next_perc_offset += ( clip.getDuration() /  _this.getDuration() ) ;
                        // js_log('on ' + clip.getDuration() +' next_perc_offset:'+ next_perc_offset);
-                       if ( next_perc_offset > v ) {
-                               // pass along the relative percentage to embed object:                           
-                               // js_log('seek:'+ v +' - '+perc_offset + ') /  (' + next_perc_offset +' - '+ perc_offset);
-                               var relative_perc =  ( v - perc_offset ) /  ( next_perc_offset - perc_offset );
+                       if ( next_perc_offset > pt ) {           
+                               // js_log('seek:'+ pt +' - '+perc_offset + ') /  (' + next_perc_offset +' - '+ perc_offset);
+                               var relative_perc =  ( pt - perc_offset ) /  ( next_perc_offset - perc_offset );
                                // update the current clip:                                                              
-                               _this.updateCurrentClip( clip );
-                               
-                               // update the clip relative seek_time_sec
-                               _this.cur_clip.embed.doSeek( relative_perc );
-                               this.play();
-                               return '';
+                               _this.updateCurrentClip( clip, relative_perc );
+                               return relative_perc;
                        }
                        perc_offset = next_perc_offset;
                }
-       },
-       setCurrentTime: function( pos, callback ) {
-               js_log( 'pl:setCurrentTime:' + pos + ' sts:' + this.seek_time_sec );
-               var _this = this;
-               var prevClip = null;
-               
-               // jump to the clip at pos 
-               var currentOffset = 0;
-               var nextTime = 0;
-               for ( var i in _this.default_track.clips ) {
-                       var clip = _this.default_track.clips[i];
-                       nextTime = clip.getDuration();
-                       if ( currentOffset + nextTime > pos ) {
-                               // update the clip relative seek_time_sec
-                               clipTime = pos - currentOffset;
-                               if ( _this.cur_clip.id != clip.id ) {
-                                       _this.updateCurrentClip( clip );
-                               }
-                               _this.cur_clip.embed.setCurrentTime( clipTime, function() {
-                                       if ( callback )
-                                               callback();
-                               } );
-                               _this.currentTime = pos;
-                               _this.doSmilActions();
-                       }
-                       currentOffset += nextTime;
-               }
+               return 0;
        },
        // gets playlist controls large control height for sporting 
        // next prev button and more status display
@@ -1106,8 +1123,6 @@ mvClip.prototype = {
        // setup the embed object:
        setUpEmbedObj:function() {
                js_log( 'mvClip:setUpEmbedObj()' );
-               // init:                
-
                
                this.embed = null;
                // js_log('setup embed for clip '+ this.id + ':id is a function?'); 
@@ -1126,7 +1141,9 @@ mvClip.prototype = {
                // if(this.pp.sequencer=='true'){
                init_pl_embed.embed_link = null;
                init_pl_embed.linkback = null;
-                       
+               
+               if( this.durationHint )
+                       init_pl_embed.durationHint =  this.durationHint;
                
                if ( this.poster )init_pl_embed['thumbnail'] = this.poster;
                
@@ -1345,8 +1362,8 @@ PlMvEmbed.prototype = {
                // status updates handled by playlist obj
        },
        setSliderValue:function( value ) {
-               js_log( 'PlMvEmbed:setSliderValue:' + value );
-               // setSlider value handled by playlist obj      
+               //js_log( 'PlMvEmbed:setSliderValue:' + value );
+               // setSlider value handled by playlist obj              
        }
 }
 
@@ -1550,7 +1567,10 @@ mvPlayList.prototype.doSmilActions = function( single_frame ) {
        // update/setup all transitions (will render current transition state)  
        var in_range = false;
        // pretty similar actions per transition types so group into a loop:
-       var tran_types = { 'transIn':true, 'transOut':true };
+       var tran_types = { 
+               'transIn' : true, 
+               'transOut':true 
+       };
        for ( var tid in tran_types ) {
                eval( 'var tObj =  _clip.' + tid );
                if ( !tObj )
@@ -1675,11 +1695,11 @@ var mvTransLib = {
                return overlay_selector_id;
        },
        doUpdate:function( tObj, percent ) {
-               // init the transition if nessesary:
+               // init the transition if necessary:
                if ( !tObj.overlay_selector_id )
                        this.doInitTransition( tObj );
                
-               // @@todo we should ensure visability outside of doUpate loop                   
+               // @@todo we should ensure viability outside of doUpate loop                    
                if ( !$j( '#' + tObj.overlay_selector_id ).is( ':visible' ) )
                        $j( '#' + tObj.overlay_selector_id ).show();
                        
@@ -1946,16 +1966,16 @@ var smilPlaylist = {
        },
        tryAddMedia:function( mediaElement, order, track_id ) {
                js_log( 'SMIL:tryAddMedia:' + mediaElement );
+
                var _this = this;
                // set up basic mvSMILClip send it the mediaElemnt & mvClip init: 
                var clipObj = { };
                var cConfig = {
-                                               "id":'p_' + _this.id + '_c_' + order,
-                                               "pp":this, // set the parent playlist object pointer
-                                               "order": order
+                                               "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;
@@ -2049,6 +2069,7 @@ mvSMILClip.prototype = {
                // parse duration / begin times: 
                if ( this.dur )
                        this.dur = smilParseTime( this.dur );
+                       
                // parse the media duration hint ( the source media length) 
                if ( this.durationHint )
                        this.durationHint = smilParseTime( this.durationHint );
index 062019c..28c8e82 100644 (file)
@@ -232,7 +232,7 @@ var global_req_cb = new Array(); // The global request callback array
                for ( var i in msgSet ) {
                        gMsg[ i ] = msgSet[i];
                }
-       },
+       }
 
        /**
        * loadRS function
@@ -1227,6 +1227,10 @@ function mwdomReady( force ) {
                        for ( var k in e[j] ) {
                                if ( e[j][k] && typeof( e[j][k] ) == 'object' ) {
                                        var     sn = e[j][k].getAttribute( 'class' );
+                                       // Try "className" for good ol IE                               
+                                       if(!sn){
+                                               var     sn = e[j][k].getAttribute( 'className' );
+                                       }                                       
                                        if ( sn && sn != '' ) {
                                                for ( var n = 0; n < mw.valid_skins.length; n++ ) {
                                                        if ( sn.indexOf( mw.valid_skins[n] ) !== -1 ) {
@@ -1526,6 +1530,7 @@ function mv_jqueryBindings() {
                $.fn.firefoggRender = function( iObj, callback ) {
                        // Check if we already have render loaded then just pass on updates/actions
                        var sElm = $j( this.selector ).get( 0 );
+                       //add a special attribute to the selector: 
                        if ( sElm['fogg_render'] ) {
                                if ( sElm['fogg_render'] == 'loading' ) {
                                        js_log( "Error: called firefoggRender while loading" );
@@ -1540,6 +1545,7 @@ function mv_jqueryBindings() {
                                'mvFirefogg',
                                'mvFirefoggRender'
                        ], function() {
+                               // Attach the firefoggRender obj to the selected elm: 
                                sElm['fogg_render'] = new mvFirefoggRender( iObj );
                                if ( callback && typeof callback == 'function' )
                                        callback( sElm['fogg_render'] );
@@ -1602,7 +1608,7 @@ function mv_jqueryBindings() {
                                'position':'absolute',
                                'left':'0px',
                                'right':'0px',
-                               'bottom':'0px',
+                               'bottom':'0px'
                        } );
                }
                
@@ -1733,8 +1739,8 @@ function npt2seconds( npt_str ) {
                // js_log('npt2seconds:not valid ntp:'+ntp);
                return false;
        }
-       // Strip "npt:" time definition if present
-       npt_str = npt_str.replace( 'npt:', '' );
+       // Strip {npt:}01:02:20 or 32{s} from time  if present
+       npt_str = npt_str.replace( /npt:|s/g, '' );
 
        var hour = 0;
        var min = 0;
index d775746..9f85bea 100644 (file)
@@ -54,14 +54,15 @@ ctrlBuilder.prototype = {
                js_log( 'f:controlsBuilder:: opt:' + this.options );
                this.id = ( embedObj.pc ) ? embedObj.pc.pp.id:embedObj.id;
                this.available_width = embedObj.playerPixelWidth();
-               // make pointer to the embedObj
+               
+               // Make pointer to the embedObj
                this.embedObj = embedObj;
                var _this = this;
                for ( var i in embedObj.supports ) {
                        _this.supports[i] = embedObj.supports[i];
                };
 
-               // special case vars:
+               // Special case vars:
                if ( ( embedObj.roe ||
                          embedObj.wikiTitleKey ||
                                ( embedObj.media_element.timedTextSources &&
@@ -70,7 +71,7 @@ ctrlBuilder.prototype = {
                        this.supports['closed_captions'] = true;
 
 
-               // append options to body (if not already there)
+               // Append options to body (if not already there)
                if ( _this.body_options && $j( '#mv_vid_options_' + this.id ).length == 0 )
                        $j( 'body' ).append( this.components['mv_embedded_options'].o( this ) );
 
@@ -78,7 +79,7 @@ ctrlBuilder.prototype = {
                for ( var i in this.components ) {
                        if ( this.supports[i] ) {
                                if ( this.available_width > this.components[i].w ) {
-                                       // special case with playhead don't add unless we have 60px
+                                       // Special case with playhead don't add unless we have 60px
                                        if ( i == 'play_head' && this.available_width < 60 )
                                                continue;
                                        o += this.components[i].o( this  );
@@ -105,13 +106,8 @@ ctrlBuilder.prototype = {
                
                
                // add play hook:
-               $tp.find( '.play-btn' ).unbind().btnBind().click( function() {
-                       $j( '#' + embedObj.id ).get( 0 ).play();
-               } )
-
-               // do play-btn-large binding:
-               $tp.find( '.play-btn-large' ).unbind().btnBind().click( function() {
-                       $j( '#' + embedObj.id ).get( 0 ).play();
+               $tp.find( '.play-btn,.play-btn-large' ).unbind().btnBind().click( function() {
+                       embedObj.play();
                } );
 
                // add recommend firefox if we have non-native playback:
@@ -158,17 +154,17 @@ ctrlBuilder.prototype = {
 
                // captions binding:
                $tp.find( '.timed-text' ).unbind().btnBind().click( function() {
-                       $j( '#' + embedObj.id ).get( 0 ).showTextInterface();
+                       embedObj.showTextInterface();
                } );
 
                // options binding:
                $tp.find( '.options-btn' ).unbind().btnBind().click( function() {
-                       $j( '#' + embedObj.id ).get( 0 ).doOptionsHTML();
+                       embedObj.doOptionsHTML();
                } );
 
                // fullscreen binding:
                $tp.find( '.fullscreen-btn' ).unbind().btnBind().click( function() {
-                       $j( '#' + embedObj.id ).get( 0 ).fullscreen();
+                       embedObj.fullscreen();
                } );
 
                js_log( " should add slider binding: " + $tp.find( '.play_head' ).length );
@@ -181,7 +177,7 @@ ctrlBuilder.prototype = {
                                var id = ( embedObj.pc != null ) ? embedObj.pc.pp.id:embedObj.id;
                                embedObj.userSlide = true;
                                $j( id + ' .play-btn-large' ).fadeOut( 'fast' );
-                               // if playlist always start at 0
+                               // If playlist always start at 0
                                embedObj.start_time_sec = ( embedObj.instanceOf == 'mvPlayList' ) ? 0:
                                                                npt2seconds( embedObj.getTimeReq().split( '/' )[0] );
                        },
@@ -194,13 +190,14 @@ ctrlBuilder.prototype = {
                                } else {
                                        embedObj.setStatus( embedObj.jump_time );
                                }
-                               // update the thumbnail / frame
+                               // Update the thumbnail / frame
                                if ( embedObj.isPlaying == false ) {
                                        embedObj.updateThumbPerc( perc );
                                }
                        },
                        change:function( event, ui ) {
-                               // only run the onChange event if done by a user slide:
+                               // only run the onChange event if done by a user slide 
+                               // (otherwise it runs times it should not)
                                if ( embedObj.userSlide ) {
                                        embedObj.userSlide = false;
                                        embedObj.seeking = true;
index 02e1a70..48f4924 100644 (file)
@@ -5,7 +5,7 @@
  
 var urlparts = getRemoteEmbedPath();
 var mwEmbedHostPath = urlparts[0];
-var mwRemoteVersion = '1.07';
+var mwRemoteVersion = '1.08';
 var mwUseScriptLoader = true;
 
 // setup up request Params: