Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.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
MP3 Flash播放器PHP readfile()缓冲区_Php_Buffer_Mp3_Flash - Fatal编程技术网

MP3 Flash播放器PHP readfile()缓冲区

MP3 Flash播放器PHP readfile()缓冲区,php,buffer,mp3,flash,Php,Buffer,Mp3,Flash,我有一个mp3 flash播放器,它可以完美地播放歌曲的加载部分 <embed src="player.swf" width="70" height="15" FlashVars="song=songs/song.mp3"/> 它与播放/停止按钮完美配合,但问题是,这样它不会显示歌曲的加载部分。在搜索提示/代码/答案几个小时后,我从Anidya找到了一个代码,由Mihai Iorga编辑,最终对我有效,请检查问题。守则: <embed src="player.swf" wi

我有一个mp3 flash播放器,它可以完美地播放歌曲的加载部分

<embed src="player.swf" width="70" height="15" 
FlashVars="song=songs/song.mp3"/>

它与播放/停止按钮完美配合,但问题是,这样它不会显示歌曲的加载部分。

在搜索提示/代码/答案几个小时后,我从Anidya找到了一个代码,由Mihai Iorga编辑,最终对我有效,请检查问题。守则:

<embed src="player.swf" width="70" height="15" 
FlashVars="song=songs/song.mp3"/>
set_time_limit(0);
$dirPath = "path_of_the_directory";
$songCode = $_REQUEST['c'];
$filePath = $dirPath . "/" . $songCode . ".mp3";
$strContext=stream_context_create(
    array(
        'http'=>array(
        'method'=>'GET',
        'header'=>"Accept-language: en\r\n"
        )
    )
);
$fpOrigin=fopen($filePath, 'rb', false, $strContext);
header('Content-Disposition: inline; filename="song.mp3"');
header('Pragma: no-cache');
header('Content-type: audio/mpeg');
header('Content-Length: '.filesize($filePath));
while(!feof($fpOrigin)){
  $buffer=fread($fpOrigin, 4096);
  echo $buffer;
  flush();
}
fclose($fpOrigin);

所以我刚刚在我的song.php中替换了这段代码,现在它工作得非常完美

啊!!有人试图使用4天前再次发布的flash bug。你是什么意思?这是php的一个bug?不,只是瑞士奶酪中又一个叫做flash的漏洞,希望最后一个用户是昨天卸载的。Op,如果可以,请回答您的问题。你可以自己回答。谢谢你的建议。我做到了。
set_time_limit(0);
$dirPath = "path_of_the_directory";
$songCode = $_REQUEST['c'];
$filePath = $dirPath . "/" . $songCode . ".mp3";
$strContext=stream_context_create(
    array(
        'http'=>array(
        'method'=>'GET',
        'header'=>"Accept-language: en\r\n"
        )
    )
);
$fpOrigin=fopen($filePath, 'rb', false, $strContext);
header('Content-Disposition: inline; filename="song.mp3"');
header('Pragma: no-cache');
header('Content-type: audio/mpeg');
header('Content-Length: '.filesize($filePath));
while(!feof($fpOrigin)){
  $buffer=fread($fpOrigin, 4096);
  echo $buffer;
  flush();
}
fclose($fpOrigin);