This site is optimised for Firefox 2.0 or Internet Explorer 7.

Progressive Flash Video loadbar vs playbar issues

circlecube has no avatar
circlecube
 
Post Count: 1
Joined: Mon Apr 27, 2009 8:28 pm
Location: Atlanta, GA
Flash Version: Adobe Flash CS3

Progressive Flash Video loadbar vs playbar issues

Postby circlecube on Tue Apr 28, 2009 7:49 pm

I'm creating a flash video player in as3 and am realizing something. Video has a variable bit rate. Most player code I have seen before (which shows progress of video download) uses the bytesLoded / bytesTotal to calculate the amount loaded and display in the time bar, we'll call this the size bar because it relates to the filesize. Video time is also displayed in the time bar as the currentTime / totalTime, and as this relates to file time we'll call it the time bar. However since video is variable bit rate, the time bar and the size bar are not interchangeable. If we imagine an extreme example video that is first half live action with lots of colors and movement and the second half is a still image slideshow, understandably the first half of the video will be larger in file size, so the first half of the sizebar would not correctly represent the first half of the time bar. So the user who watches the video load and loads halfway, scrubbing to halfway through the video, the player will not be able to play yet because that time is not yet loaded. So if we allow scrubbing through the video by clicking on the loaded bar, there is a good chance that part of the video may not actually be loaded.
Calculating display bar:
Code: Select all
//bar is display bar mc
//bar.bg.width is used as a constant to scale the percentage to the full bar width
bar.sizebar.width = (ns.bytesLoaded / ns.bytesTotal) * bar.bg.width;
bar.timebar.width = (ns.time / duration) * bar.bg.width;

Scrub on click
Code: Select all
//calculate from percentage of bar width to time for seeking to
jumpSeekTo = (bar.mouseX / bar.bg.width) * duration;
ns.seek(jumpSeekTo);

A possible simple solution I've thought of is to just display a loading graphic if they click a time which has not yet loaded, but that seems counter intuitive and backwards, since the load bar would display that time as having being loaded.

I have not seen anything in documentation or online that suggests any other way to display the amount loaded. Is there a way to know what time has loaded in the video and display that in the loadbar rather than display the percent of kb loaded?

allhailneuveville has no avatar
allhailneuveville
 
Post Count: 4
Joined: Mon May 04, 2009 4:21 am
Flash Version: Adobe Flash CS3

Re: Progressive Flash Video loadbar vs playbar issues

Postby allhailneuveville on Mon May 04, 2009 4:54 am

Did something similiar to what you are doing. There is another alternative by playing a low-res video first while loading the high-res video then once the high-res video is loaded. You could then replace the low-res with the high-res.

To get the current time you could use:
FLV.duration / ns.bytesTotal * ns.bytesLoaded= total time loaded in seconds(TS)
I guess with that, you can come up with the time loaded. It should work.


Return to Actionscript 3.0

Who is online

Users browsing this forum: Kirone and 5 guests