Web ページで実行している埋め込み 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 プレーヤーで再生されない原因となっているこのデータの出力の何が間違っていますか?