Skip to content

Commit

Permalink
Fixed next and prev functions to use correct parent. (not this.queue,…
Browse files Browse the repository at this point in the history
… this.pointer)
  • Loading branch information
Andrew-McGee committed Jun 12, 2021
1 parent 437bd35 commit 19c26ff
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,27 +260,28 @@ function playAllNext() {

// Skip next function
function next() {
if (this.pointer == this.queue.length - 1) {

if (parent.pointer == parent.queue.length - 1) {
// We're at the end so lets stop playback
trk01.stop();
// Do some tidy up
document.getElementById("playBtn").className = "bordered play icon"; // change button back to play
document.title = "foam"; // update doc title back to default
this.pointer = 0; // reset our position in the queue
parent.pointer = 0; // reset our position in the queue
} else {
this.pointer++;
playnew(this.pointer);
parent.pointer++;
playnew(parent.pointer);
}
}

// Skip prev function
function prev() {
// Check if we've been playing for 5 seconds if so just rewind this song, if not decrement pointer to previous song
if (trk01.seek() >= 5) {
playnew(this.pointer); // Just start playback again with current pointer
playnew(parent.pointer); // Just start playback again with current pointer
} else {
if (this.pointer !== 0) this.pointer--; // Decrement the pointer to the previous song if it's not at the start
playnew(this.pointer);
if (parent.pointer !== 0) parent.pointer--; // Decrement the pointer to the previous song if it's not at first song
playnew(parent.pointer);
}
}

Expand Down

0 comments on commit 19c26ff

Please sign in to comment.