Skip to main content
October 23, 2008
Question

How to tell when video.videoWidth and video.videoHeight are available?

  • October 23, 2008
  • 4 replies
  • 2452 views
From the documentation of Video.videoHeight:

"You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage."

This is exactly what I'm trying to do. Unfortunately, the documentation doesn't say when this property is available. From trial and error I have determined that it is not available immediately after NetStream.play, it is sometimes available and sometimes not available after NetStream.onMetaData, and it is available substantially before netStatus fires with the first NetStream.Buffer.Full event. So, when should I set my Video instance size to Video.videoWidth and Video.videoHeight??
This topic has been closed for replies.

4 replies

October 24, 2008
> Original video height and width (if this is what you need) is available
> onMetaData as info.width and info.height

Yeah, not necessarily. :) For instance, videos on YouTube do not contain width/height in the metadata.

Yes, I'm using a Video object and handling everything myself, not FLVPlayback or VideoPlayer components.
October 24, 2008
Yeah, sorry, when I say NetStream.onMetaData I'm just using the documentation notation; onMetaData is an event of the NetStream class even though you use it as a callback of the NetStream.client property, I know this and it's working fine. :)

Sorry for the confusion, my question is not related to that, really, I just want to know when Video.videoHeight and Video.videoWidth become available so I can use them to set Video.width and Video.height. Sometimes it's available when onMetaData fies, sometimes it's not. It also doesn't seem to correspond to any netStatus event. So when should I look for it?
Inspiring
October 24, 2008
Original video height and width (if this is what you need) is available onMetaData as info.width and info.height (see my previous post). There is no videoHeight or videoWidth in the video file itself. This is true - it doesn't correspond with any netstatus event.

I assume you are writing your own routine for video streaming (not using FLVPlayback, etc.)

Hope it helps.
October 24, 2008
Yes, I'm currently using NetStream.onMetaData to capture meta data of a stream.

But when is Video.videoWidth and Video.videoHeight available? There doesn't seem to be an event that fires when this is available.
Inspiring
October 24, 2008
There is no NetStream.onMetaData method. onMetaData is a method of a client. For instance:

var ns:NetStream = new NetStream(connection);
// this is what makes onMetaData called:
ns.client = this;

later:

function onMetaData(info:Object):void{
trace ("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
Inspiring
October 24, 2008
In AS3 onMetaData is not a method of NetStream but of NetStream.client.

I believe onMetaData is the only method which gets stream asset's parameters. It is one of the most reliable and consistent methods (from my experience) in terms of streaming video unlike other methods/events that execute differently depending on stream type (progressive, streaming, live streaming).