Skip to content

Commit

Permalink
Seek to the beginning on replay
Browse files Browse the repository at this point in the history
The video.js SWF no longer seeks back to the beginning automatically. Instead, check whether the video has ended on play and seek back to the beginning if necessary.
  • Loading branch information
dmlap committed Aug 31, 2015
1 parent c38778c commit 3869eec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/js/tech/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class Flash extends Tech {
* @method play
*/
play() {
if (this.ended()) {
this.setCurrentTime(0);
}
this.el_.vjs_play();
}

Expand Down
22 changes: 22 additions & 0 deletions test/unit/tech/flash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ test('seekable', function() {
equal(result.length, mockFlash.duration_, 'seekable is empty with a zero duration');
});

test('play after ended seeks to the beginning', function() {
let plays = 0, seeks = [];

Flash.prototype.play.call({
el_: {
vjs_play() {
plays++;
}
},
ended() {
return true;
},
setCurrentTime(time) {
seeks.push(time);
}
});

equal(plays, 1, 'called play on the SWF');
equal(seeks.length, 1, 'seeked on play');
equal(seeks[0], 0, 'seeked to the beginning');
});

// fake out the <object> interaction but leave all the other logic intact
class MockFlash extends Flash {
constructor() {
Expand Down

0 comments on commit 3869eec

Please sign in to comment.