简体   繁体   English

我如何知道视频(外部FLV视频)的长度?

[英]How do I know the length of the video (external FLV video)?

How do I know the length of the video (external FLV video)? 我如何知道视频(外部FLV视频)的长度?

I have tried several ways but the result is 0 . 我尝试了几种方法,但结果为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); 如果只需要持续时间: trace(infoObject.duration); inside the onMetaData(infoObject) function, of course. 当然,在onMetaData(infoObject)函数中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM