如何使用PHP流媒体文件? [英] How to stream a media file using PHP?
问题描述
$ $ $ $ $ $ $ $ $ $ $ $ $ $> $ // HTTP / 1.1
header(Expires:Sat,26 Jul 1997 05:00:00 GMT); //过去的日期
header(Content-Type:{$ file-> getMimetype()});
header(Content-Disposition:inline; filename =。$ filename。;);
header(Content-Length:.strlen($ file_content));
echo $ file_content;
除了当我尝试转发视频或音频时,每件事情都很好,(我的意思是假设当前播放位置是0:15,直接进入1:25),媒体停止,当我再次按下播放按钮时,它从头开始。
I认为问题是与缓冲,但无法弄清楚。我在做什么错误的标题或其他东西是必需的。
谢谢。
I am trying to build an application in which i have to stream the media files (audio and video) to the browser. I am reading the file through php and send the data to browser. I am using the following code.
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-Type: {$file->getMimetype()}");
header("Content-Disposition: inline; filename=".$filename.";");
header("Content-Length: ".strlen($file_content));
echo $file_content;
Every thing is working fine, except when i try to forward the video or audio, (I mean suppose current play location is 0:15 and it directly go to 1:25), media stops and when i press the play button again, it starts from the beginning.
I think the problem is with the buffering, but can't figure it out. Am i doing something wrong in header or something else is required.
Thanks.
I think you need to implement the Range header, so that the client can skip to a specific position in the file. You can probably find out what goes wrong by sniffing the request the player sends.
这篇关于如何使用PHP流媒体文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!