Hi Guys,
We are trying to create a little servlet in Tomcat, which is capable to send audio files over http to an embedded media player. The definition of the player looks like:
...
<OBJECT ID="Mp" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" TYPE="application/x-oleobject" WIDTH="0" HEIGHT="0">
<PARAM name="uiMode" value="none">
<PARAM NAME="ShowControls" VALUE="0">
<PARAM NAME="AutoStart" VALUE="1">
<PARAM NAME="ShowPositionControls" VALUE="0">
<PARAM NAME="ShowStatusBar" VALUE="0">
<PARAM NAME="ShowDisplay" VALUE="0">
</OBJECT>
...
<script language="javascript">document.Mp.URL = "here comes the url of the servlet with item ID";</script>
The servlet reads the audio file and writes its content to the response with the following http header settings:
getResponse().setContentType("audio/x-wav");
getResponse().setHeader("Content-Transfer-Encoding", "binary");
getResponse().setHeader("Pragma", "Public");
getResponse().setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
getResponse().setHeader("Content-Disposition", "inline; filename=Media.wav");
getResponse().setHeader("Content-Length", new Integer(MediaBytes.length).toString());
getResponse().setHeader("Accept-Ranges", "bytes");
So, everything works fine for wav files in Internet Explorer, but we are facing problems with Firefox, where it does not work. The embedded Media Player says that "Windows Media Player cannot play the file. One or more codecs required to play the file could not be found."
But if we set the url to directly to the file on the server, everything works fine.
We have analyzed the HTTP traffic in both situation, but we cannot understand how Internet Explorer/Firefox and Media Player works together:
- how does Media Player know that the audio file is playable?
- if the url points directly to the file, the HTTP headers does not contain any kind of information about the file type, only the extension is available; Media Player checks the file extenion in the url?
- if the url points to the servlet, why Media Player in Firefox cannot determine the file type and throws error?
Any help is greately appreciated!
Thanks!
Gabor