Permalink
Browse files

Merge pull request #41 from cadecairos/issue-35-36

Issue 35 36
  • Loading branch information...
cadecairos committed May 17, 2012
2 parents f1bb28c + 49fa19e commit ccf43162d8b166c7ac681ad8bf6d2dff0ed3a97c
Showing with 44 additions and 7 deletions.
  1. +8 −2 popcorn.sequence.js
  2. +36 −5 test/sequence.unit.js
View
@@ -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;
},
@@ -451,7 +457,7 @@
return currentTime;
},
jumpTo: function( time ) {
-
+
if ( time < 0 || time > this.duration() ) {
return this;
}
View
@@ -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();
});
@@ -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();
+ });
+});
+
+

0 comments on commit ccf4316

Please sign in to comment.