I need a help, I am working on a streaming audio system, and I have a problem with chunked transfer encoding, actually I don't know how to make it workable on the IOS, Android etc. Is there any alternative of chunked encoding? This is my code:
<?php
header('Transfer-Encoding: chunked');
header('Content-Type:audio/mpeg');
header('Connection: keep-alive');
ob_clean();
flush();
$buffer = '';
$handle = fopen($filepath, 'rb');
if($handle === false){
return false;
}
while(!feof($handle)){
$buffer = fread($handle, 8192);
echo sprintf("%x\r\n", strlen($buffer));
echo $buffer;
echo "\r\n";
ob_flush();
flush();
}
echo sprintf("%x\r\n", 0);
echo "\r\n";
fclose($handle);
?>
Thanks for help