Testing out Cirrus/P2P
Does this script look right to you?
ActionScript Code: package { import flash.events.NetStatusEvent; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; import flash.utils.ByteArray; import flash.media.Microphone; import flash.media.Camera; /** * ... * @author */ public class Communications { private const CirrusAddress:String = "rtmfp://p2p.rtmfp.net"; private const DeveloperKey:String = "my developer key"; private var netConnection:NetConnection; private var recievedKey:String; private var sendStream:NetStream; private var recieveStream:NetStream; public function Communications() { //Dislpay/Relay audio //Display/Relay video //Connect to adobe cirrus netConnection = new NetConnection(); netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionHandler); netConnection.connect(CirrusAddress + DeveloperKey); } private function netConnectionHandler(e:NetStatusEvent):void { //Retrieve key for other clients to use to connect to recievedKey = new String(netConnection.nearID); } private function prepareSendStream(useMic:Boolean, useCamera:Boolean):void { sendStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS); sendStream.addEventListener(NetStatusEvent.NET_STATUS, netStreamHandler); sendStream.publish("media"); if (useMic) { sendStream.attachAudio(Microphone.getMicrophone()); } if (useCamera) { sendStream.attachCamera(Camera.getCamera()); } } private function connectToAClient(key:String):void { recieveStream = new NetStream(netConnection, key); recieveStream.addEventListener(NetStatusEvent.NET_STATUS, netStreamHandler); recieveStream.play("media"); var video:Video = new Video(); video.attachNetStream(recieveStream); //Might work } private function sendData(data:ByteArray):void { sendStream.send("recieveData", data); } private function recieveData(data:ByteArray):ByteArray { trace(data.bytesAvailable); } }}
Does this look right?
Tuesday, June 19, 2012
[Action Script] Does this look right? June,2012
Posted by Bimo Hery Prabowo at 3:13 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment