douxun1407 2010-10-21 14:06
浏览 248
已采纳

php流式传输或缓冲mp3文件问题

I built a mp3 playing website.

I use a flash mp3 player to play the mp3 file.It can play, but it can not load the correct time and not stream and buffer the mp3 file located on my server.

It can play the mp3 file correctly if the url is from other site, like Google music.

I think the important problem is the header output of the mp3 file.

this is the code of my php file to output the mp3 file.

<?php
 $filename='music/'.$_GET['id'].'.mp3';
 $fileSize=filesize($filename);
 header('Accept-Ranges: bytes');
 header('Cache-Control: max-age=604800');
 header('Content-Length: ' . $fileSize);
 header('Content-type: audio/mpeg');
 readfile($filename);
?>

can anyone tell me what`s the problem is?

PS: You can test on Chrome. Just use Chrome to open the file or page, it will display a player to play mp3 file.

  • 写回答

4条回答 默认 最新

  • doujiazong0322 2010-10-22 17:08
    关注

    OK, the problem solved. The actually problem is the Liunx system (Like CentOS and Ubuntu) do not support mp3 streaming.

    To solve the problem, you have to install gnump3d to enable streaming server.

    my site mu6.me can play the music like other music website now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?