NetStream attached to multiple video objects
Last week I looked at an interesting bug with Flash Video. Let's assume you have two video objects on stage and you attach the same NetStream object to them:
myNetStream = new NetStream(myNetConnection);
myVideo1.attachVideo(myNetStream);
myVideo2.attachVideo(myNetStream);
This code will not do exactly what you'd expect. FLVs are a packet based format and the NetStream object will simply evenly distribute packets between the two video objects. Each video object instance has it's own instance of the video codec. What happens is that the video codec is suddenly missing some frames, including key frames. This will result in corrupted video playback.
So if you want to make this work you have to create another NetStream object which will serve up the video.
myNetStream = new NetStream(myNetConnection);
myVideo1.attachVideo(myNetStream);
myVideo2.attachVideo(myNetStream);
This code will not do exactly what you'd expect. FLVs are a packet based format and the NetStream object will simply evenly distribute packets between the two video objects. Each video object instance has it's own instance of the video codec. What happens is that the video codec is suddenly missing some frames, including key frames. This will result in corrupted video playback.
So if you want to make this work you have to create another NetStream object which will serve up the video.


10 Comments:
Hi Tinic,
Yesterday, I came across the problem of attaching one NetStream to multiple video objects.
The immediate way round this was to create multiple NetStream objects to feed the video objects.
However, in my application this had drawbacks. I require the multiple video objects to be in sync. When using multiple NetStreams playing video from the same FLV, I could not guarantee that they would play in sync.
The obvious solution to me now, is to extend the NetStream class to distribute packets evenly to multiple video objects. Unfortunately, there is no way of viewing the original source code for the class. I'm not even sure that these classes are written in Actionscript either.
Have you or anyone else come up with a solution of extending this class to evenly distribute packets, or any other solution to combat this problem?
I notice this issue has not been visited in the latest Flash 8 release.
Regards.
Hello, I realise it has been a while since this post. I am attempting to create multiple netstream objects at runtime, ie. something like an array of netstream objects, but any syntax I attempt does not result in much success.
Do you know of any resources that might help me in my attempts?
Any suggestions would be greatly appreciated.
Regards
Ian Watson
iwatson@inkey.co.za
I like articles like this. Thanks!
Great Article! Thank You!
Thanks to author! I like articles like this, very interesting.
nice blog!
nice blog!Nice information
:-) ochen\' zaebatyj blog!
soglasen s vami ochen\' zaebatyj blog!
Keep up the great work. It very impressive. Enjoyed the visit!
Post a Comment
<< Home