Play MIDI : MIDI « J2ME « Java Tutorial






import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;

public class PlayMIDIMIDlet extends MIDlet {

  Player midiPlayer = null;

  public PlayMIDIMIDlet() {
    try {
      midiPlayer = Manager.createPlayer(getClass().getResourceAsStream("/a.mid"), "audio/midi");
    } catch (Exception e) {
      System.err.println(e);
    }
  }

  public void startApp() {
    try {
      if (midiPlayer != null) {
        midiPlayer.start();
      }
    } catch (Exception e) {
      System.err.println(e);
    }
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }
}








31.57.MIDI
31.57.1.Play MIDI
31.57.2.Controllable MIDI
31.57.3.MIDI Capabilities
31.57.4.MIDI EventsMIDI Events
31.57.5.Mixing Audio