play 2 rtmp videos at the same time problem
Hi!
My swf is playing one video in using NetConnection, NetStream and Video object. If I want to stream one more video simultaneously in the same swf I have a few problems. It works when I create more NetConnection, NetStream and Video objects but is that necessary? The code rapidly becomes complex to handle.
Is there an easier way like perhaps share the NetConnection, or something (same FMS server)?
Question 2
The two videos on the stage are suppose to have different size, placement etc. Still the last one created inherit the properties of the first video display. It also starts playing for an annoying couple of seconds before the first one. How can I avoid that (inherit and delay)?
Thanks for any feedback.
G
var ns1:NetStream;
var ns2:NetStream;
var nc1:NetConnection = new NetConnection();
var nc2:NetConnection = new NetConnection();
nc1.connect("rtmp://my.fms/vod");
nc2.connect("rtmp://my.fms/vod");
var meta1:Object = new Object();
var meta2:Object = new Object();
var cuep1:Object = new Object();
var cuep2:Object = new Object();
var vid1:Video = new Video(550,310);
var vid2:Video = new Video(100,80);
addChild(vid1);
addChild(vid2);
vid2.x = 170;
vid2.y = 320;
nc1.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent1);
nc2.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent2);
function onStatusEvent1(stat:Object):void {
switch (stat.info.code) {
case ("NetConnection.Connect.Success") :
ns1 = new NetStream(nc1);
ns1.client = meta1;
vid1.attachNetStream(ns1);
ns1.play("sample");
break;
}
}
function onStatusEvent2(stat:Object):void {
switch (stat.info.code) {
case ("NetConnection.Connect.Success") :
ns2 = new NetStream(nc2);
ns2.client = meta2;
vid2.attachNetStream(ns2);
ns2.play("Legend");
break;
}
}
meta1.onMetaData = metadataHandler;
cuep1.onCuePoint = cuepointHandler;
meta2.onMetaData = metadataHandler;
cuep2.onCuePoint = cuepointHandler;
function metadataHandler(metadataObj:Object):void {
//trace("Clip duration: "+metadataObj.duration);
}
function cuepointHandler(cuepointObj:Object):void {
//trace("CuePoints: "+cuepointObj);
}
nc1.addEventListener(AsyncErrorEvent.ASYNC_ERROR, dummyFunc);
nc2.addEventListener(AsyncErrorEvent.ASYNC_ERROR, dummyFunc);
function dummyFunc(dummy:AsyncErrorEvent) {
//trace("AsyncError dummyevent fired: "+dummy);
}
