Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Commit

Permalink
Replace setInterval with setTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
eljenso committed Jul 31, 2015
1 parent 3be139c commit e59a1fc
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions modules/mopidyCom.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function checkInit() {
Q.all([mopidy.playback.getCurrentTrack(), mopidy.playback.getTimePosition()])
.spread(function(currentTrack, timePosition) {
if (currentTrack) {
queueTimeout = setInterval(function () {
setTimeout(function () {
queueNextTrack();
}, currentTrack.length - timePosition - 10*1000);
deferred.reject('Already playing!');
Expand All @@ -107,10 +107,6 @@ function checkInit() {

function queueNextTrack (isInit) {
var deferred = Q.defer();

// clear old timeout!
clearInterval(queueTimeout);

var trackUri;

Q()
Expand All @@ -126,7 +122,7 @@ function queueNextTrack (isInit) {
})
.then(function (nextTracks) {
// 5 seconds before the current track stops, queue next track
queueTimeout = setInterval(function () {
setTimeout(function () {
queueNextTrack();
}, nextTracks[0]._doc.length - (firstSong ? 10*1000 : 0));
firstSong = false;
Expand Down

0 comments on commit e59a1fc

Please sign in to comment.