red5 と flex 4.5 を使用して音声チャット アプリケーションを作成するには、次のコードを試してください。もちろん、目的に合わせて調整する必要があります。
音声チャット機 1
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var netConnection:NetConnection;
private var InsertStream:NetStream;
private var getStream:NetStream;
private var connectionUrl:String="rtmp://YOURSERVER/vchat";
private function init():void
{
netConnection=new NetConnection();
netConnection.connect(connectionUrl);
netConnection.addEventListener(NetStatusEvent.NET_STATUS,connectHandler);
}
private function connectHandler(e:NetStatusEvent):void
{
if(e.info.code=="NetConnection.Connect.Success")
{
InsertStream=new NetStream(netConnection);
InsertStream.attachAudio(Microphone.getMicrophone());
InsertStream.publish("stream1","live");
getStream=new NetStream(netConnection);
getStream.attachAudio(Microphone.getMicrophone());
getStream.play("stream2"); // play the machine 2 stream
}
else
{
Alert.show("server Problem");
}
}
]]>
</mx:Script>
マシン 2
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var netConnection:NetConnection;
private var InsertStream:NetStream;
private var getStream:NetStream;
private var connectionUrl:String="rtmp://YOURSERVER/vchat";
private function init():void
{
netConnection=new NetConnection();
netConnection.connect(connectionUrl);
netConnection.addEventListener(NetStatusEvent.NET_STATUS,connectHandler);
}
private function connectHandler(e:NetStatusEvent):void
{
if(e.info.code=="NetConnection.Connect.Success")
{
InsertStream=new NetStream(netConnection);
InsertStream.attachAudio(Microphone.getMicrophone());
InsertStream.publish("stream2","live");
getStream=new NetStream(netConnection);
getStream.attachAudio(Microphone.getMicrophone());
getStream.play("stream1"); // play stream from the other machine
}
else
{
Alert.show("server Problem");
}
}
]]>
</mx:Script>