Permalink
Browse files

Use the meta channel for end of track, this fixes a weird MIDI bug wh…

…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 04745042ae1bc056a0d6dc7631ad861e08dff526
@@ -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();
@@ -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) {
@@ -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");
}
}
}

0 comments on commit 0474504

Please sign in to comment.