MP3 streaming code help
Posted: Thu Aug 26, 2004 1:28 am
OK, I looked at the source code of a MP3 jukebox called kplaylist and found code for streaming (transcode) MP3.
LAME 3.96.1 (stable) is used by this script.
It works sort of but while playing the streamed MP3...it only plays a part of the song. It's not a certain amount of time that gets cutoff the end of the song (ie. it'll play 9 seconds for one song while another could be 60 seconds). If anyone can help with this I'd appreciate it.
Code: Select all
<?php
$descriptorspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'));
$process = proc_open('c:/lame/lame.exe --silent --nores --mp3input -h -m s -b 128 "'.$_REQUESTї'file_to_stream'].'" -', $descriptorspec, $pipes);
if(is_resource($process))
{
while(!feof($pipesї1]) && !connection_aborted())
echo fgets($pipesї1], 1024);
fclose($pipesї0]);
fclose($pipesї1]);
proc_close($process);
}
?>It works sort of but while playing the streamed MP3...it only plays a part of the song. It's not a certain amount of time that gets cutoff the end of the song (ie. it'll play 9 seconds for one song while another could be 60 seconds). If anyone can help with this I'd appreciate it.