1

MP3 ファイルの内容を取得し、必要に応じてヘッダーを設定する次のコードがあります (?):

$file = fopen("test.mp3","r");
$content = fread($file,filesize("test.mp3"));

header("Content-Type: audio/");
header("Content-Length: " .(string)(filesize("test.mp3")) );

fclose($file);

echo $content;

ファイルを再生するには、audiojs ( http://kolber.github.io/audiojs/ ) を使用します。PHP ファイルは、通常の MP3 ファイルと同じようにデータ ソースとして機能します。

audiojs はこの MP3 ファイルを再生できますが、プレーヤーのバッファリングを視覚的に確認できますが、MP3 ファイル内の既にバッファリングされている位置にジャンプすることはできません。実際の MP3 ファイルの場合、これは可能です。

MP3ファイルとして機能するPHPファイルを使用しないのはなぜですか? PHPまたはaudiojsが理由ですか?

次のコードも試しました。

// Try and open the remote stream
  if (!$file = fopen("test.mp3","r")) {
    // If opening failed, inform the client we have no content
    header('HTTP/1.1 500 Internal Server Error');
    exit('Unable to open remote stream');
  }

  $stream = stream_get_contents($file);

  // It's probably an idea to remove the execution time limit - on Windows hosts
  // this could result in the audio stream cutting off mid-flow
  set_time_limit(0);

  // Inform the client we will be sending it some MPEG audio
  header("Content-type: audio");
  header("Content-Length: ".(string)(filesize("test.mp3")) );
  header("Content-transfer-encoding: binary");

  // Send the data
  fpassthru($stream);

どちらも機能していません:( 可能性はありますか?パーミッショントピックにはこの機能が本当に必要です.または、.htaccess以外の代替手段はありますか?

キャプタン2

4

0 に答える 0