4 Replies Latest reply on Jun 13, 2007 4:46 AM by Greg Dove

    flv counter

    Pewee2000
      Hi there,

      The basics of it are - I'm trying to come up with a way to start/stop a timer when a cue point is hit. like a start stop on a stopwatch. Its for a piece of race footage where the lap starts some time through the flv.

      Now more in depth - I want the timer to be a dynamic text box that when you scrub back and forth on the flv playhead
      the timer responds acordingly as if it were the flv timecode. Now there are 2 ways I can see this going. First to write a large lump of code and design a custom timer, or offset the flvs time in actionscript so that when it hits the first cue point it has reached 0 and the cue point would tell the alpha of the dynamic text box to change from 0% to 100% (so it looks like it has started on the cue point)..

      Which is easier and how would I go about writting the action script for it.

      I know this is a big project, but im hoping that there is a way to offset as I think this might be a quicker option.

      Thanks in advance for anyone who would know how to tackle this.
        • 1. Re: flv counter
          crazyjoemilan Level 2
          I just built one of these actually. You'll want to find a way to attach the clip's progress to actual time, which it will give you. I forget the exact code at the moment, but its very possible--especially since .flv's now pass metadata when you ask them to.

          getProgress() I think is the basis for your functions. Check it out and let me know.
          • 2. Re: flv counter
            Greg Dove Level 4
            Are you using the FLVPlayback component? If so, I'd probably use the offset approach you mentioned.

            If you use the cuepoint to trigger the start of your timer, consider that it will never happen if someone scrubs into the 'timer' range from outside.....so you may need to set it up as a listener for the whole video in the playheadUpdate event.

            If you use the cuepoint approach, once the cuepoint triggers, you know the playheadTime from the cuepoint event data already (or you can check it as playheadTime) and set this as your 'zero' time and fade in your textfield or whatever. You may want the listener even set up without the cuepoint... if they scrub over the cue point and arrive in the "timer" range somewhere, the cuepoint never fired and so the timer doesn't show. Or you could do it the same way using the playheadUpdate and a check for proximity to the 'zero' time (which you have hard coded) to start the fade in.

            Whether its set up by the cuepoint, or you set it up for the whole video, you just need to set up a listener for playheadUpdate event (change the playheadUpdateInterval if you want it to be more frequent than 0.1 secs - its probably OK as is for what you want).
            In the listener, first check that the playheadTime is within the range that you want it to be visible. If its not then I'd make the text field instantly not visible (you could fade it out if it was close to the time when it would normally fade while "playing" ,but if its scrubbed out of the 'timer' range then probably you want it to be instantly gone rather than fade...? ) .

            If its in range, then you could check and see if the textfields _visible property is false (which may be the case if it was scrubbed into the middle of the timer range from outside ) and if so make it true. And then assign it the value of the current playheadTime minus the 'zero' playheadTime like you described.

            • 3. Re: flv counter
              Pewee2000 Level 1
              Here is what I have so far that is working:

              import mx.video.*;
              my_FLVPlybk.playheadUpdateInterval = 1;
              var listenerObject:Object = new Object();
              listenerObject.playheadUpdate = function(eventObject:Object):Void {
              trace("playhead time is: " + eventObject.playheadTime);

              // dynamic text fields instance name is 'playtime'
              playtime.text = eventObject.playheadTime;
              };
              my_FLVPlybk.addEventListener("playheadUpdate", listenerObject);
              my_FLVPlybk.contentPath = " http://www.helpexamples.com/flash/video/water.flv";

              I cant work out how to offset the playhead information so that it starts at 0 after 3 seconds into the clip
              also having difficutly setting the alpha to 0 untill 3 seconds in
              • 4. flv counter
                Greg Dove Level 4
                try something like this
                [ edit info: I removed a redundant line of code ]