从多个预加载视频获取元数据

发布于 2024-10-04 11:02:38 字数 962 浏览 3 评论 0原文

我发现我只能获取我点击的第一个视频的元数据。元数据如何运作?视频结束前只能加载一次?

这是我正在做的一些示例,

//will be adding new video when this function is called
public function set newVideo():void
{
    videoProperties();
}

public function videoProperties():void
{
    meta=new Object()
    nc = new NetConnection();
    nc.connect(null);
    ns = new NetStream(nc);

    nsArray[dList.currentIndex] = ns;
    nsi = nsArray[dList.currentIndex];
    // Add the buffer time to the video Net Stream
    nsi.bufferTime = buffer;

    // Set client for Meta Data Function
    nsi.client = {};
    nsi.client.onMetaData = onMetaData;
    nsi.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler);
    nsi.addEventListener(NetStatusEvent.NET_STATUS, onNetStatusEvent);

    nsi.play(videoURL);
    nsi.pause();
    nsi.seek(-1);
}

private function onMetaData(info:Object):void
{
    //some video duration calculations
}

我尝试一次加载所有元数据,但似乎它需要播放视频,只有它才能设法获取元数据。

I found out that I could only get the metadata of the 1st video I clicked. How does metadata works? It could only load once before the video ends?

Here's some example what I'm doing

//will be adding new video when this function is called
public function set newVideo():void
{
    videoProperties();
}

public function videoProperties():void
{
    meta=new Object()
    nc = new NetConnection();
    nc.connect(null);
    ns = new NetStream(nc);

    nsArray[dList.currentIndex] = ns;
    nsi = nsArray[dList.currentIndex];
    // Add the buffer time to the video Net Stream
    nsi.bufferTime = buffer;

    // Set client for Meta Data Function
    nsi.client = {};
    nsi.client.onMetaData = onMetaData;
    nsi.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler);
    nsi.addEventListener(NetStatusEvent.NET_STATUS, onNetStatusEvent);

    nsi.play(videoURL);
    nsi.pause();
    nsi.seek(-1);
}

private function onMetaData(info:Object):void
{
    //some video duration calculations
}

I tried to load all the metadata at once, but seems like it needs the video to be play only it will manage to get the metadata.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉薄对峙 2024-10-11 11:02:38

您是否试图在不启动视频加载过程的情况下获取元数据?如果是这样,那么仅使用动作脚本是不可能的。也就是说,由于 flv 是渐进加载的,因此您无需加载整个视频即可获取元数据。您可以加载每个视频,并在获得元数据后停止加载。

Are you trying to get the metadata without starting the video loading process? If so, that's not possible with actionscript alone. That said, since flvs load progressively you don't need to load an entire video to get at the meta data. You can load each video and stop loading it when you've got the metadata.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文