简体   繁体   中英

Flash (Actionscript 3): Play 2 videos from 1 NetStream?

I'm streaming a video from an Amazon CloudFront RTMP source with

video.attachNetStream(myNetStream);
myNetStream.play(myVideoFileName,0,-1);

and it's working quite well. Now, what I want to do is something like this:

video1.attachNetStream(myNetStream);
video2.attachNetStream(myNetStream);
myNetStream.play(myVideoFileName,0,-1);

This doesn't work as written because only one of the two videos will play at a time for some unknown reason. I want video1 and video2 to play the same video from a single NetStream (to save bandwidth) and remain completely in-sync with each other. How can I accomplish this?

If you are playing an FLV file directly (not streaming it from FMS), you should be able to :

  1. Load the file with URLStream
  2. Wait for sufficient data to start copying the data to a ByteArray object
  3. Create as many NetStream objects as you need and use the appendBytes(bytes) method

I haven't actually tested it, and the logic of appendBytes() needs to be looked at, but theoretically it should work.

Also, it deserves a benchmark. But it's probably better than re-drawing a bitmap copy at the same rate as the video, and keep the two videos in sync.

bitmapData can't be accessed at all because of security restrictions. I'm going with plan B which is playing 2 netstreams, but reducing the file size of the one the videos by removing its audio. I'll have to wait until Amazon allow security policy access to use the bitmapData solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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