Ok, this is a big question to me but on IRC I got some people who made it sound very easy, but it's going to take some hand-holding in my case.
My requirement is a functionality that allow users to take a series of small audio files that are stored on the server in wav format, and allow them to select the files they want to use, and put them in the order that they prefer. Then, they click a download link and I start sending them an mp3 of the concatenated wav files.
So basically, files are created on-the-fly, and then sent to the browser.
I'm developing in a LAMP stack, and I'm only 6 months in to programming at all, so php has become my drug of choice.
This code is my first experimentation with creating download links.
$filename = 'Programming for Dumbasses.pdf';
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false); // required for certain browsers
header('Content-Disposition: attachment; filename="'. basename($filename) . '";');
header('Content-Length: ' . filesize($filename));
and that's just something I pulled off of stackoverflow. So here's my question:
I'm assuming that I can change the content type to an mp3. Also i'm going to have to call some external binaries like sound exchange or the LAME mp3 encoder using php's exec() function.
Furthmore, I'm going to have to pull the order and identity of each sound file from the user's browser. So if he has a list in front of him, how can i send that list using ajax, while still using href = download.php, where download.php is similar to the code described above?
Here's the sequence of events as I am thinking of them.
1. the list of files is acquired, through post or get.
2. the files are confirmed, and sent to the lame or sound exchange binary with a filename for concatenation and conversion
3.the header is sent, and an ajax response for loading is returned
4. the file is created by the external process, confirmed to exist by php, and sent to the user
5. delete the file, and smash my head on the keyboard.
Now if that sounds stupid to you, believe me it sounds stupid to me too. Ajax returns certain strings and document types etc, but I've never seen it continuously monitor the progress of a download or process outside of itself. At least not that I'm aware of. Also, creating the file then reading it from php seems super weighty at best. On IRC I got the suggestion to "pipe to concatenated wav files into LAME, then pipe the output to a streaming download link". That sounds beautifully perfect. How the hell do I do that?
Any help whatsoever will earn you my firstborn son.