我们有shoutcast / icecast音频流.我希望能够在我们的网站上提供一个名为mobiledroid.php的链接,该链接将使用默认播放器打开.我见过这个
done on another site,所以我知道这是可能的.
我假设它使用php头文件和流通过php文件作为流?
使用Brad的说明,android实际上提供了使用声音播放器打开的选项.好一个.
它也可以通过PC在WMP上播放,但不在Android上如何播放上述链接
header("Content-type: audio/mpeg");
header("Transfer-Encoding: chunked");
header("Connection: close");
$sock = fsockopen($streamname,$port); //$streamname is the IP
fputs($sock, "GET $path HTTP/1.0\r\n"); //path in my case is /;stream.mp3
fputs($sock, "Host: $ip\r\n");
fputs($sock, "User-Agent: WinampMPEG/2.8\r\n");
fputs($sock, "Accept: */*\r\n");
fputs($sock, "Icy-MetaData:1\r\n");
fputs($sock, "Connection: close\r\n\r\n");
fpassthru($sock);
fclose($sock);
在android上,它说“抱歉,这个播放器不支持这种类型的音频文件”
更新2:
删除“转移编码”将在Android上播放,但由于实时流没有“内容长度”,通常需要很长时间才能以“准备”状态开始播放流
header(“Transfer-Encoding:none”);也从上面的代码中删除:
引用布拉德:
Android 2.3 and later has an issue with Transfer-Encoding set to “none”. Removing that hard-set header puts the stream back to chunked Transfer-Encoding. This works great for Android 2.3+. Originally I had disabled chunked encoding as VLC doesn’t support it. It also seems that Android 2.2 and older does not support chunked encoding.
注意到虽然它适用于Android,但大多数直播流将需要花费大量时间才能开始.