Progress on repeat now that we have playlists

This commit is contained in:
Jordan Eldredge 2015-01-21 09:56:44 -08:00
parent ea060500cf
commit 8f78fd73c5
2 changed files with 11 additions and 8 deletions

View file

@ -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;
}

View file

@ -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() {