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

Check this thread and let me know if it sounds like it addresses your situation. If not, we'll have to look at other possibilities.

Hi,

Thank you!
The problem was exactly the same described in the referred topic.
We had to make a very nasty workaround to store the sessions and override it when media player changes the sesssion id.

Regards,

Gabor

In case that source is lost, here's the solution for anyone else that may be interested.

To whomever cares,
I've got a workaround now. I still do not know for certain if it's a
bug or by-design that the cookies aren't used by the plugin. While
looking through the Netscape Plugin API (NPAPI), I found a function that
one would use to request info from the browser, but no mention was made
of cookies. Perhaps it could be used to pass cookies, and perhaps not.
The long and short of it is that cookies aren't passed.

What I did to work around the problem was to create a new .aspx page to
point the NPAPI plugin at. My <embed> tag points WMP to it and appends
the SessionID to the Url. This new .aspx page takes that param and
updates the session-cookie that WMP is using, then redirects it to the
actual Url to get the video. And, yes, I did take extra precautions to
stop people from using this new page as a backdoor into the site; thanks
for looking out for me. =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.