popcornjs addtrackevent (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="//popcornjs.org/code/dist/popcorn.js"></script>

<video id="subject" src="http://dl.dropbox.com/u/3531958/snowdriving.ogv"></video>
<script>
  Popcorn.addTrackEventAlt = function(obj, track) {
   var startDone = false,
       endDone = false;
  
   if (track._natives) {
    //  Supports user defined track event id
    track._id = !track.id ? Popcorn.guid(track._natives.type) : track.id;
  
    //  Push track event ids into the history
    obj.data.history.push(track._id);
  
    track._natives.start = track._natives.start || Popcorn.nop;
    track._natives.end = track._natives.end || Popcorn.nop;
   }
  
   track.start = Popcorn.util.toSeconds(track.start, obj.options.framerate);
   track.end = Popcorn.util.toSeconds(track.end, obj.options.framerate);
  
   //  Store this definition in an array sorted by times
  
   //obj.data.trackEvents.byStart.push(track);
   //obj.data.trackEvents.byEnd.push(track);
   //obj.data.trackEvents.byStart.sort(function(a, b) {
   // return (a.start - b.start);
   //});
   //obj.data.trackEvents.byEnd.sort(function(a, b) {
   // return (a.end - b.end);
   //});
  };
  
  Popcorn.prototype.execAlt = function(time, fn) {
  
   //  Creating a one second track event with an empty end
   Popcorn.addTrackEventAlt(this, {
    start: time,
    end: time + 1,
    _running: false,
    _natives: {
     start: fn || Popcorn.nop,
     end: Popcorn.nop,
     type: "exec"
    }
   });
  
   return this;
  };
  
  var $current = Popcorn("#subject")
  $alt = Popcorn("#subject");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
current
$current.exec(1, Popcorn.nop);
ready
alt
$alt.execAlt(1, Popcorn.nop);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.