Skip to content

Commit 646c42f

Browse files
committed
Previous: go backwards through list of played songs
1 parent e589202 commit 646c42f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

js/AudioPlayer.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var AudioPlayer = (function() {
8484
repeating = false,
8585
// either null or an array of all indices which were not played yet
8686
shuffling = null,
87+
played = [],
8788
seeking = false,
8889
rightClick = false,
8990
apActive = false,
@@ -313,6 +314,8 @@ var AudioPlayer = (function() {
313314
return;
314315
}
315316

317+
played.push(index)
318+
316319
audio.src = playList[index].file;
317320
audio.preload = 'auto';
318321
document.title = trackTitle.innerHTML = playList[index].title;
@@ -327,7 +330,12 @@ var AudioPlayer = (function() {
327330
}
328331

329332
function prev() {
330-
index = index - 1;
333+
if (played.length > 1) {
334+
index = played.splice(-2)[0];
335+
} else {
336+
index = 0;
337+
}
338+
331339
play();
332340
}
333341

0 commit comments

Comments
 (0)