|
How to load and play Midi audio |
|
|
This Java tip illustrates a method of loading and playing Midi audio. This tip
may be very useful for the developers who want to create multi-media applications.
Games can also be a very useful end application for this code.
try {
// From file
Sequence sequence = MidiSystem.getSequence(new File("midiaudiofile"));
// From URL
sequence = MidiSystem.getSequence(new URL("http://hostname/midiaudiofile"));
// Create a sequencer for the sequence
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(sequence);
// Start playing
sequencer.start();
} catch (MalformedURLException e) {
} catch (IOException e) {
} catch (MidiUnavailableException e) {
} catch (InvalidMidiDataException e) {
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.