Skip to content

Commit

Permalink
An attempt at seek tracking.
Browse files Browse the repository at this point in the history
Will emit seek if predicted time is different by 5 seconds or more.
  • Loading branch information
itotallyrock committed Jun 28, 2017
1 parent 06f6f69 commit ae3283b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ function SpotifyWebHelper(opts) {
};
this.player.seekTo = seconds => {
this.status.playing_position = seconds; // eslint-disable-line camelcase
this.player.emit('seek', seconds);
return this.player.play(this.status.track.track_resource.uri + '#' + parseTime(seconds));
};
this.status = null;
Expand Down Expand Up @@ -279,6 +280,9 @@ function SpotifyWebHelper(opts) {
stopSeekingInterval.call(this);
}
}
if (Math.abs(this.status.playing_position - status.playing_position) > 5) {
this.player.emit('seek', status.playing_position);
}
};
var getStatus = () => {
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit ae3283b

Please sign in to comment.