来自FTP的Chrome opus文件播放

时间:2015-07-02 14:19:02

标签: html5 google-chrome ftp mime-types opus

我一直试图通过提供php脚本来源,通过HTML5音频标签制作chrome play opus音频文件。 这在mozilla中运行良好,但chrome会出现错误“资源被解释为文档但使用MIME类型传输音频/ ogg ”。

<td>
  <audio preload='none' id='$row[FILE_NAME]' controls='controls'>
  <source src='../../functions/play.php?FILE=$row[FILE_NAME]' type='audio/ogg; codecs=opus' />
  </audio>    
</td>

以下是从ftp

下载音频文件的脚本代码
<?php 
if (isset($_GET["FILE"]) && ($_GET["FILE"]!=""))
{
    $FILENAME=$_GET["FILE"];
    $ftp_server = "server";
    $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to    $ftp_server");
    $login = ftp_login($ftp_conn, 'username', 'password');
    $fsize = ftp_size($ftp_conn, $FILENAME);

    header('Content-disposition: inline; filename="'.$FILENAME.'"');
    header('Content-Type: audio/ogg');
    header('Content-Length: '.$fsize);

    $path = "ftp://username:password@server/".$FILENAME;

    $handle = fopen($path, "rb");

    if (FALSE === $handle) exit("Failed to open stream to URL");

    $contents = fpassthru($handle);

    fclose($handle);

    print ($contents);
}

else exit("No filename recived");
?>

0 个答案:

没有答案