diff --git a/src/js/media/flash.js b/src/js/media/flash.js index 3a9629d91f..9223ae6d0b 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -101,6 +101,10 @@ vjs.Flash.prototype.dispose = function(){ }; vjs.Flash.prototype.play = function(){ + if (this.ended()) { + this['setCurrentTime'](0); + } + this.el_.vjs_play(); }; diff --git a/test/unit/flash.js b/test/unit/flash.js index 9218165cfc..05b217b691 100644 --- a/test/unit/flash.js +++ b/test/unit/flash.js @@ -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, {