1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| var mycam_audio:Microphone = Microphone.getMicrophone();
var client_nc = new NetConnection();
client_nc.objectEncoding = ObjectEncoding.AMF3;
client_nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsync);
client_nc.connect("rtmp://localhost/live/tchat/");
client_nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
function onStatus (e:NetStatusEvent):void
{
var msg = e.info.code;
if (msg == "NetConnection.Connect.Success")
{
texte.text = "Connexion réussie. En attente de votre correspondant...";
var audio_ns = new NetStream(client_nc);
audio_ns.attachAudio(mycam_audio);
audio_ns.publish("user_1", "live");
var in_ns = new NetStream(client_nc);
in_ns.play("user_2");
live_feed.attachNetStream(in_ns);
}
else if (msg == "NetStream.Play.Start")
{
texte.text = "Hello world!";
}
}
function onBWDone():void { }
function onAsync(event:AsyncErrorEvent):void {
if ( event.text.indexOf( "onBWDone" ) > -1 ) {
onBWDone();
}
} |
Partager