本教程是在ThinkPHP5.0中进行的,如用在其它程序中,作少量修改即可。/**
* 以文件流输出音频文件
* @author Sindsun
* @date 2018年10月27日22:32:17
* @param $filePath 文件地址
* @param $param 其它参数
* @param $fun 执行一个闭包函数 第一个参数为外部参数
* @output filestream
* @return bool
* */
public function outputStream($filePath,$clientSectionInfo){
if(!file_exists($filePath)){
return false;
}
//返回的文件(流形式)
//对照的完整地址推荐:http://tool.oschina.net/commons/
//header("Content-type: application/octet-stream");
//header("Content-type: audio/mp3");
header("Content-type: audio/mpeg");
header("Age:0");
//按照字节大小返回
//header("Accept-Ranges: bytes");
$fileSize = filesize($filePath);
//$httpRange = $this->request->hea