Tweaked click animation

Fixed: Bug where you can hear users after leaving conversation
This commit is contained in:
Tom Moor 2013-03-04 22:02:41 -08:00
parent 9a9b619e7c
commit 31166002c6
4 changed files with 3 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
package com.sqwiggle { import flash.events.NetStatusEvent; import flash.media.Camera; import flash.net.NetConnection; import flash.net.NetStream; import flash.media.Microphone; import flash.media.SoundCodec; import flash.events.MouseEvent; import flash.events.Event; import fl.transitions.Tween; import fl.transitions.easing.*; import com.sqwiggle.Member; public class Self extends Member { var cam:Camera; var mic:Microphone; var noc; public function Self(userId:String) { cam = Camera.getCamera(); mic = Microphone.getEnhancedMicrophone(); if (cam) { cam.setQuality(0, 100); cam.setMode(160,120, 4); } if (mic) { mic.enableVAD = true; mic.codec = SoundCodec.SPEEX; mic.encodeQuality = 8; mic.setSilenceLevel(100); mic.setUseEchoSuppression(true); mic.framesPerPacket = 1; } super(userId, '', 'Me'); } public override function render(w:Number, h:Number):void { super.render(w, h); if (!cam) { w = Math.min(Member.MAX_WIDTH, w); h = Math.min(Member.MAX_HEIGHT, h); noc = new NoCameraDetected(); noc.x = w/2; noc.y = h/2; noc.visible = true; addChild(noc); } } public function updatePeerId():void { var options = new Object(); options.peer_id = peerId; // make an API request to save the new peerID var request = Api.putRequest('/users/update', options); // dispatch an event once the peerID is updated request.addEventListener(Event.COMPLETE, function(event:Event) { dispatchEvent(new Event("Connected")); }); } protected override function updateActivity(event:Event):void { if (mic) { activity.alpha = 100 / (50 + (mic.activityLevel/2)); } } public override function connectToVideo(connection:NetConnection):void { peerId = connection.nearID; Sqwiggle.trace('Publishing video to: ' + userId + ', stream: ' + peerId); stream = new NetStream(connection, NetStream.DIRECT_CONNECTIONS); stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); stream.attachCamera(this.cam); stream.publish(this.userId); var client:Object = new Object(); client.onPeerConnect = function(caller:NetStream):Boolean { Sqwiggle.trace('Member connecting to your video stream: ' + caller.farID); return true; }; stream.client = client; video.attachCamera(this.cam); video.smoothing = true; video.deblocking = 5; // ensure we update this users peerID on the server for // other clients to connect to. updatePeerId(); } public override function addToConversation(conversation:Conversation):void { mic.setSilenceLevel(0); stream.attachAudio(mic); activity.gotoAndStop(conversation.color_id); activity.visible = true; nameField.x = 40; Sqwiggle.trace('Your audio is now on'); } ddToConversation(conversation:Conversation):void { ddToConversation(conversation:Conversation):void { mic.setSilenceLevel(100); stream.attachAudio(null); ddToConversation(conversation:Conversation):void { activity.gotoAndStop(conversation.color_id); nameField.x = 10; Sqwiggle.trace('Your audio is now off'); } } }
package com.sqwiggle { import flash.events.NetStatusEvent; import flash.media.Camera; import flash.net.NetConnection; import flash.net.NetStream; import flash.media.Microphone; import flash.media.SoundCodec; import flash.events.MouseEvent; import flash.events.Event; import fl.transitions.Tween; import fl.transitions.easing.*; import com.sqwiggle.Member; public class Self extends Member { var cam:Camera; var mic:Microphone; var noc; public function Self(userId:String) { cam = Camera.getCamera(); mic = Microphone.getEnhancedMicrophone(); if (cam) { cam.setQuality(0, 100); cam.setMode(160,120, 4); } if (mic) { mic.enableVAD = true; mic.codec = SoundCodec.SPEEX; mic.encodeQuality = 8; mic.setSilenceLevel(100); mic.setUseEchoSuppression(true); mic.framesPerPacket = 1; } super(userId, '', 'Me'); } public override function render(w:Number, h:Number):void { super.render(w, h); if (!cam) { w = Math.min(Member.MAX_WIDTH, w); h = Math.min(Member.MAX_HEIGHT, h); noc = new NoCameraDetected(); noc.x = w/2; noc.y = h/2; noc.visible = true; addChild(noc); } } public function updatePeerId():void { var options = new Object(); options.peer_id = peerId; // make an API request to save the new peerID var request = Api.putRequest('/users/update', options); // dispatch an event once the peerID is updated request.addEventListener(Event.COMPLETE, function(event:Event) { dispatchEvent(new Event("Connected")); }); } protected override function updateActivity(event:Event):void { if (mic) { activity.alpha = 100 / (50 + (mic.activityLevel/2)); } } public override function connectToVideo(connection:NetConnection):void { peerId = connection.nearID; Sqwiggle.trace('Publishing video to: ' + userId + ', stream: ' + peerId); stream = new NetStream(connection, NetStream.DIRECT_CONNECTIONS); stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); stream.attachCamera(this.cam); stream.publish(this.userId); var client:Object = new Object(); client.onPeerConnect = function(caller:NetStream):Boolean { Sqwiggle.trace('Member connecting to your video stream: ' + caller.farID); return true; }; stream.client = client; video.attachCamera(this.cam); video.smoothing = true; video.deblocking = 5; // ensure we update this users peerID on the server for // other clients to connect to. updatePeerId(); } public override function addToConversation(conversation:Conversation):void { nameField.x = 40; mic.setSilenceLevel(0); stream.attachAudio(mic); Sqwiggle.trace('Your audio is now on'); } ddToConversation(conversation:Conversation):void { mic.setSilenceLevel(100); stream.attachAudio(null); ddToConversation(conversation:Conversation):void { Sqwiggle.trace('Your audio is now on'); Sqwiggle.trace('Your audio is now off'); } } }

BIN
p2p.fla

Binary file not shown.