Skip to content

Commit 2c8fbb3

Browse files
committed
Stop timeInterval when song is paused.
1 parent 505ac0c commit 2c8fbb3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

player.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ var player = (function () {
128128
};
129129

130130
var startUpdateClock = function startUpdateClock () {
131+
132+
if (_self.intervalId !== undefined) {
133+
clearInterval(_self.intervalId);
134+
}
135+
131136
//
132137
// Updates the clock every 1 second.
133138
//
@@ -164,7 +169,14 @@ var player = (function () {
164169

165170

166171
var playPauseText = function playPauseText () {
167-
_self.dnPlayPause.textContent = _self.dnAudio.paused ? 'Play' : 'Pause';
172+
if (_self.dnAudio.paused) {
173+
_self.dnPlayPause.textContent = 'Play';
174+
clearInterval(_self.intervalId);
175+
}
176+
else {
177+
_self.dnPlayPause.textContent = 'Pause';
178+
startUpdateClock();
179+
}
168180
}
169181

170182
/**
@@ -190,9 +202,6 @@ var player = (function () {
190202
_self.dnHandler.style.left = pos + '%';
191203
});
192204

193-
if (_self.dnAudio.currentTime > 0) {
194-
startUpdateClock();
195-
}
196205
};
197206

198207

@@ -256,6 +265,7 @@ var player = (function () {
256265

257266
_self.dnAudio.currentTime = newTimePosition;
258267
_self.dnAudio.play();
268+
startUpdateClock();
259269
}
260270
};
261271

0 commit comments

Comments
 (0)