diff --git a/js/media.js b/js/media.js index 09afa594..2678166e 100644 --- a/js/media.js +++ b/js/media.js @@ -228,6 +228,10 @@ Media = { this.play(time); }, + repeatEnabled: function() { + return this._loop; + }, + // There is probably a more reasonable way to do this, rather than having // it always running. _draw: function() { @@ -246,13 +250,8 @@ Media = { _updatePosition: function() { this._position = this._context.currentTime - this._startTime; if(this._position >= this._buffer.duration && this._playing) { - // Idealy we could use _source.loop, but it makes updating the position tricky - if(this._loop) { - this.play(0); - } else { - this.stop(); - this._callbacks.ended(); - } + this.stop(); + this._callbacks.ended(); } return this._position; } diff --git a/js/winamp.js b/js/winamp.js index 474c0614..c864f064 100755 --- a/js/winamp.js +++ b/js/winamp.js @@ -64,7 +64,11 @@ Winamp = { this.media.addEventListener('ended', function() { self.skin.visualizer.clear(); - self.setState('stop'); + if(self.media.repeatEnabled()) { + self.next(); + } else { + self.setState('stop'); + } }); this.media.addEventListener('waiting', function() {