MIDI links playing in the browser

Getting MIDI links at Composers' Village to play in people's browsers has been an interesting challenge. After I first noticed that the links were prompting file downloads, investigation led me to the "Content-Disposition" header that FileField puts on files downloaded from a filefield. (FileField is the name of the Drupal module that I am using to implement the file links for the Village, and the particular container is a filefield.)

Making FileField output "Content-Disposition: inline" as opposed to "Content-Disposition: attachment" makes the browser look for a plug-in that handles that type of content and play it, rather than downloading the corresponding file.

After initially correcting the problem in the FileField module's code at first, I wanted to make the fix in a modular way, that did not require changing FileField's code. When I looked at the Drupal 6 code further, however, I discovered that any implementation of hook_file_download I did in my composers_village module could only add to the headers put there by FileField's implementation and could never take away what FileField's implementation had added.

So, the remaining option was to contribute my fix of the problem to the FileField project at drupal.org. In researching similar issues in the drupal.org issue queue, I learned that the same problem had just been fixed for Flash content in a filefield. Since MIDI is a relatively rare file format and it required the "inline" designation, I fixed the problem in a way that created an administrative settings page for FileField where an administrator can set additional file types to be downloaded as "inline". This community discussion is at http://drupal.org/node/485336 and is ongoing. The next release of FileField should contain some version of my fix.

[UPDATE 9/2/09: The change has been committed to FileField head for some time but has not yet appeared in a release.]

[UPDATE 12/23/09] Just searched for filefield_inline_types in version 6.x 3.2 of FileField and can confirm that this patch is part of this version.]


An "interesting challenge"

An "interesting challenge" does not begin to describe the troubles I have had with doing this. Thank you so much for sharing this, you are a lifesaver! I finally got rid of that headache!

Drupal SEO