I’ve been working on an Android app that plays MIDI files via Bluetooth. (Why would anyone want to do such a thing? I have my reasons, but for now let’s just say that I’m a glutton for punishment.) The first obstacle was that Android offers no API support for parsing MIDI files. While I generally feel that it is wise not to support MIDI, the decision to remove
javax.sound.midi from the API is a bit of a mystery because the functionality is still there. After all, the media player handles MIDI files just fine, as does the Jet engine.
Fortunately, free (as in GPL) implementations of
javax.sound.midi are available, and it was easy enough to paste them into an Android project. The next step was to get Android to launch my app when opening a MIDI file. No problem, just register an intent filter for the MIME type audio/midi and you’re done.
Well, almost. Catching launch intents for audio/midi worked nicely until my Droid X received an upgrade to Android 2.3 (Gingerbread). My first impressions of Gingerbread are quite favorable, but the one downside I noticed was that my MIDI file player stopped working. Whenever I tried to open a MIDI file using the Files app, it would just ignore my intent filter and launch the media player instead.
It turns out that the version of the Files app that comes with Gingerbread thinks that MIDI files are of MIME type audio/sp-midi. This makes no sense, but at least it’s easy to work around. (If you download a new MIDI file and open it by selecting its download notification, it’ll still show up with a MIME type of audio/midi, and so a MIDI file player app needs to register intent filters for both audio/midi and audio/sp-midi.)
Not a terribly compelling post, but I sort of feel like this MIME type issue needs to be documented, just in case someone else is crazy enough to write an app that handles MIDI files. Given the way I feel about MIDI, however, I sincerely hope that this post will be of no interest to anybody.