views:

1575

answers:

1

I'm trying to troubleshoot the scrubber for a custom video player and I'm coming across an issue with the scrubber being dragged past the progress bar fill if the flv hasn't fully loaded.

The player is here: http://mindfilemultimedia.com/stage/portfolio.html

If you play the video you will see that while the flv is still downloading, when you move the scrubber past the yellow progress bar into the white part of the line, the video player will freeze. It is doing that because the user is telling it to seek to a part of the video that has not been fully downloaded yet. What I want it to do is determine if the flv is still downloading and restrict the user to only be able to drag the scrubber up until the width of the yellow progress bar. Right now I have set the code to retrieve the bytesLoaded and bytesTotal and what I want to do is to say something like (in actionscript 3):

if (videoPlayer.bytesLoaded < videoPlayer.bytesTotal) {
    var newBounds:Rectangle = new Rectangle(0, 0, (videoPlayer.bytesLoaded/videoPlayer.bytesTotal) * MovieClip(root).SeekBar.SeekProgressBar.width, 0);
    MovieClip(root).SeekBar.SeekBarHandle.startDrag(false, newBounds);
}

I am by no means an actionscript person, so that was my attempt at doing what I needed. I have a feeling that it is not working because I'm accessing the classes incorrectly for the progress bar and the scrubber handle, but I am just taking the default classes as the seekbar was a flash components. Well, I can just be completely wrong. Any help here would be appreciated.

A: 

Where are you putting this code? It needs to be put somewhere, where it is updated regularly. Depending on what type of video player you were using you could see what events it dispatches and use an event listener to regularly check how much has been buffered. You could also use the enter frame event although you would need to make sure you stopped listening once the buffer is complete as it would add extra overhead on every frame.

As a side note SeekBar and SeekBarHandle should probably be seekBar and seekBarHandle respectively, as it's standard practice to start instance names with a lowercase letter in actionscript.

James Hay