PDA

View Full Version : making mp3's available for download



dpr
06-28-2007, 04:55 PM
Hi there, I have a website that I want visitors to be able to download mp3's from (all my own material, of course).

I want them to be able to listen before they download, so I have 3 links for each song: "lofi," "hifi" and "download."

I have streamed lofi (16k) versions and hifi (192k) versions using the .m3u files in a separate folder, and it works fine, but I'm not sure how to do the "download" one. I tried linking directly to the mp3, and that doesn't work.

Thing is, I am running Windows XP, and when I click on either "lofi" or "hifi" it brings up a box that asks if I want to open the file or save it to disk. Is there anyway you can tell their browser what to do, so that box doesn't appear. In other words, when they click on "lofi" or "hifi," it will automatically stream and play, but when they click on "download," it will automatically download?

Thanks in advance for your help,
Mike

charlesgan
06-29-2007, 01:04 AM
use the embed , and auto start the player.
eg. http://www.mioplanet.com/rsc/embed_mediaplayer.htm


<OBJECT id="VIDEO" width="320" height="240"
style="position:absolute; left:0;top:0;"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">

<PARAM NAME="URL" VALUE="your file or url">
<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">
<PARAM NAME="AutoStart" VALUE="True">
<PARAM name="uiMode" value="none">
<PARAM name="PlayCount" value="9999">
</OBJECT>

siguie
06-30-2007, 04:34 AM
It's been a while and I usually just let the surfers do a "Save As" but in php it used the code ...


header("Content-Type: application/force-download");

... and a mime-type specification I'm pretty sure.

I would just lookup "Force File Download" or ask/wait for one of the real php programmers here to chime in ;)

felgall
06-30-2007, 02:59 PM
The correct header to use is:

header('Content-Disposition: attachment; filename=whatever.mp3');

dpr
07-01-2007, 11:16 AM
Okay bear with me, cuz I'm not that knowledgeable about this stuff, but according to this article you linked to, I can embed WMP into my document to control what it plays. But what would happen if one of the visitors to my website was using a Mac? Or just a PC without WMP? Would that screw it up? Thanks


use the embed , and auto start the player.
eg. http://www.mioplanet.com/rsc/embed_mediaplayer.htm

dpr
07-01-2007, 11:18 AM
Ah okay. But my website is CSS/HTML.. In order to use this php code in my website, would I have to reencode the whole thing in php?
Thanks


The correct header to use is:

header('Content-Disposition: attachment; filename=whatever.mp3');

felgall
07-01-2007, 01:15 PM
That header needs to be in the file to be downloaded. The usual way is to set up PHP that will create the necessary header and then copy the file that is to be downloaded. Apar from the link address it doesn't change your web page.