I've written a little script for VoiceXML applications to generate a WAV from an MP3 on demand:

#file wavwrapper.php
<?
header('Content-Type: audio/wav');
$filename = $_GET['filename'];

$mp3dir="/var/www/mp3s/";
$playercmd="/usr/local/bin/mpg123 -m -w - -q -4 --8bit";
passthru("$playercmd $mp3dir/$filename 2> /tmp/playererror");
?>


I request it as wavwrapper?filename=song.mp3, and the browser reads the MIME type properly, prompts me to play or download the song. I download it, and save it as a WAV file. However, Mozilla downloads about 1.5M of data, saves it all to a file, and then displays the downloaded size as 1k. And then when I try to play it back, it won't play; it's like an empty file. Same thing happens if I try to play it directly. But if I redirect the output of mpg123 from standard out (so it goes across the web connection) to a file and then download the file, the file plays just fine. I figure there's something to do with the way PHP dumps back the binary data that just isn't working right, but I don't know what it is. Anyone have any ideas?

--
Soren Harward
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to