Java tutorial
import javax.sound.midi.MetaEventListener; import javax.sound.midi.MetaMessage; import javax.sound.midi.MidiSystem; import javax.sound.midi.Sequencer; public class Main { public static void main(String[] argv) throws Exception { Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); sequencer.addMetaEventListener(new MetaEventListener() { public void meta(MetaMessage event) { if (event.getType() == 47) { // Sequencer is done playing } } }); } }