Custom FLV Scrubber

For some reason my scrubber won’t scrub correctly while the video is loading, but once it has completed it scrubs just fine. Here is my code

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

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

                    mediaPanel.loader_mc.loadbar_mc.onPress = function():Void  {
                        clearInterval(videoInterval);
                        scrubInterval = setInterval(scrubit, 10);

                    };
                    mediaPanel.loader_mc.loadbar_mc.onRelease = function():Void  {
                        clearInterval(scrubInterval);
                        videoInterval = setInterval(videoStatus, 100);

                    };


Here is are the videostatus and scrubit functions

 var duration:Number;

function videoStatus():Void {
    amountLoaded = ns.bytesLoaded/ns.bytesTotal;
    mediaPanel.loader_mc.loadbar_mc._xscale = amountLoaded*100;
    mediaPanel.loader_mc.scrub_mc._xscale = (ns.time/duration)*100;


}

function scrubit():Void {
    newTime = (mediaPanel.loader_mc.back_mc._xmouse/298)*duration;
    trace(newTime);
    ns.seek(Math.floor(newTime));
} 

Here is the site that im working on http://mav-media.com/Maverick click on portfolio, then the first thumbnail under “motion”

and thoughts welcome.

scrubbers are a little bit off until it has fully loaded, but yours is fairly bad.

gotoandlearn…

Thanks, I actually followed that tutorial to begin with, anything in my code that may be incorrect or causing this result :S?

[quote=randomagain;2351221]scrubbers are a little bit off until it has fully loaded, but yours is fairly bad.

gotoandlearn…[/quote]

Why not just edit and rename a default scrubber? I’ve made countless numbers of these and the default ones are relatively easy to edit and customize.

I did have one problem that happened from encoding a rather large video similar to yours being “a bit off”. it seemed that the scrubber wouldn’t work until it was fully loaded, but it turns out sometimes the flv encoding method looses data. There is a tool that i used that fixed the problem. I don’t know it off hand but if you need it hit me with a pm.

What tool? Could you explain what you mean by the default scrubber? Thanks

[quote=jibble;2351435]Why not just edit and rename a default scrubber? I’ve made countless numbers of these and the default ones are relatively easy to edit and customize.

I did have one problem that happened from encoding a rather large video similar to yours being “a bit off”. it seemed that the scrubber wouldn’t work until it was fully loaded, but it turns out sometimes the flv encoding method looses data. There is a tool that i used that fixed the problem. I don’t know it off hand but if you need it hit me with a pm.[/quote]


i have had to use the FLV MetaData Injector GUI 1.05 to fix a few of my flv’s. Seems to be the bigger ones ~15 mins or bigger that i’ve had issues with, but you might want to try it.

As for the actual design and look of the scrubber. Take one of the flash default scrubbers and just edit it. Should be here(for CS3 anyway)…

C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\FLVPlayback Skins\FLA\ActionScript 2.0

copy and paste one or two of those scrubber .fla’s that would be easiest for you to edit and mess around with it. Basically just re-skin it.

i dont want to use the flv component though, any other suggestions on why this isn’t working for me?

it looks like, on press the red bar tries to go to the mouse, but then backs up to where it thinks it should be playing. If this is correct, I kinda think its the videoStatus method.
in the following:


newTime = (mediaPanel.loader_mc.back_mc._xmouse/298)*duration;

  • is 298 the total width of your progress bar?
  • is the newTime tracing appropriately while its loading - and its in milliseconds?
  • are you clearning your intervals correctly? looks like both are always running
  • could it me your _xmouse target - mediaPanel (don’t see how that could change)

In the videoStatus method, trace all of these out:
amountLoaded
amountLoaded*100;
ns.time
duration

see if anything is undefined. I’ve had issues with metadata too, sometimes loading, sometimes not. Also, the metadata seems to lag on loading some times. So if duration isn’t tracing in videoStatus, that seems like it would cause something like whats happening.

  1. 298 is the total width
  2. newTime is tracing correctly (in seconds, not miliseconds)
  3. I think I am clearing them correctly, I’m using clearInterval
  4. all those variables are tracing correctly including duration :S

Use an onEnterFrame instead of setInterval to fire the scrubbing functions.

could you show me how with as 2.0?
thank you

Your code looks like gotoandlearn’s tutorial code, and consequently, this code comes from Lee’s blog:


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 * 208.9;
loader.scrub._x = ns.time / duration * 208.9;
}
loader.scrub.onPress = function() {
vFrame.onEnterFrame = scrubit;
this.startDrag(false,0,this._y,208,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
vFrame.onEnterFrame = videoStatus;
this.stopDrag();
}
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/208)*duration));
}