I would like to know the size of the movie I am watching on any video site [ if not possible on all video sites, then at least on YouTube ]. So is it possible, say I will specify the complete path like: 'http://www.youtube.com/watch?v=7xyuX7u-Xts'
, to calculate the size of the Flash video (.flv) using JavaScript?
Note
*B开发者_JAVA技巧y saying size I meant filesize, not the dimension. Sorry if it was creating any ambiguity. [ @cristoph ]Yes. Look for the content-length in the header with an XmlHttpRequest if you're looking to find out the .swf filesize.
Edit: If you're looking for the actual video size that gets streamed to your computer and not the just the player's filesize, you probably will have to do a little estimation. Take the total bitrate in kbits per second for the video and multiply it by the number of seconds of the video length, which is available in the video page javascript source:
yt.setConfig({
//... (snip)
'SWF_ARGS': {..., "length_seconds": "727", ...}
//... (snip)
}
Hope this helps get you started.
精彩评论