5 Replies Latest reply on Sep 4, 2007 11:46 AM by Greg Dove

    FLV Time Display

    shojinate
      Hi, I have an FLV video using "progressive download from a web server". I would like to display the playback time during the video. I've done some searching and found a bit on how to do this, but not enough for me to apply it myself since I'm not too hot with action script yet.

      I found this code in the flash help section which might be what I need:

      var listenerObject:Object = new Object();
      listenerObject.cuePoint = function(eventObject:Object):Void {
      trace("Elapsed time in seconds: " + my_FLVPlybk.playheadTime);
      trace("Cue point type is: " + eventObject.info.type);
      }
      my_FLVPlybk.addEventListener("cuePoint", listenerObject);

      ...but I'm not sure how to apply it correctly. Could someone guide me through it? I believe I also need to set up a dynamic text field for the time display... how can I do this? Maybe there's a better way to do it altogether?

      Thanks you!
        • 1. Re: FLV Time Display
          Greg Dove Level 4
          You don't need the cuePoint event if you just want to display current playheadTime.

          This is what you need. There's an example at the bottom of that page doing what you want.

          http://livedocs.adobe.com/flash/9.0/main/00003037.html#wp3726400

          Instead of the trace output used there you would set you dynamic textfield to have the
          eventObject.playheadTime
          value.

          e.g.
          myTimeDisplay.text=eventObject.playheadTime;



          • 2. Re: FLV Time Display
            shojinate Level 1
            Wonderful, thank you! Now I'd just like to polish the time display element a little if possible.

            What I'm getting is a count of seconds and milliseconds without any rounding. How do I tell it to round to the nearest second (no milliseconds), and then into minutes (instead of countinuing the count over 60+ seconds)?

            I would also love the initial display to read something like: 0:00, where the 0's get filled in when they get used, like if it's at 45 seconds it'd be: 0:45; then at 2 minutes and 30 seconds it'd read 2:30 and so on...

            Here is the code as I'm using it now:

            // Time Display
            import mx.video.*;
            var listenerObject:Object = new Object();
            listenerObject.playheadUpdate = function(eventObject:Object):Void {
            timeDisplay1.text=eventObject.playheadTime;
            };
            EQUO_GlitterGirl.GlitterGirl.addEventListener("playheadUpdate", listenerObject);
            EQUO_GlitterGirl.GlitterGirl.contentPath = "Music/GlitterGirl.flv";
            • 3. FLV Time Display
              Greg Dove Level 4
              I haven't checked this to see if it has syntax errors or if it does what you want, but I think its on the right track

              listenerObject.playheadUpdate = function(eventObject:Object):Void {
              var wholeSecs = Math.round(eventObject.playheadTime);
              var dispMin= Math.floor(wholeSecs /60);
              var dispSec=wholeSecs%60;
              timeDisplay1.text=dispMin+":"+(("0"+dispSec).substr(-2));
              };
              • 4. FLV Time Display
                shojinate Level 1
                Whoa, thanks for your super speedy reply. It works perfectly and does everything I wanted!
                • 5. Re: FLV Time Display
                  Greg Dove Level 4
                  no problems. You're welcome.