Forum Moderators: open

Message Too Old, No Replies

Trying to stream mp3, Mac browsers are downloading instead

what response header do i send?

         

mattglet

8:44 pm on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an asp file that pulls an mp3 title from a database, then streams the file to the browser. I can't link directly to the mp3, because I need to do a couple of checks first to make sure the file id is valid, etc.

The problem is that Mac browsers don't handle the content-type correctly (audio/x-mpeg), and it tries to download the ASP page instead.

Is there a work-around for this?

py9jmas

8:57 pm on Sep 7, 2004 (gmt 0)

10+ Year Member



Mac browsers don't handle the content-type correctly (audio/x-mpeg), and it tries to download the ASP page instead.

Explain how that is not "correct"?

Probably the best way to get the desired result would be to generate a "m3u" or "pls" file which the browser can download and pass to the configured player. If your webpage can link to the file (to cause it to be downloaded), then you have a URL for it to place in the .m3u/.pls file.

mattglet

9:09 pm on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Explain how that is not "correct"?

If you explicitly assign a content-type to the page, the browser should take action accordingly.

i.e.
I tell the browser that the page's content-type is audio/x-mpeg, and I tell the browser (via content-disposition) that the filename is c:\somewhere\something.mp3. It should then know to open the file via the system's default application to play mp3 files.

It would be a different story if I specified the content-type as text/html, and the content-disposition as test.asp, but that's not the case. So the browser shouldn't try to download my test.asp file.

Am I missing something?

Edit:
I will make it a little more clear: Mac browsers are trying to download the physical ASP file, like it was an attachment. Opera, IE, Netscape all handle the mp3 file correctly, and stream it.

mattglet

9:38 pm on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, now I've finally got my problem identified...

I'm using an ASP file to dynamically stream an m3u file:


Response.ContentType = "audio/x-mpegurl"
Response.AddHeader "Content-disposition", "filename=audio_stream" & intFileID & ".m3u"
Response.Write "#EXTM3U" & vbCrLf

Response.Write "#EXTINF: 0," & rs("bandname") & " - " & rs("title") & vbCrLf
Response.Write "http://www.example.com/audio_standard/audio_standard.mp3?file_id=" & intFileID

When I try this on IE 6, Opera 7.53, even Netscape 6.2, it works fine. But if I try it on a Mac, it tries to download my ASP file, not the m3u file listed in the content-disposition.

drbrain

10:20 pm on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see a disposition-type there. Try changing that to:

Response.write "Content-Disposition", "attachment; filename=" ...

mattglet

3:36 pm on Sep 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No dice.

Mac still tries to download my ASP file.

py9jmas

3:53 pm on Sep 9, 2004 (gmt 0)

10+ Year Member



Isn't Content-Disposition usually used to request the browser treats the file as an attachment - that is prompt to "save as" instead of passing the file to a helper application? That seems to be the opposite of what you want.
Also, has the Mac got a helper application configured for audio/x-mpegurl?

mattglet

7:11 pm on Sep 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



py9jmas-

I am aware of the "attachment" thing... It's actually "inline" for my purposes, I just didn't bother to post the correction to drbrain.

As for the content handler-

x-mpegurl is the standard content-type for an M3U file. I have iTunes installed on the Mac, which covers that base.

Please keep the ideas coming :)

plumsauce

7:57 pm on Sep 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




matt,

try using a sniffer against a site where this *is* working to see what they are actually sending out.

mattglet

8:42 pm on Sep 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not a bad idea -- Now I just have to find a site that does what I'm looking to do, because I don't know of any off hand.

plumsauce

7:28 pm on Sep 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




another suggestion:

is the query part of the returned url being handled properly by the client, ie:?file_id=" & intFileID

and is the returned content properly formed?

some clients, notably IE, will make allowances for ill-formed responses, maybe the mac client does not.

mattglet

2:51 pm on Sep 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



plumsauce-

Can you go into more detail as to what you are asking there? Not sure I fully understand what you mean...

Thanks.

plumsauce

7:21 pm on Sep 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




i am saying that you return "?file_id=nnn" as part of the mpegurl. the particular browser/plugin combo that you are having trouble with may fall down because it can only handle for example somefile.mpg without any parameters.

test this by trying to feed it just somefile.mpg as a test url.