Actionscript 3: Queuing up FLVs using netstatus and cuepoints

一世执手 提交于 2019-12-24 19:26:30

问题


I'm building a flash site that uses video transitions to go from section to section. Each section's background is a still-frame photo at higher res than the transition videos themselves, which are scaled up during transition. The first frame of each video transition is the current background image, and the last frame of each video transition is the destination's background image. Roughly speaking, this is the intended flow of navigation on the site:

Resting state:
hi-res image in foreground, no video elements

User clicks item on navigation:
Flash prepares an FLV via a netstream object and buffers it, which is accomplished through the netstream.play() function. Upon receipt of the "Netstatus.Buffer.Full" event, the netstream object is paused and attached to a video object, which is then added to the display list behind the hi-res image in the foreground. As soon as the video object has been added to the stage, the hi-res image in the foreground alphas out (via tween), leaving only the background video. When the foreground is finished tweening, the video in the background plays. As soon as "NetStream.Play.Stop" is received, the process happens in reverse; that is, a new hi-res foreground image tweens in over the video layer, and the video is removed from the stage as soon as that's done.

I don't think there's anything wrong (at least in principle) with the flow I've outlined above, and it doesn't sound like it should be that tricky to do. However, I've had no end of problems with the initial setting up of the FLV/video object. At first, it seemed that the FLV wasn't queuing up properly, by which I mean that the hi-res foreground image tweened out to reveal a white screen, and the video popped in and only began playing after a second or two. (The first frame of the FLV is definitely not white).

I had no idea what might have been causing this behavior, but hackishly threw in a timer that plays the netstream for about 100 ms after "Buffer.Full" is received, thereby advancing the video past whatever might have been causing the white screen. This worked well locally but as soon as I put the site on a dev host, it was back to the white screen during transitions. The annoying thing is that bumping the hackish delay up to about 2 s got rid of the white screen problem on remote servers, but results were unpredictable; depending on connection speed, you might see everything work perfectly, or you might get thrown into a video that had already been playing for a second or two.

I've also tried similar approaches using bytesLoaded/bytesTotal instead of netStatus events, to no avail. My last experiment was using cuepoints; during FLV encoding, I threw in a cuepoint 0.2 seconds into the FLV and waited for THAT before tweening out the foreground; once again, it worked locally, but I was treated to a tween-to-white before the video kicked in when testing on a remote server.

I'm really running out of ideas here and would very much appreciate any advice you guys can offer. Thanks very much for your time and consideration!

Justin


回答1:


FLVs are tricksy beasts at times.

I'm going to see if I can dig up some code I wrote a while back to handle all of this. In the meantime I like your idea about cuepoints, and I know why you're running into trouble with them. Cuepoints are actually tied to keyframes - so you need to make sure your cuepoint is placed AFTER your second keyframe - that will ensure that at least the first keyframe of video has been displayed.



来源:https://stackoverflow.com/questions/1433374/actionscript-3-queuing-up-flvs-using-netstatus-and-cuepoints

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!