Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5989749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:08:45+00:00 2026-05-22T23:08:45+00:00

I have a class which load and play a flv video file. My problem

  • 0

I have a class which load and play a flv video file. My problem is, How can I get the flv`s duration in my main code? ..
This is my video class:

package src {     
    import flash.display.Sprite;     
    import flash.media.Video;     
    import flash.net.NetConnection;     
    import flash.net.NetStream;      
    import flash.events.Event;
    import flash.events.MouseEvent;

        public class vplayer extends Sprite{                 
            public var vid:Video = new Video(1920,1080);
            private var nc:NetConnection = new NetConnection();
            public var ns:NetStream;
            public var listener:Object = new Object();

            public function vplayer():void{             
                addChild(vid);
                nc.connect(null);
                ns = new NetStream(nc);
                vid.attachNetStream(ns);
                listener.onMetaData = metaDataHandler;
                ns.client = listener;           
                //customClient.onCuePoint = cuePointHandler;
            }
            public var time00:Number = 0;
            public function playVideo00():void{
                ns.play("image00/mov00.flv");
            }
            public function stopVideo00():void{
                ns.close();
            }
            /*public function cuePointHandler(infoObject:Object):void {
                trace("cuePoint");
            }*/
            public function metaDataHandler(infoObject:Object):void {
                trace (" Time:  " + infoObject["duration"]);
            }
        } 
}

.. and in my main class I have:

        Veed = new vplayer();
        addChild(Veed);
        Veed.playVideo00();

After running program I have ” Time: 6.76″ in output windows and it plays flv fine, which is correct but I want something like
var myTD:int = Veed.getDuration();
in my main class to get the duration. It seems easy but I cannot make it done yet!! Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:08:46+00:00Added an answer on May 22, 2026 at 11:08 pm

    Add a private var at the top:

    private var _duration:Number = 0;
    

    Update this like so:

    public function metaDataHandler(infoObject:Object):void
    {
        _duration = infoObject["duration"];
    }
    

    Now create a getter for duration.

    public function get duration():Number
    {
        return _duration;
    }
    

    Now you can do a:

    trace(Veed.duration);
    

    The meta data will be retrieved even milliseconds after it’s requested, meaning if you try fetch the duration immediately after fetching the meta data, it wouldn’t have loaded yet. Try this as an example:

    addEventListener(Event.ENTER_FRAME, _wait);
    function _wait(e:Event):void
    {
        if(Veed.duration != 0)
        {
            trace(Veed.duration);
            removeEventListener(Event.ENTER_FRAME, _wait);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To put this in concise language... Aim: To create a class which can load
I have a class which is marked with a custom attribute, like this: public
I have a class which looks something like this: public class Test { private
I have the following method for my class which intends to load a nib
I have a class which reads some settings from an XML file with simplexml.
I have a custom class which is a UITableViewController, this is inside of a
I have set up a nice Flash audio visualization which can load an audio
I have a Custom class which is supposed to load a window from a
I have a class which I'm serialising to send over a unix socket and
I have a class which implements UserControl. In .NET 2005, a Dispose method is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.