我需要帮助,我正在开发流式音频系统,但我遇到了分块传输编码的问题,实际上我不知道如何让它在 IOS、Android 等设备上可用。有没有分块编码的替代方案?这是我的代码:
<?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);
?>
感谢帮助