html5 - Is there a way to tell the file size of an .ogg video before it is fully loaded? -


I know that the difference between the OG video and the MP3 video is that the metadata not describing the OG video file size , So an OG video loads, the control can not show up until the time the file is fully loaded. This can be a problem if the OG video is longer than a few minutes. Is there a way to get this file when the page is requested?

(The client-side developer is asking a question that I think is the server-side answer. It can think more specifically about a method of asking.)

Try it.

First of all, grab all .ogv videos transparently with .htaccess and process them with PHP.

.htaccess

  RewriteEngine On RewriteRule ^ (. *) \. Ogv $ ogv.php? File = $ 1   

ogv.php

  & lt ;? Php $ file = $ _GET ['file'] '.ogv'; While (Stropo ($ file, '..')! == Incorrect) {$ file = str_replace ('..', '', $ file); } $ Filesize = filesize ($ file); Header ("Content-Type: Video / OG"); Header ("content-transfer-encoding: binary"); Header ("content-length: {$ filesize}"); Readfile ($ file); Get out ()? & Gt;   

HTML:

  & lt; Video src = "video.ogv" id = "video" control & gt; & Lt; / Video & gt; & Lt; Script & gt; Var video_src = document.getElementById ('Video'). Src; Var xhr = New XMLHttpRequest (); Xhr.open ('GET', video_src, incorrect); Xhr.send (zero); Var size = xhr.getResponseHeader ('content-length'); Warning (size); & Lt; / Script & gt;   

So here's how the system works. Just link a normal .gav video, but the .htaccess file first captures the request and it is sent to OGW.P.P. The PHP file then specifically sends a file size header, if the server does not automatically, it is OK, it still does not do you good, right? Okay, then you can request Ajax for the video and remove the filesystem with the HTTP header.

Hope this will be helpful.

Comments