Java examples for Media:Audio
Determining When a Midi Audio Player Has Finished Playing
import javax.sound.midi.MetaEventListener; import javax.sound.midi.MetaMessage; import javax.sound.midi.MidiSystem; import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.Sequencer; public class Main { public void main(String[] argv) { try {//from w w w . j a v a 2 s . c om Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); sequencer.addMetaEventListener(new MetaEventListener() { public void meta(MetaMessage event) { if (event.getType() == 47) { // Sequencer is done playing } } }); } catch (MidiUnavailableException e) { } } }