Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中播放音频流的Php代码不起作用_Php_Android_Audio Streaming_Live Streaming - Fatal编程技术网

在android中播放音频流的Php代码不起作用

在android中播放音频流的Php代码不起作用,php,android,audio-streaming,live-streaming,Php,Android,Audio Streaming,Live Streaming,您好,我需要您的帮助我需要播放音频流的代码我需要的是,当人们从您的android手机进入php页面时,下载mp3播放器,并以android Prederminado的方式播放此页面中的声音。Perfectament服务很好,但我也会使用此代码,但我被告知问题是如果如果有人知道这个主题,请查看文件,但听起来没有什么问题。。我需要你的帮助 <?php header("Content-type: audio/mpeg"); header("Transfer-Encoding: chunke

您好,我需要您的帮助我需要播放音频流的代码我需要的是,当人们从您的android手机进入php页面时,下载mp3播放器,并以android Prederminado的方式播放此页面中的声音。Perfectament服务很好,但我也会使用此代码,但我被告知问题是如果如果有人知道这个主题,请查看文件,但听起来没有什么问题。。我需要你的帮助

<?php 

header("Content-type: audio/mpeg"); 
header("Transfer-Encoding: chunked");
header("Transfer-Encoding: none"); 
header("Connection: close");

$sock = fsockopen($streamname,$port); 

$streamname = "193.17.192.13"; //IP
$port = "80"; // PORT
$path = "/;stream.mp3"; 


fputs($sock, "GET $path HTTP/1.0\r\n");
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);
?> 

让我们仔细看看从PHP脚本返回的数据。您的响应标题:

HTTP/1.1 200 OK
Date: Fri, 25 Jan 2013 04:19:16 GMT
Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze8
icy-notice1: <BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
icy-notice2: SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
icy-name: Atmosfera 96.5 Grupo Emisoras Unidas
icy-genre: Rock
icy-url: http://www.atmosfera.fm
icy-pub: 1
icy-br: 64
Connection: close
Transfer-Encoding: chunked
Content-Type: audio/mpeg
另外,使用
Transfer Encoding
删除两个
header()
调用

完成后,测试并查看它是否有效。顺便说一下,您可以使用一个工具,例如,轻松查看您的流发生了什么

apache_setenv('force-response-1.0','true');