FORUMS: list search recent posts

Scrubber & Progress Bar in FLV Player.

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
downtownguy
Scrubber & Progress Bar in FLV Player.
on Jan 24, 2006 at 1:04:17 am

Hi Gang,

I am working on a flash video player based on the uber-cool tutorial by Lee. In addition to the load bar, which indicates how much of the FLV has been loaded, I have added a progress bar, which (along with the scrubber), indicates the position of the video.

I am trying to get the progress bar to drag along with the scrubber, and was hoping one of you could help me out. Here is my action script. Thanks in advance! :)

//---------- LoadBar

var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;

ns["onMetaData"] = function(obj) {
duration = obj.duration;
}

function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadBar._width = amountLoaded * 240;
loader.scrub._x = ns.time / duration * 240;
loader.progressBar._width = ns.time / duration * 240;
}

var scrubInterval;

loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,244.5,this._y);
}

loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
}

function scrubit() {
ns.seek(Math.floor((loader.scrub._x/244.5)*duration));
}

//---------- /LoadBar



Return to posts index

lajoiet
Re: Scrubber & Progress Bar in FLV Player.
on Jan 24, 2006 at 12:54:11 pm

Starting off on a side note, see Lee's note at http://theflashblog.com/?p=5 about modifying the video player code because of problems that may happen from using 2 intervals at the same time.

As for getting your progress bar to move allong with the scrubber bar, all you need to do is add another line into the scrubit function after the seek line to set the progress bar's list, which should be the same as the one in the code in the videoStatus function:

loader.progressBar._width = ns.time / duration * 240;

or you could use the loader.scrub._x property to set the width of the progress bar if there is too much lag on the seek command to keep up.


Return to posts index

downtownguy
Re: Scrubber & Progress Bar in FLV Player.
on Jan 24, 2006 at 7:13:55 pm

Thank you, for this solution! It worked like magic. I am a complete newbie when it comes to ActionScript, so I'd like to thank you for your patience in answering my question.

Anyway, here is my new script, thanks to you and Lee's blog post:

//---------- LoadBar

this.createEmptyMovieClip("vFrame",this.getNextHighestDepth());
vFrame.onEnterFrame = videoStatus;
var amountLoaded:Number;
var duration:Number;

ns["onMetaData"] = function(obj) {
duration = obj.duration;
}

function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadBar._width = amountLoaded * 240;
loader.scrub._x = ns.time / duration * 240;
loader.progressBar._width = loader.scrub._x;
}

loader.scrub.onPress = function() {
vFrame.onEnterFrame = scrubit;
this.startDrag(false,0,this._y,244.5,this._y);
}

loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
vFrame.onEnterFrame = videoStatus;
this.stopDrag();
}

function scrubit() {
ns.seek(Math.floor((loader.scrub._x/244.5)*duration));
loader.progressBar._width = loader.scrub._x;
}

//---------- /LoadBar



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]