Skip to content
Advertisement

Check file size of HTML5 video

I have a page with a <source> for an HMTL5 video player; I need to obtain its file size.

Is it possible to check the size in MB of a video uploaded on the server from a <source>?

Does the HTML5 API provide some functions for this? Solutions with PHP or JavaScript are both fine.

Advertisement

Answer

While the best way to do this would be via a server side script that responds to (say) and Ajax request, reads the size of the file and responds (or depending on how the pages are being generated you could add it as a custom property to the element when you create the page the only way I can think of to answer your specific question would be to load the file itself via an ajax request and check the size of the respond – see Why don’t all videos load on page in Chrome? for an example of how to do that

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement