I am trying to play midi in a browser and use a Java applet that works fine on a PC. This is extremely unreliable on OSX, so I wrote a simple test case that shows the same problem:
import javax.sound.midi.*;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class MidiPlayer {
public static void main(String[] args) {
try {
Sequencer sequencer = MidiSystem.getSequencer();
if (sequencer == null)
throw new MidiUnavailableException();
sequencer.open();
FileInputStream is = new FileInputStream("sample.mid");
Sequence mySeq = MidiSystem.getSequence(is);
sequencer.setSequence(mySeq);
sequencer.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
It seems that the random message is being removed. Just as a note does not work, and a random note will forever depend. Is this a known issue in OSX? Java doesn't seem to get enough love from Apple these days.
If someone has the best solution for playing Midi in a browser, I’m all ears!
source
share