简体   繁体   English

在Flash中预加载多个视频?在Flex?

[英]Pre-Load Multiple Videos in Flash? In Flex?

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. 我查看了Adobe的Flash和Flex文档,但我找不到预加载视频的方法。 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. 我不习惯向其他人询问编程问题,我是RTFM,但我发现Adobe文档缺乏,而且谷歌搜索flash / flex问题很难。 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. 对于Flex / Flash,我对其中任何一个或两者的解决方案感兴趣。 Perhaps it is the same, as it is actionscript? 也许它是一样的,因为它是动作脚本?

You could try looking at the bulk-loader project and see if it might be useful for this. 您可以尝试查看bulk-loader项目,看看它是否对此有用。

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." “BulkLoader是一个用Actionscript 3(AS3)编写的最小库,旨在使加载和管理复杂的加载需求变得更加容易和快速.BulkLoader采用更加动态,更少架构的方式[原文如此]。很少有进口和大量使用AS3的动态功能,BulkLoader具有单线感,不会妨碍你。“

This should be very straightforward. 这应该非常简单。 For straight flash, use either fl.video. 对于直接闪光,请使用fl.video。 VideoPlayer or fl.video. VideoPlayer或fl.video。 FLVPlayback . FLVPlayback Create multiple players, one per video, calling load() on each with the url to your source video. 创建多个播放器,每个视频一个,使用您的源视频的网址调用每个播放器上的load()。 Then listen for VideoProgressEvent.PROGRESS events to find out when the video is loaded. 然后侦听VideoProgressEvent.PROGRESS事件以找出视频加载的时间。 Finally, you can attach the videos in succession to a visual component and call play() to play them. 最后,您可以将视频连续附加到可视组件,并调用play()来播放它们。

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.");
                         }
                       }

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

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