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

Reset to 0 on play if the video has ended #2519

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ vjs.Flash.prototype.dispose = function(){
};

vjs.Flash.prototype.play = function(){
if (this.ended()) {
this['setCurrentTime'](0);
}

this.el_.vjs_play();
};

Expand Down
30 changes: 30 additions & 0 deletions test/unit/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,36 @@ test('seekable should be empty if no video is loaded', function() {
equal(tech.seekable().length, 0, 'seekable is empty');
});

test('hitting play again after video ends resets current time to 0', function() {
var player = PlayerTest.makePlayer(),
currentTime = 60,
tech = new vjs.Flash(player, {
'parentEl': player.el()
});

// mock out currentTime
tech.el()['vjs_getProperty'] = function(name) {
if (name === 'currentTime') {
return currentTime;
}
if (name === 'ended') {
return true;
}
};

tech.el()['vjs_setProperty'] = function(property, value) {
if (property === 'currentTime') {
currentTime = value;
}
};

tech.el()['vjs_play'] = function() {};

tech.play();

equal(tech.currentTime(), 0, 'current time was not 0');
});

test('calling methods before the SWF loads is safe', function() {
var player = PlayerTest.makePlayer(),
tech = new vjs.Flash(player, {
Expand Down