我需要一种方法来下载一个mp3文件,同时从m4a转换为mp3。
我试过这个代码,它可以工作,但是,当我播放歌曲时,它有错误的持续时间,如果歌曲有3分钟的长度,那么当通过这个函数下载时,它的长度是3:40左右
set_time_limit(0);
$local_file = 'song.mp3';
$download_file = 'song.mp3';
if(file_exists($local_file) && is_file($local_file)) {
header('Content-Description: file transfer');
header('Content-Disposition: attachment; filename='.$download_file);
header("Content-Transfer-Encoding: binary");
header("Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3");
$perSecond = 500000;
$file = fopen($local_file, 'r');
while(!feof($file)) {
echo fread($file, $perSecond);
flush();
sleep(11);
}
}
有没有办法做到这一点?谢谢!
https://stackoverflow.com/questions/56227982
复制相似问题