Hey Everybody!
Anybody know how to play a MIDI file in Java or in Java applets?
I know it's possible but I just don't know how to do it.
Printable View
Hey Everybody!
Anybody know how to play a MIDI file in Java or in Java applets?
I know it's possible but I just don't know how to do it.
javax.sound.midi
Quite Easy. The java.applet.AppletStub and java.applet.AppletContext interfaces describe services that the web browser or applet viewer provides to applets. Note if your applet declares a main method these interfaces will have null AppletStub and AppletContext members. Therefore if you try to use these methods in such an applet a NullPointerException will be thrown.
The applet class has five methods that download sounds from the web. The two play() methods download a sound file and play it immediately. The two getAudioClip() methods and the static Applet.newAudioClip() method save a sound for later playing.
public void play(Url u)
public void play(Url u, String filename)
public AudioClip getAudioClip(Url u)
public AudioClip getAudioClip(Url u, String filename)
public static final AudioClip newAudioClip(Url u)
But in non-Applets you still have to use the javax.sound.midi package...