If I'm not mistaken, there's a flaw in the logic, as the progress is based on bytesLoaded and bytesTotal, while the shuttle/scrubber is time based.
Only the beginning and end of both will match up (0% loaded = 0 time -- 100% 
loaded = total time).

Make sense?

Most video players out there do it that way though (as you described).

regards,
Muzak

----- Original Message ----- From: "Steven Sacks" <[EMAIL PROTECTED]>
To: "Flash Coders List" <[email protected]>
Sent: Wednesday, December 10, 2008 6:20 AM
Subject: Re: [Flashcoders] video seek ability


Here's what you need to know to make a good scrubber for progressive download 
FLVs.

1. You need a background that shows the entire width of the bar.

2. You need a progress bar that shows how much of the video has loaded. The width of this bar is the background.width * (ns.bytesLoaded / ns.bytesTotal);

3. You need a playback bar or shuttle which is updated on a timer. The width (bar) or position (shuttle) is the background.width * (ns.time / ns.metaData.duration).

4. You put the mouse events on the progress bar. On press, you set a flag that you're seeking (so the update doesn't move the bar/shuttle but does keep the progress bar updated), you pause the video, and you start a timer that calls an update function. In the update function, you track the mouseX and constrain the value (via Math.min and Math.max) to values between 0 and the progress bar width, to which you set the position of the shuttle or width of the playback bar. You take the position/width of the bar, divide it by the background.width, multiply that by the duration of the ns, round it, and that's your seek time. When you release, you unpause the video (assuming the video was playing when you pressed, you'll need to keep a separate flag for that).


If you do it like I've described, then the dragging is always constrained by the current loaded amount, not the loaded amount at the time you pressed, and you don't get that ugly stutter when you stay in one place (there's no reason to not pause the video when scrubbing).

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to