如何从 Actionscript 3.0 使多个视频剪辑同时播放

发布于 2024-10-31 20:00:01 字数 565 浏览 1 评论 0原文

我正在尝试做一个小型多媒体播放器,其中至少有 9 个我想要放置和播放的小视频剪辑 - 全部由 AS 3.0 控制。

甚至可能超过 9 个剪辑,但它们会随机显示在 9 个位置。电影也可以切换视口。

我会将它们全部预加载到缓冲区中,并且我想同时随机播放它们。

这意味着可能有 9 个大小相同的区域显示小影片剪辑,包括声音和随机时间。

像这样:

[1][2][3]

[4][5][6]

[7][8][9]

所以它的 1 个 Flash 画布/播放器同时显示它们。

这可能吗?播放 9 部电影(包括其声音)会使 Flash 崩溃吗?电影的长度可能不同,并且必须重置并播放多次,但我无法将结果预渲染为从用户输入随机生成的结果。

这里有任何敏锐的 AS 3.0 大师可以为我指明这个想法的正确方向吗?

编辑

就像...从哪里开始的示例代码?我一直在想,我可以将所有部分放入一个“精灵电影”中,并从每个“窗口”的 XYZ 帧开始播放 - 但不确定它如何或是否会起作用......也不是最好的方法。

I am trying to do a little multimedia player where I have at least 9 small videoclips that I would like to place and play - all controlled by AS 3.0.

It might even be more than 9 clips, but they will show randomly in 9 places. A movie can switch viewport too.

I will preload them all into buffers and I would like to play them randomly at the same time.

This means that there could be 9 equally sized areas showing small movieclips including sound and random times.

Like this:

[1][2][3]

[4][5][6]

[7][8][9]

So its 1 Flash canvas/player showing them all at the same time.

Is this possible or will it crash Flash to play 9 movies including their sound? The movies might be of different length and will have to be reset and played many times, but I cant prerender the result as its randomly generated from user input.

Any sharp AS 3.0 guru in here who can point me in the right direction for this idea?

EDIT

like in... an example code of where to start? I've been thinking that I could put all the parts into one "sprite movie" and the play from frame XYZ for each "window" - but not sure how or if it will work... nor whats best approach.

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

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

发布评论

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

评论(2

断爱 2024-11-07 20:00:01

我认为这是完全可能的。您创建 9 个视频对象,并且需要 9 个 NetStream。您设置一个计时器来分别启动每个视频。

所以最简单的就是一个数组里有9个flv名字,一个数组里有9个。然后创建一个循环,在其中创建 9 个视频对象,将它们排列在矩阵中,然后使用超时在特定时间启动每个对象。

我能想到的最简单、最短的代码如下:

//we use the same flv now
var flvs:Array = ["filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv"];

//setting the times in milliseconds
var times:Array = [0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000];

//creating a NetConnection
var nc:NetConnection = new NetConnection();

//connect null, the flv is in the same folder and a simple file loading
nc.connect(null);

//the loop
for(var i:int = 0; i < times.length; i++)
{
    var ns:NetStream = new NetStream(nc);

    var video:Video = new Video(100, 100);
    addChild(video);

    //i%3 and int(i/3) arranges them in a 3x3 matrix
    video.x = (i%3) * video.width;
    video.y = int(i/3) * video.height;

    video.attachNetStream(ns);

    //the tricky timeout to call the funcion playFlv, in times[i] time, for the specific nc NetStream to play the given flvs[i] flv
    flash.utils.setTimeout(playFlv, times[i], ns, flvs[i]);
}

function playFlv(ns:NetStream, flv:String):void
{
    ns.play(flv);
}

I think it's more than possible. You create 9 video objects and you need 9 NetStreams for them. You set a timer to start each video respectively.

So the easiest is to have 9 flv names in an array, and 9 times in an array. Then you create a loop, where you create the 9 video objects, arrange them in a matrix, then use a timeout to start each at the specific time.

The easiest and shortest code I can think of is as follows:

//we use the same flv now
var flvs:Array = ["filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv", "filename.flv"];

//setting the times in milliseconds
var times:Array = [0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000];

//creating a NetConnection
var nc:NetConnection = new NetConnection();

//connect null, the flv is in the same folder and a simple file loading
nc.connect(null);

//the loop
for(var i:int = 0; i < times.length; i++)
{
    var ns:NetStream = new NetStream(nc);

    var video:Video = new Video(100, 100);
    addChild(video);

    //i%3 and int(i/3) arranges them in a 3x3 matrix
    video.x = (i%3) * video.width;
    video.y = int(i/3) * video.height;

    video.attachNetStream(ns);

    //the tricky timeout to call the funcion playFlv, in times[i] time, for the specific nc NetStream to play the given flvs[i] flv
    flash.utils.setTimeout(playFlv, times[i], ns, flvs[i]);
}

function playFlv(ns:NetStream, flv:String):void
{
    ns.play(flv);
}
离笑几人歌 2024-11-07 20:00:01

是的,这绝对是可能的。当然,您会希望尽可能地优化视频。 Pine Point 网站上有这样的先例(您必须导航到“保质期”部分,然后点击“下一步”几次即可看到它)它一次播放 12 个视频,长度各不相同。就构建而言,它与播放一个视频没有什么不同,只需重复步骤 X 次即可。

我希望这有帮助,

Yes this is definitely possible. You will want to optimize you videos as much as possible of course. There is precedent for this in the Pine Point website, (you'll have to navigate to the "shelf life" section, and hit "next" a few times to see it) It is playing 12 videos at once, all different lengths. In terms of building it, its no different than playing one video, just repeat the steps X number of times.

I hope that helps,

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