actionscript-3apache-flexflash-builderflex4.7

How to display the time length of video (current time/ total time)?


I would like to ask how to display the displayed time of the video which show only in system using AS 3.0. Example: it show the seek time and total time using trace(). It there any information or solution to solve it? I appreciate it any of you able to answer it. ^^ Thank you.


Solution

  • I assume that you are using a NetStream object to stream your video?

    If so, the NetStream class has a variable called time which gives you the seek time in seconds.

    var ns:NetStream;
    // load video, etc
    ...
    // update every frame
    stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    function onEnterFrame(e:Event):void {
        trace("seek time: " + ns.time);
    }
    

    As for the total time, you can get that from the video's metadata by listening to the onMetaData event. See here.