我在使用mediaelements.js播放 MP3 文件时遇到问题。在我的 AJAX 请求中,我获取了我的 MP3 文件并设置了音频 src。
如果我通过 URL 获得真正的 MP3,例如:
http://host.com/real/path/tp/mp3
并将其设置为我的音频 src 播放器运行良好。
现在......当我通过一个从我的存储文件夹中获取 MP3 的脚本请求我的 MP3 时,如下所示:
$headers = array(
'Content-Type' => File::mime(File::extension($mp3)),
'Content-Length' => filesize($mp3),
'Content-Transfer-Encoding'=>'',
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
);
return Response::make(readfile($mp3), 200, $headers);
播放器开始播放 MP3 文件,但我无法卷曲。:(
真实 MP3 路径的响应头:
HTTP/1.1 200 OK
Date: Tue, 26 Mar 2013 18:47:27 GMT
Server: Apache/2.2.16 (Debian)
Last-Modified: Tue, 26 Mar 2013 14:37:28 GMT
ETag: "8d4b852-7b7342-4d8d4dc53fa00"
Accept-Ranges: bytes
Content-Length: 8090434
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: audio/mpeg
发送 MP3 的 Laravel 脚本的响应标头:
HTTP/1.1 200 OK
Date: Tue, 26 Mar 2013 19:02:33 GMT
Server: Apache/2.2.16 (Debian)
Content-Length: 6330826
content-transfer-encoding: binary
cache-control: must-revalidate, post-check=0, pre-check=0, private
Set-Cookie: laravel_session=16f4d83c0ce0262a90df3a0229f8b8ba261eaad7%2BDZIBuW8nbRbBMT7Nvu0NGQ9Rfqaiu6SAS 1wGjYse; expires=Tue, 26-Mar-2013 20:02:33 GMT; path=/; httponly
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: audio/mpeg