Reputation: 22565
I'm trying to make a fake live video stream with HTML5 + PHP.
from my php, I have something like below.
$file = fopen("filename.mp4","rb");
fseek($file, 1000);
while(!feof($file) {
fread($file, 1024);
flush();
}
this code outputs correct data. The problem is that HTML5 video tag doesn't like partial content. I think it's because video tag only accept a complete mp4 format.
I've tried to set "HTTP/1.1 206 Partial Content", but it didn't work either.
Is there a way to make html5 video tag to play a partial mp4 content?
Upvotes: 0
Views: 838
Reputation: 7853
Your web server will probably already do this work for you if you use Media Fragments. You can specify a URL with a start time and end time, and your browser will figure out what range of partial content to request from the server.
For example, if you want to watch a video starting at 10 seconds and going to 20 seconds, set the src url to:
http://foo.com/video.ogg#t=10,20
MDN describes the syntax here, and if you're interested there's a more technical slideshow.
Upvotes: 1