Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 35 36 #41

Merged
merged 4 commits into from May 17, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions popcorn.sequence.js
Expand Up @@ -323,7 +323,13 @@

play: function() {

this.playlist[ this.active ].play();
if ( ( ( this.queue.length - 1 ) === this.active ) &&
( this.inOuts[ "ofVideos" ][ this.active ][ "out" ] >= Math.round( this.queue[ this.active ].currentTime ) ) )
{
this.jumpTo( 0 );
} else {
this.queue[ this.active ].play();
}

return this;
},
Expand Down Expand Up @@ -451,7 +457,7 @@
return currentTime;
},
jumpTo: function( time ) {

if ( time < 0 || time > this.duration() ) {
return this;
}
Expand Down
41 changes: 36 additions & 5 deletions test/sequence.unit.js
Expand Up @@ -737,17 +737,17 @@ asyncTest("pause() and play()", 3, function() {
seq.on( "loadedmetadata", function() {

seq.cue( 2, function() {

equal( seq.playing, true, "Sequence is playing" );

seq.pause();

}).on ("pause", function() {
seq.off( "pause" );
equal( seq.playing, false, "Sequence is paused" );
seq.play();
equal( seq.playing, false, "Sequence is paused" );
seq.play();
}).cue(4,function(){
equal( seq.playing, true, "Sequence is playing again" );
equal( seq.playing, true, "Sequence is playing again" );
seq.remove();
start();
});
Expand All @@ -756,3 +756,34 @@ asyncTest("pause() and play()", 3, function() {
});


asyncTest( "play() after sequence ended", 2, function() {

var seq = Popcorn.sequence( "video-sequence-b", remoteMediaList ),
ended = 0;

seq.on( "loadedmetadata", function() {

seq.on( "pause", function() {
if ( seq.currentTime() >= seq.duration() ) {

if ( !seq.playing ) {
ended = 1;
}

seq.play();

seq.cue( 2, function() {

start();
equal( ended, 1, "Sequence ended" );
equal( seq.active, 0, "Sequence cycle started from beginning" );
seq.remove();
start();
})
}
})
seq.play();
});
});