зеркало из https://github.com/mozilla/popcorn-js.git
Fix smpte support regression, add test.
This commit is contained in:
Родитель
607b33dc92
Коммит
08e9d837ab
16
popcorn.js
16
popcorn.js
|
@ -547,7 +547,21 @@
|
|||
// Attach an event to a single point in time
|
||||
exec: function( id, time, fn ) {
|
||||
var length = arguments.length,
|
||||
trackEvent;
|
||||
trackEvent, sec;
|
||||
|
||||
// Check if first could possibly be a SMPTE string
|
||||
// p.cue( "smpte string", fn );
|
||||
// try/catch avoid awful throw in Popcorn.util.toSeconds
|
||||
// TODO: Get rid of that, replace with NaN return?
|
||||
try {
|
||||
sec = Popcorn.util.toSeconds( id );
|
||||
} catch ( e ) {}
|
||||
|
||||
// If it can be converted into a number then
|
||||
// it's safe to assume that the string was SMPTE
|
||||
if ( typeof sec === "number" ) {
|
||||
id = sec;
|
||||
}
|
||||
|
||||
// Shift arguments based on use case
|
||||
//
|
||||
|
|
|
@ -894,13 +894,14 @@ test( "roundTime", function() {
|
|||
|
||||
test( "exec", function() {
|
||||
|
||||
QUnit.reset();
|
||||
|
||||
var popped = Popcorn( "#video" ),
|
||||
expects = 2,
|
||||
expects = 3,
|
||||
count = 0,
|
||||
hasLooped = false,
|
||||
loop = 0;
|
||||
loop = 0,
|
||||
flags = {
|
||||
looped: false,
|
||||
smpte: false
|
||||
};
|
||||
|
||||
expect( expects + 1 );
|
||||
|
||||
|
@ -909,7 +910,7 @@ test( "exec", function() {
|
|||
|
||||
setTimeout(function() {
|
||||
|
||||
equal( loop, expects, "cue callback repeat check, only called twice" );
|
||||
equal( loop, 2, "cue callback repeat check, only called twice" );
|
||||
Popcorn.removePlugin( popped, "cue" );
|
||||
popped.destroy();
|
||||
start();
|
||||
|
@ -919,17 +920,25 @@ test( "exec", function() {
|
|||
|
||||
stop();
|
||||
|
||||
// Supports SMPTE
|
||||
popped.cue( "00:00:04", function() {
|
||||
if ( !flags.smpte ) {
|
||||
flags.smpte = true;
|
||||
ok( true, "cue supports SMPTE" );
|
||||
plus();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
popped.cue( 4, function() {
|
||||
ok( loop < 2, "cue callback fired " + ++loop );
|
||||
plus();
|
||||
|
||||
if ( !hasLooped ) {
|
||||
|
||||
popped.currentTime( 3 ).play();
|
||||
|
||||
hasLooped = true;
|
||||
if ( !flags.looped ) {
|
||||
flags.looped = true;
|
||||
popped.play( 3 );
|
||||
}
|
||||
}).currentTime( 3 ).play();
|
||||
}).play( 3 );
|
||||
});
|
||||
|
||||
test( "cue: alias of exec", function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче