0

I have this code that basically makes a video on an FTP server able to be displayed in a tag on another page. But when viewing the video, it is not possible to return and back in time, I already tried a series of things but always the error when I try to get the file from the ftp server, with a normal file (file.mp4 ex) it works, wanted Learn how I can enable video time advance

            $path = "http://cd1.animakai.tv/teste/hd/1031.mp4";
            header('HTTP/1.1 206 Partial Content');
            header('Content-type: video/mp4');
            header("Content-Length: ".$size);
            header("Accept-Ranges: bytes");
            header("Content-Range bytes");


            $handle = fopen($path, "rb");
            while (!feof($handle)) {

              echo fread($handle, 1000 * 1024);

            }
            fclose($handle);

1 Answers1

0

The problem with your code is that you send the browser the whole file as a stream but provide no way for it to seek forward or back within the video. For this tow work, you'll need to let the browser know how big the file is (through content-length header) and you'll need to be able to handle requests for any part of the file, rather than the whole file (by reading the 'Range' header and sending only the piece of the file that the browser wants.

Take a look at this answer

BeetleJuice
  • 39,516
  • 19
  • 105
  • 165