【发布时间】:2012-11-24 15:18:06
【问题描述】:
Shoutcast 服务器无法生成有效的 HTTP 资源。我们的移动播放器链接 (Android) 需要有效的 HTTP 资源。我如何使用 php 脚本进行直播流?此脚本提供有效的 http 资源?有谁知道吗?
<?php
$track = "shoutcaststream.mp3";
if (file_exists($track)) {
header("Content-Type: audio/mpeg");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: inline; filename="shoutcaststream.mp3"');
header('X-Pad: avoid browser bug');
header('Cache-Control: no-cache');
readfile($track);
exit;
} else {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
echo "no file";
}
更新 2
按照“Brad”的指示,现在一切正常。我们使用 set_time_limit(0) 但是我的流在 3 分钟到 5 分钟后仍然关闭?怎么修?请帮助我.. :)
【问题讨论】:
-
我的意思是shoutcast mp3输出没有“Content-Type”
-
你问它是否是一个有效的 HTTP 资源,然后你说它有
Content-Type,而在你的代码中你有header("Content-Type: audio/mpeg");。太模糊了…… -
大家好,他的问题没有错。他遇到的问题是使用 SHOUTcast 流时的一个众所周知的问题。
标签: php streaming mp3 shoutcast