我正在尝试设置一个可以收听多个(私有)流的页面.不幸的是我无法让它运行.我尝试使用php在Android上打开实时音频流,但由于某种原因,浏览器在加载脚本时卡住了.
请参阅下面的脚本以及工作主机的示例(请参阅http://icecast.omroep.nl/radio4-bb-mp3)
请有人请赐教.
Tnx提前!
$host = "icecast.omroep.nl";
$port = 80;
$sub = "/radio4-bb-mp3";
$sock = fsockopen($host,$port, $errno, $errstr, 30);
if (!$sock){
throw new Exception("$errstr ($errno)");
}
header("Content-type: audio/mpeg");
header("Connection: close");
fputs($sock, "GET $sub HTTP/1\r\n");
fputs($sock, "Host: $host \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);
Run Code Online (Sandbox Code Playgroud)