From fee82a1d84205675cf4bf3ba43d6d09ce02dfca5 Mon Sep 17 00:00:00 2001 From: David Seifried Date: Tue, 6 Sep 2011 14:47:19 -0400 Subject: [PATCH] Implemented a fix for if the previousTime === currentTime in the timeUpdate function, also added in functionality to imediately call timeUpdate when a trackEvent is added --- popcorn.js | 4 +++- test/popcorn.unit.js | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/popcorn.js b/popcorn.js index 51659a7..9f6b091 100644 --- a/popcorn.js +++ b/popcorn.js @@ -755,6 +755,8 @@ break; } } + + this.timeUpdate( obj, null ); // Store references to user added trackevents in ref table if ( track._id ) { @@ -882,7 +884,7 @@ tracksByStart = tracks.byStart; // Playbar advancing - if ( previousTime < currentTime ) { + if ( previousTime <= currentTime ) { while ( tracksByEnd[ tracks.endIndex ] && tracksByEnd[ tracks.endIndex ].end <= currentTime ) { // If plugin does not exist on this instance, remove it diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 605922a..1fecb60 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -2538,6 +2538,30 @@ test("getTrackEvent", function () { }); +test("timeUpdate functionality", function() { + + var $pop = Popcorn( "#video" ), + count = 0, + expects = 5; + + expect( expects ); + + function plus() { + if ( ++count === expects ) { + start(); + + Popcorn.removeInstance( $pop ); + } + } + + Popcorn.plugin("timeUpdateTester", function() { + return { + start: function(){}, + end: function(){} + }; + }); +}); + test("Index Integrity", function () { -- 2.43.0