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条)

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂