How do I know the length of the video (external FLV video)?
I have tried several ways but the result is 0
.
videonya.addEventListener(fl.video.VideoEvent.READY, onFlvPlayback_READY);
function onFlvPlayback_READY(event:fl.video.VideoEvent):void
{
var metaDataObj:Object = videonya.metadata as Object;
trace("metaDataObj.duration: "+metaDataObj.duration);
}
The standard way of playing video and accessing metadata is this:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
ns.play("video.flv");
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
function onMetaData(infoObject:Object):void
{
var key:String;
for (key in infoObject)
{
trace(key + ": " + infoObject[key]);
}
}
This will trace out all of the metadata codes including duration. If you just want the duration: trace(infoObject.duration);
inside the onMetaData(infoObject)
function, of course.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.