Flash Streaming AS3 / NetStream
Ein kleines Beispiel wie man sich am besten an einen Streaming Cluster verbindet und dann einen Stream aufruft auch wenn der Cluster nicht sofort reagiert - Viel Erfolg damit.
var ns:NetStream;
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS,statusHandler);
nc.connect(”rtmp://live.fms.cdn.xxxxxxx“);function statusHandler(evt:NetStatusEvent):void {
switch(evt.info.code) {
case ‘NetConnection.Connect.Success‘:
ns = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play(”streamname“);
var myVideo:Video = new Video(504,312);
myVideo.attachNetStream(ns);
addChild(myVideo);
break;
}
}function asyncErrorHandler(event:AsyncErrorEvent):void {
trace(”asyncErrorHandler:” + event.text);
}