mediaelement.js MP3无法播放

问题描述 投票:1回答:1

我用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
laravel audio mp3 audio-player
1个回答
0
投票

我必须设置以下标题:

"Accept-Range" => "bytes"

上班。问题现在已解决。 :)

© www.soinside.com 2019 - 2024. All rights reserved.