From 8f78fd73c504e503ed1984d6a3243f46bdd0133d Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 21 Jan 2015 09:56:44 -0800 Subject: [PATCH] Progress on repeat now that we have playlists --- js/media.js | 13 ++++++------- js/winamp.js | 6 +++++- 2 files changed, 11 insertions(+), 8 deletions(-) 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() {