我有一个音频流,一些音频文件在HDD中,一些在线,代码是,
<?php
ignore_user_abort(true);
set_time_limit(0);
$mime_type = "audio/mpeg";
header("Content-type: {$mime_type}");
$files[0] = "audio/abc def.mp3";
$files[1] = "http://www.bootstrap-template.com/templates/HTML5//300111377/audio/mp3/FrankSinatra-BarbaraStraizand-Crush.mp3";
$files[3] = "audio/ghij.mp3";
$files[4] = "http://193.111.141.116:8888/stream";
/*print_r(headers_list());
print_r(get_headers($files[3]));
print_r(getallheaders());
exit();*/
while (true)
{
foreach ($files as $key => $value)
{
$filename = $value;
if($fh = fopen("$filename","r"))
{
while (!feof($fh))
{
echo fgets($fh);
}
fclose($fh);
}
}
}
使用Firefox时,在播放第一首歌曲时就可以正常工作(不在chrome中,并且未在其他浏览器中进行测试)。它在第一和第二磁道的断点处产生噪声并继续,在第三磁道的时间再次产生噪声并且不继续。错误日志中没有任何内容。我正在使用HTML5播放器。
该脚本的目的是,如果
$file[4]
停止,则使流运行
最佳答案
您可以使用html5播放器播放文件。在Chrome浏览器中,内置Flash Player UC浏览器相同。在Firefox中,请使用Adobe Flash。在这种情况下,您无法播放文件。
关于php - PHP mp3流在连接点出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41262098/