dp815292 2018-12-19 12:32
浏览 183

使用PHP输出M4A音频文件(Chrome问题)

When I embed an M4A audio file directly into HTML and load the page into Chrome, everything works perfectly. I can select the position in the progress bar and the selected position will be played.

However, I want to perform some preliminary checks when I call the file, so I load the file via PHP. If I then embed this file in the HTML, the playback also works perfectly, but I can no longer jump to the desired position in the progress. Whenever I click in the progress bar, it jumps back to the previous position.

I therefore assume that I have an error in my PHP header:

$file = 'test.m4a';

if(file_exists($file)) {
    header('Content-Type: audio/mp4');
    header('Content-Disposition: inline;filename="'.$file.'"');
    header('Content-length: '.filesize($file));
    header('Cache-Control: no-cache');
    header("Content-Transfer-Encoding: chunked"); 

    readfile($file);
}

This is my HTML integration (I don't think that the problem is here):

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <audio controls preload="auto" style="width:480px;">
            <source src="audio.php"  type="audio/mp4"/>
            <p>Your browser does not support HTML5 audio.</p>
        </audio>
    </body>
</html>

In Firefox also the PHP version works perfectly and I can freely choose the playback position, only in Chrome I have the problem.

Can anyone help me? Thank you

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
    • ¥15 画两个图 python或R
    • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
    • ¥15 八路抢答器设计出现故障
    • ¥15 opencv 无法读取视频