flv total time

Posted on 2007-08-12
Last Modified: 2010-08-05
How can i get the total time of a externaly loaded flv video , I am using as3 with the netsream class.
Question by:nysurf1
    LVL 14

    Expert Comment


    Try using NetStream.time()
    LVL 5

    Accepted Solution

    It is considered it is possible with server-side AS when you're using Flash Media Server, but I guess, you don't.

    So you can use onMetaData method.
    Here's a snippet from manual

    var nc:NetConnection = new NetConnection();
    var ns:NetStream = new NetStream(nc);

    ns.onMetaData = function(infoObject:Object) {
        for (var propName:String in infoObject) {
            trace(propName + " = " + infoObject[propName]);

    This causes the following information to be displayed:

    canSeekToEnd = true
     videocodecid = 4
     framerate = 15
     videodatarate = 400
     height = 215
     width = 320
     duration = 7.347
    LVL 5

    Expert Comment

    Note that onMetaData may not work with some flvs (which don't contain any metadata). In this case I can only recommend you to do some calculations with NetStream's bufferLength, bytesLoaded properties and file size. You can determine the estimated length, but it will be veeeeery approximate.

    I suppose you can obtain file size with's onProgress method, although some server-side solution like PHP will do this work better and plainer.

    NetStream.time() is the current video position, isn't it?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now