]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
merged timeupdate fix in to develop
authorScottDowne <sdowne@learn.senecac.on.ca>
Thu, 25 Aug 2011 19:23:27 +0000 (15:23 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Thu, 25 Aug 2011 19:23:27 +0000 (15:23 -0400)
1  2 
popcorn.js

diff --cc popcorn.js
index 8a75c5069e733965af0a391ade856a8a91102b0f,54592f83dbf76ab3a0deac10efcaf8eb31833159..7dad7447f0f083af1c67b56bcd1e203f84d7f43a
            });
  
            that.media.addEventListener( "timeupdate", function( event ) {
-             var currentTime    = this.currentTime,
-                 previousTime   = that.data.trackEvents.previousUpdateTime,
-                 tracks         = that.data.trackEvents,
-                 tracksByEnd    = tracks.byEnd,
-                 tracksByStart  = tracks.byStart;
- 
-             //  Playbar advancing
-             if ( previousTime < currentTime ) {
- 
-               while ( tracksByEnd[ tracks.endIndex ] && tracksByEnd[ tracks.endIndex ].end <= currentTime ) {
-                 //  If plugin does not exist on this instance, remove it
-                 if ( !tracksByEnd[ tracks.endIndex ]._natives ||
-                     ( !!Popcorn.registryByName[ tracksByEnd[ tracks.endIndex ]._natives.type ] ||
-                       !!that[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) ) {
- 
-                   if ( tracksByEnd[ tracks.endIndex ]._running === true ) {
-                     tracksByEnd[ tracks.endIndex ]._running = false;
-                     tracksByEnd[ tracks.endIndex ]._natives.end.call( that, event, tracksByEnd[ tracks.endIndex ] );
-                   }
-                   tracks.endIndex++;
-                 } else {
-                   // remove track event
-                   Popcorn.removeTrackEvent( that, tracksByEnd[ tracks.endIndex ]._id );
-                   return;
-                 }
-               }
- 
-               while ( tracksByStart[ tracks.startIndex ] && tracksByStart[ tracks.startIndex ].start <= currentTime ) {
-                 //  If plugin does not exist on this instance, remove it
-                 if ( !tracksByStart[ tracks.startIndex ]._natives ||
-                   ( !!Popcorn.registryByName[ tracksByStart[ tracks.startIndex ]._natives.type ] ||
-                     !!that[ tracksByStart[ tracks.startIndex ]._natives.type ] ) ) {
- 
-                   if ( tracksByStart[ tracks.startIndex ].end > currentTime &&
-                         tracksByStart[ tracks.startIndex ]._running === false &&
-                           that.data.disabled.indexOf( tracksByStart[ tracks.startIndex ]._natives.type ) === -1 ) {
- 
-                     tracksByStart[ tracks.startIndex ]._running = true;
-                     tracksByStart[ tracks.startIndex ]._natives.start.call( that, event, tracksByStart[ tracks.startIndex ] );
-                   }
-                   tracks.startIndex++;
-                 } else {
-                   // remove track event
-                   Popcorn.removeTrackEvent( that, tracksByStart[ tracks.startIndex ]._id );
-                   return;
-                 }
-               }
- 
-             // Playbar receding
-             } else if ( previousTime > currentTime ) {
- 
-               while ( tracksByStart[ tracks.startIndex ] && tracksByStart[ tracks.startIndex ].start > currentTime ) {
-                 // if plugin does not exist on this instance, remove it
-                 if ( !tracksByStart[ tracks.startIndex ]._natives ||
-                   ( !!Popcorn.registryByName[ tracksByStart[ tracks.startIndex ]._natives.type ] ||
-                     !!that[ tracksByStart[ tracks.startIndex ]._natives.type ] ) ) {
- 
-                   if ( tracksByStart[ tracks.startIndex ]._running === true ) {
-                     tracksByStart[ tracks.startIndex ]._running = false;
-                     tracksByStart[ tracks.startIndex ]._natives.end.call( that, event, tracksByStart[ tracks.startIndex ] );
-                   }
-                   tracks.startIndex--;
-                 } else {
-                   // remove track event
-                   Popcorn.removeTrackEvent( that, tracksByStart[ tracks.startIndex ]._id );
-                   return;
-                 }
-               }
- 
-               while ( tracksByEnd[ tracks.endIndex ] && tracksByEnd[ tracks.endIndex ].end > currentTime ) {
-                 // if plugin does not exist on this instance, remove it
-                 if ( !tracksByEnd[ tracks.endIndex ]._natives ||
-                   ( !!Popcorn.registryByName[ tracksByEnd[ tracks.endIndex ]._natives.type ] ||
-                     !!that[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) ) {
- 
-                   if ( tracksByEnd[ tracks.endIndex ].start <= currentTime &&
-                         tracksByEnd[ tracks.endIndex ]._running === false  &&
-                           that.data.disabled.indexOf( tracksByEnd[ tracks.endIndex ]._natives.type ) === -1 ) {
- 
-                     tracksByEnd[ tracks.endIndex ]._running = true;
-                     tracksByEnd[ tracks.endIndex ]._natives.start.call( that, event, tracksByEnd[tracks.endIndex] );
-                   }
-                   tracks.endIndex--;
-                 } else {
-                   // remove track event
-                   Popcorn.removeTrackEvent( that, tracksByEnd[ tracks.endIndex ]._id );
-                   return;
-                 }
-               }
-             }
- 
-             tracks.previousUpdateTime = currentTime;
- 
 +
+             Popcorn.timeUpdate( that, event );
            }, false );
          } else {
            global.setTimeout(function() {
      return obj.data.history[ obj.data.history.length - 1 ];
    };
  
 -        if ( !tracksByEnd[ tracks.endIndex ]._natives || !!obj[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) {
+   Popcorn.timeUpdate = function( obj, event ) {
+ 
+     var currentTime    = obj.media.currentTime,
+         previousTime   = obj.data.trackEvents.previousUpdateTime,
+         tracks         = obj.data.trackEvents,
+         tracksByEnd    = tracks.byEnd,
+         tracksByStart  = tracks.byStart;
+ 
+     //  Playbar advancing
+     if ( previousTime < currentTime ) {
+ 
+       while ( tracksByEnd[ tracks.endIndex ] && tracksByEnd[ tracks.endIndex ].end <= currentTime ) {
+         //  If plugin does not exist on this instance, remove it
 -        if ( !tracksByStart[ tracks.startIndex ]._natives || !!obj[ tracksByStart[ tracks.startIndex ]._natives.type ] ) {
++        if ( !tracksByEnd[ tracks.endIndex ]._natives ||
++            ( !!Popcorn.registryByName[ tracksByEnd[ tracks.endIndex ]._natives.type ] ||
++              !!obj[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) ) {
++
+           if ( tracksByEnd[ tracks.endIndex ]._running === true ) {
+             tracksByEnd[ tracks.endIndex ]._running = false;
+             tracksByEnd[ tracks.endIndex ]._natives.end.call( obj, event, tracksByEnd[ tracks.endIndex ] );
+           }
+           tracks.endIndex++;
+         } else {
+           // remove track event
+           Popcorn.removeTrackEvent( obj, tracksByEnd[ tracks.endIndex ]._id );
+           return;
+         }
+       }
+ 
+       while ( tracksByStart[ tracks.startIndex ] && tracksByStart[ tracks.startIndex ].start <= currentTime ) {
+         //  If plugin does not exist on this instance, remove it
 -      } 
++        if ( !tracksByStart[ tracks.startIndex ]._natives ||
++          ( !!Popcorn.registryByName[ tracksByStart[ tracks.startIndex ]._natives.type ] ||
++            !!obj[ tracksByStart[ tracks.startIndex ]._natives.type ] ) ) {
++
+           if ( tracksByStart[ tracks.startIndex ].end > currentTime &&
+                 tracksByStart[ tracks.startIndex ]._running === false &&
+                   obj.data.disabled.indexOf( tracksByStart[ tracks.startIndex ]._natives.type ) === -1 ) {
+ 
+             tracksByStart[ tracks.startIndex ]._running = true;
+             tracksByStart[ tracks.startIndex ]._natives.start.call( obj, event, tracksByStart[ tracks.startIndex ] );
+           }
+           tracks.startIndex++;
+         } else {
+           // remove track event
+           Popcorn.removeTrackEvent( obj, tracksByStart[ tracks.startIndex ]._id );
+           return;
+         }
 -        if ( !tracksByStart[ tracks.startIndex ]._natives || !!obj[ tracksByStart[ tracks.startIndex ]._natives.type ] ) {
++      }
++
+     // Playbar receding
+     } else if ( previousTime > currentTime ) {
+ 
+       while ( tracksByStart[ tracks.startIndex ] && tracksByStart[ tracks.startIndex ].start > currentTime ) {
+         // if plugin does not exist on this instance, remove it
 -        if ( !tracksByEnd[ tracks.endIndex ]._natives || !!obj[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) {
++        if ( !tracksByStart[ tracks.startIndex ]._natives ||
++          ( !!Popcorn.registryByName[ tracksByStart[ tracks.startIndex ]._natives.type ] ||
++            !!obj[ tracksByStart[ tracks.startIndex ]._natives.type ] ) ) {
++
+           if ( tracksByStart[ tracks.startIndex ]._running === true ) {
+             tracksByStart[ tracks.startIndex ]._running = false;
+             tracksByStart[ tracks.startIndex ]._natives.end.call( obj, event, tracksByStart[ tracks.startIndex ] );
+           }
+           tracks.startIndex--;
+         } else {
+           // remove track event
+           Popcorn.removeTrackEvent( obj, tracksByStart[ tracks.startIndex ]._id );
+           return;
+         }
+       }
+ 
+       while ( tracksByEnd[ tracks.endIndex ] && tracksByEnd[ tracks.endIndex ].end > currentTime ) {
+         // if plugin does not exist on this instance, remove it
 -        } 
++        if ( !tracksByEnd[ tracks.endIndex ]._natives ||
++          ( !!Popcorn.registryByName[ tracksByEnd[ tracks.endIndex ]._natives.type ] ||
++            !!obj[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) ) {
++
+           if ( tracksByEnd[ tracks.endIndex ].start <= currentTime &&
+                 tracksByEnd[ tracks.endIndex ]._running === false  &&
+                   obj.data.disabled.indexOf( tracksByEnd[ tracks.endIndex ]._natives.type ) === -1 ) {
+ 
+             tracksByEnd[ tracks.endIndex ]._running = true;
+             tracksByEnd[ tracks.endIndex ]._natives.start.call( obj, event, tracksByEnd[tracks.endIndex] );
+           }
+           tracks.endIndex--;
+         } else {
+           // remove track event
+           Popcorn.removeTrackEvent( obj, tracksByEnd[ tracks.endIndex ]._id );
+           return;
++        }
+       }
+     // time bar is not moving ( video is paused )
+     }
+ 
+     tracks.previousUpdateTime = currentTime;
+ 
+   };
+ 
    //  Map and Extend TrackEvent functions to all Popcorn instances
    Popcorn.extend( Popcorn.p, {