Skip to content

Commit

Permalink
Use the meta channel for end of track, this fixes a weird MIDI bug wh…
Browse files Browse the repository at this point in the history
…ere some MIDI files were not calling close() on the sequencer once they finished. Not sure if it's a Java bug or the spec is just unclear.
  • Loading branch information
me4502 committed Jul 10, 2017
1 parent eb9fc4e commit 0474504
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ public void close() {
}
});

sequencer.addMetaEventListener(meta -> {
// END_OF_TRACK_MESSAGE
if (meta.getType() == 47) {
running = false;
}
});

try {
if (sequencer.isOpen()) {
sequencer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public void run () {

while(players.isEmpty()) {
if(!isPlaying()) return;
CraftBookPlugin.logDebugMessage("Playlist has no players", "playlist");
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
Expand Down Expand Up @@ -289,6 +290,7 @@ public void run () {
} else if (line.startsWith("goto ")) {

position = Integer.parseInt(StringUtils.replace(line, "goto ", ""));
CraftBookPlugin.logDebugMessage("Setting line to: " + position, "playlist");
}
}
}
Expand Down

0 comments on commit 0474504

Please sign in to comment.