How to stream a media file using PHP?

≡放荡痞女 提交于 2019-12-03 01:30:00
Sjoerd

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.

Martin Holzhauer

What you want is called "Content-Range requests"

Have a look here Resumable downloads when using PHP to send the file?

I came across this recently which may help you:

http://www.jasny.net/articles/how-i-php-x-sendfile/

Rather than passing the whole file through PHP (which eats up memory), you can use x-sendfile. This is an Apache module which allows you to run a PHP program, but pass control back to the web server to handle the actual file download once your code has done what it needs to do (authentication, etc).

It means that your PHP code doesn't have to worry about how the file is served; let the web server do what it's designed for.

Hope that helps.

Here is a good tutorial for it, you only want the PHP section but still: http://www.devshed.com/c/a/PHP/Video-Streaming-PHP-Script-Tutorial/3/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!