Forum Moderators: travelin cat

Message Too Old, No Replies

Streaming files on a Mac...

Setting proper content-type

         

mattglet

3:07 pm on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to stream mp3 files through an ASP (language shouldn't matter, just putting into context) page via this method:

test.asp?file_id=123456

In the ASP file, I'm setting the "Content-Type" to "audio/mpeg" (I've also tried audio/mp3 & audio/x-mpeg), adding a "Content-disposition" header that says "filename=C:\mydirectory\audio\filename.mp3"

This works fine (on a PC) with IE 6, Opera 7.54, even Netscape 6.2. The only problems I'm having, are with a Mac (OS 9), using IE 5.2 & Safari.

This is what happens: QuickTime recognizes that an audio file needs to be played, even calculates the file size (3.6mb -- the test file I'm using). But when it tries to stream, it lists "test.asp" as the title of the object it's streaming, and no sound comes out. I have another version of streaming, using an m3u file, and it works perfectly everywhere. It's just when I try to do the "test.asp?file_id=123456" it doesn't work... Is there a trick to a Mac browser that I'm missing?

timster

5:05 pm on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd check out the Content-Disposition. "C:" is a Windows-only syntax. Just a guess.

mattglet

5:09 pm on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The C:\ is a reference to the file location on the server (obviously)... I would be disappointed if that is the reason for my troubles, but I will check it out.

timster

7:30 pm on Sep 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No luck yet, then? I know I've seen this problem before, and we just tinkered until the problem went away (since we really didn't understand what we were doing).

One thing though: Could you clarify what browsers you're using that give the error? You mention OS 9 and Safari, but Safari doesn't run under OS 9.

Span

8:10 pm on Sep 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The asp file should be served with a Content-Type: text/html. The mp3 should have a Content-Type: video/mpeg. Works for me. It looks like you are serving the asp file as a video?

mattglet

4:51 pm on Sep 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



timster-
Still nothing working on my end, and I'm still tinkering during my down time. And yes, you are correct... it's OS X.

Span-
Can you post an example of what you are describing? I'm confused by your statement because only one Content-Type can be declared for a page.

timster

3:12 pm on Sep 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you post an example of what you are describing? I'm confused by your statement because only one Content-Type can be declared for a page.

Yes and no. If your movie appears on a Web page, then the (asp-generated) web page and the (possibly asp-generated) movie each would have its own headers, including content-type.

But in any case, it looks like Span caught the bug: you're streaming video, not audio, and the header should reflect that.

jamesa

9:28 pm on Sep 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This has worked across browser/platforms for me (mp3 files):

Cache-Control: private
Content-type: application/octet-stream
Content-Disposition: attachment; filename="blah");
Content-length: ...

jamesa

11:00 pm on Sep 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looking at it closer I see the problem...

adding a "Content-disposition" header that says "filename=C:\mydirectory\audio\filename.mp3"

That's not supposed be the path on your server, but rather the name of the file the end user gets. So use "filename=filename.mp3" instead.

The way you had it would try to create a *file* called "C:\mydirectory\audio\filename.mp3" but the colon is an illegal character in Mac file names. I would avoid colons (:) and forward slashes (/) in file names.