diff --git a/src/js/player.js b/src/js/player.js index f98aea263..39d88d804 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -511,6 +511,8 @@ vjs.Player.prototype.onEnded = function(){ if (this.options_['loop']) { this.currentTime(0); this.play(); + } else if (!this.paused()) { + this.pause(); } }; diff --git a/test/unit/player.js b/test/unit/player.js index fe6b8b6db..66f7e1d71 100644 --- a/test/unit/player.js +++ b/test/unit/player.js @@ -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'); +});