Skip to content

Commit

Permalink
Catch error
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLaumeister committed Dec 22, 2019
1 parent 34d5197 commit 90ac020
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/NotePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ class NotePlayer {

play(index, time, volume) {
// Cycle through the voices
this.players[this.currentPlayer].volume.setValueAtTime(volume, time);
this.players[this.currentPlayer].start(time, index * this.noteDuration, this.noteDuration);
this.currentPlayer = (this.currentPlayer + 1) % this.players.length;
try {
this.players[this.currentPlayer].volume.value = volume;
this.players[this.currentPlayer].start(time, index * this.noteDuration, this.noteDuration);
this.currentPlayer = (this.currentPlayer + 1) % this.players.length;
} catch (e) {
// Player not yet ready
}
}
}

0 comments on commit 90ac020

Please sign in to comment.