0

我有一个在网页中运行的嵌入式 mp3 播放器。当我将物理 mp3 的路径加载为文件 url 时,它工作得很好,但是当我尝试从 php 端点加载 mp3 二进制数据时,它会失败。

这是我通过 php 输出 mp3 数据的方法:

//Begin writing headers
header( 'Pragma: public' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Cache-Control: public' );
header( 'Content-Description: File Transfer' );
header( 'Content-Type:audio/mpeg');
header( 'Content-Disposition: inline;');
header( 'filename=SoundFile.mp3' );
header( 'Content-Transfer-Encoding: binary' );

//supply the length
$len = strlen($res['ReturnValue']);
header( 'Content-Length: ' . $len );

echo $res['ReturnValue']; exit();
// $res['ReturnValue'] is the actual binary data of the mp3

此外,当我在浏览器中运行该 php 代码时,它会导致下载正确名称和文件大小的文件,但文件本身不会在任何东西(itunes / winamp / 等)上播放,就好像它已损坏一样。

我在输出这些数据导致它无法在嵌入式 mp3 播放器中播放时做错了什么?

4

1 回答 1

0

字节数据没有正确输出给我,因此,我的标题不是问题。

于 2012-06-04T21:44:30.687 回答