在 Flash 中预加载多个视频? 在弗莱克斯?

发布于 2024-07-09 19:26:44 字数 366 浏览 16 评论 0 原文

我正在做一个项目,我们连续播放多个视频,如果我们通过提供流 URL 以正常方式加载它们,则每次开始下一个视频时都会出现加载延迟。

我浏览了 Adob​​e 的 Flash 和 Flex 文档,但找不到预加载视频的方法。 在此应用程序中嵌入它们是行不通的。 理想情况下,我们会预加载它们,同时显示进度条或其他短视频,并且仅在所有视频加载完毕后才开始视频播放。

我不习惯向别人询问编程问题,我是 RTFM,但我发现 Adob​​e 文档缺乏,并且谷歌搜索 flash/flex 问题很困难。 有很多东西需要筛选,但我找不到相关的技术/解决方案。

至于 Flex/Flash,我对其中一个或两者的解决方案感兴趣。 也许它是相同的,因为它是动作脚本?

I'm doing a project where we play multiple videos back to back, and if we load them the normal way by providing a stream url, there is a load delay each time we start the next video.

I've looked through Adobe's docs for both Flash and Flex, and I can't find a way to pre-load the videos. Embedding them is not workable in this application. Ideally we would pre-load them, display a progress bar or other short video in the meanwhile, and only start the video playback when all the videos have loaded.

I'm not used to asking questions of others for programming, I RTFM, but I find the Adobe docs to be lacking, and googling flash/flex problems is tough. There's a lot to sift through, and I can't find the relevant technique/solution.

As to Flex/Flash I'm interested in the solution for either, or both. Perhaps it is the same, as it is actionscript?

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

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

发布评论

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

评论(2

狼性发作 2024-07-16 19:26:44

这应该是非常简单的。 对于直接 Flash,请使用 fl.video.VideoPlayer 或 fl.video.FLVPlayback。 创建多个播放器,每个视频一个,使用源视频的 url 对每个播放器调用 load()。 然后侦听 VideoProgressEvent.PROGRESS 事件以了解视频何时加载。 最后,您可以将视频连续附加到可视组件并调用 play() 来播放它们。

示例代码(未测试):

var video1:VideoPlayer = new VideoPlayer();
video1.load("http://example.com/video1.flv");
video.addEventListener(VideoProgressEvent.PROGRESS,
                       function(e:VideoProgressEvent):void
                       {
                         if (e.bytesLoaded == e.bytesTotal)
                         {
                           trace("video1 loaded.");
                           parent.addChild(video1);
                           video1.play();
                         }
                       }
var video2:VideoPlayer = new VideoPlayer();
video2.load("http://example.com/video1.flv");
video.addEventListener(VideoProgressEvent.PROGRESS,
                       function(e:VideoProgressEvent):void
                       {
                         if (e.bytesLoaded == e.bytesTotal)
                         {
                           trace("video2 loaded.");
                         }
                       }

This should be very straightforward. For straight flash, use either fl.video.VideoPlayer or fl.video.FLVPlayback. Create multiple players, one per video, calling load() on each with the url to your source video. Then listen for VideoProgressEvent.PROGRESS events to find out when the video is loaded. Finally, you can attach the videos in succession to a visual component and call play() to play them.

Example code(not tested):

var video1:VideoPlayer = new VideoPlayer();
video1.load("http://example.com/video1.flv");
video.addEventListener(VideoProgressEvent.PROGRESS,
                       function(e:VideoProgressEvent):void
                       {
                         if (e.bytesLoaded == e.bytesTotal)
                         {
                           trace("video1 loaded.");
                           parent.addChild(video1);
                           video1.play();
                         }
                       }
var video2:VideoPlayer = new VideoPlayer();
video2.load("http://example.com/video1.flv");
video.addEventListener(VideoProgressEvent.PROGRESS,
                       function(e:VideoProgressEvent):void
                       {
                         if (e.bytesLoaded == e.bytesTotal)
                         {
                           trace("video2 loaded.");
                         }
                       }
还在原地等你 2024-07-16 19:26:44

您可以尝试查看 bulk-loader 项目,看看是否它可能对此有用。

摘录自首页:

“BulkLoader 是一个用 Actionscript 3 (AS3) 编写的最小库,
旨在使装载和管理
复杂的装载要求更容易
而且速度更快。 BulkLoader 需要更多时间
动态,减轻架构负担
方法[原文如此]。 进口量少,制造重
使用 AS3 的动态功能,
BulkLoader 有一种单行的感觉
不会妨碍你。”

You could try looking at the bulk-loader project and see if it might be useful for this.

An excerpt from the front page:

"BulkLoader is a minimal library written in Actionscript 3 (AS3) that
aims to make loading and managing
complex loading requirements easier
and faster. BulkLoader takes a more
dynamic, less architecture heavy
aproach [sic]. Few imports and making heavy
use of AS3's dynamic capabilities,
BulkLoader has a one-liner feel that
doesn't get in your way."

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