2

我需要在 AS3 中动态创建一个具有近乎无缝过渡的播放列表。

我曾尝试将 play2 命令与 .APPEND 一起使用。它确实在非动态设置中工作。但我所拥有的是,在应用程序启动时,我知道第一个视频是什么,然后,在该视频结束之前,我会知道下一个要播放的视频是什么,依此类推,直到我收到消息,我播放了最后一个视频。

所以,一开始,我不知道会有多少个视频,也不知道要播放的文件的顺序。

如果我在流已经播放时尝试使用 APPEND 添加视频,它似乎会替换当前播放的视频,而不是开始缓冲并仅在当前视频的结尾播放。

我也不能使用 appendBytes,因为视频文件必须是 h.264 格式

任何人的帮助将不胜感激,因为我不知道该往哪个方向看了。如有必要,我可以提供更多详细信息。

非常感谢。

4

1 回答 1

1

This is a bit of an off-the-cuff answer, but the logic is sound & should give you another direction to pursue.

Firstly, the concept: with Flash video you have 2 completely separate processes occurring simultaneously:

  1. buffering / loading

  2. the video playing

Thus, playing & streaming can & do occur simultaneously, but separately & that is where the logic should be hooked in.

So, on to the implementation: would be to have a primary player, and a secondary (shadow) player / loader. The primary player should be responsible for loading the initial video & playing it.

[& here comes the magic]

Once buffering in the primary player is complete, determined by the NetStream.Buffer.Flush NetStatusEvent on the NetStream object. Then begin buffering the following video in the shadow player, initialising the connection & using NetStream.Pause, to begin buffering, but not playing, while the primary player plays out.

When playing is complete in the primary player (determined by the NetStream.Play.Stop event) you can pass the variables (NetConnention, NetStream & Video) (always passed by reference) from the shadow player over to the primary player & it should continue practically seamlessly. Then clear the values from the shadow player & repeat the above process, waiting for buffering to complete before loading the next video; ad infinitum.

Alternatively, you can have a more balanced approach - although in my mind this will be more resource intensive (as you'll have 2 video players continually active) - and have a primary & secondary player, where they alternate. As soon as one buffer is complete, you begin buffering the next, as soon as playing is complete, you switch from one player to the other.

This will be be pretty fiddly to assemble (hence the lack of an example, as it is complicated, and in essence, your job ;) as you'll be dealing with 2 sets of NetConnections, NetStreams & Videos - which are complicated to begin with, lots of events that require handling...

But, I don't think play2() is your answer here, that is used primarily to reawaken broken/closed NetConnections. The problem that faces you here is seamless asynchronisation of 2 separate NetConnections & NetStreams.

Ping me if you still need assistance/explanation here, this is a bit of an old Q & I don't want to write a few hundred lines of code if you've already moved on...

Best, a.)

于 2012-09-23T12:30:13.970 回答