Flash: Movie Duration??
- Started
- Last post
- 13 Responses
- cosmo
I am sure one of you have a solution to this problem. how do I grab the duration of a movie?
NetStream's onMetaData doesn't seem to be working. Any suggestions? Yes, I already searched for this shit. :)
ns.onMetaData = function(obj) {
trace("Video Duration is: "+obj.duration);
trace("Video Rate is:"+obj.videodatarate);
trace("Audio Rate is:"+obj.audiodatarate);
};
- enjine0
us this, i've had the same problem, but this works for me:
ns["onMetaData"] ...
- cosmo0
hmmm...still doesn't work. Do I have do anything special to the movie file itself? n00bie at flash.
- enjine0
you're loading an .flv, right?
you set up your net connections, passed a null variable, instantiated the net stream object and called the play function?
- cosmo0
yup, all that is working just fine.
var nc:NetConnection = new NetConnection ();
nc.connect(null);
var ns:NetStream = new NetStream (nc);
var fileName = "test.flv";theVideo.attachVideo (ns);
ns.play(fileName);
- enjine0
and at what point are you declaring the onMetaData function?
- cosmo0
This what I had before and "duration" variable seems to receive nothing.
var duration:Number;
ns["onMetaData"] = function (obj) {
duration = obj.duration;
}
- enjine0
did you declare the onMetaData before you loaded/played the flv?
- enjine0
oh and, be sure to put some text in the trace statement, because first of all, your duration variable is outside of the scope of the onMetaData function. that is, unless you're writing this code on the timeline. I think then it would probably work. def not in a class file though
- cosmo0
yup.
- PonyBoy0
is it possible that the flv is missing metaData?
i know when you encode a flv that you have plenty of options to tack on... such as cuePoints etc... so I'm wondering if the flv is missing something that you're trying to extract... nahmean?
- enjine0
or if you're not using flashcomm server. i've only been streaming them through flashcomm (i.e. no null variable), so that could be a factor.
- cosmo0
yup, movie was not encoded right. thanks guys.
- UndoUndo0
try calling the function with the 'onStatus' handler and then 'buffer. full'. you'll have to look it up in flash - im sure thats not quite right but alomost there
if you read the forums on flash video there are loads of frustrated peeps talking about how unreliable flash video classes are