mirror of
https://github.com/videojs/video.js.git
synced 2024-12-25 02:42:10 +02:00
On ended, pause player if not paused or looping IE11 (and maybe other browsers as well) only fire 'ended' event when the video ends and doesn't fire pause. This makes IE11 not reset it's state into a paused state that allows a user to replay immediately. However, a two clicks on the play/pause button will allow you to replay. In Chrome, we get first a pause event and then an ended event. When 'loop' is set, neither the last pause nor ended fire. In the flash tech, the pause and ended events fire like in chrome in all browsers. Add tests for onEnded change Appease jshint.
This commit is contained in:
parent
18965bb8d7
commit
53ea60cd06
@ -511,6 +511,8 @@ vjs.Player.prototype.onEnded = function(){
|
||||
if (this.options_['loop']) {
|
||||
this.currentTime(0);
|
||||
this.play();
|
||||
} else if (!this.paused()) {
|
||||
this.pause();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -618,3 +618,31 @@ test('should clear pending errors on disposal', function() {
|
||||
}
|
||||
ok(true, 'did not throw an error after disposal');
|
||||
});
|
||||
|
||||
test('pause is called when player ended event is fired and player is not paused', function() {
|
||||
var video = document.createElement('video'),
|
||||
player = PlayerTest.makePlayer({}, video),
|
||||
pauses = 0;
|
||||
player.paused = function() {
|
||||
return false;
|
||||
};
|
||||
player.pause = function() {
|
||||
pauses++;
|
||||
};
|
||||
player.trigger('ended');
|
||||
equal(pauses, 1, 'pause was called');
|
||||
});
|
||||
|
||||
test('pause is not called if the player is paused and ended is fired', function() {
|
||||
var video = document.createElement('video'),
|
||||
player = PlayerTest.makePlayer({}, video),
|
||||
pauses = 0;
|
||||
player.paused = function() {
|
||||
return true;
|
||||
};
|
||||
player.pause = function() {
|
||||
pauses++;
|
||||
};
|
||||
player.trigger('ended');
|
||||
equal(pauses, 0, 'pause was not called when ended fired');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user