1 Replies - 3884 Views - Last Post: 12 April 2012 - 01:50 PM

#1 drmaxmad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-April 12

Whats wrong with the code.

Posted 09 April 2012 - 11:01 AM

Hi All,
can some one take a look and tell what have i done wrong.Let me explain what this code does. Its host code for a multiway video chat system, it works fine with two people but when the third person connects i am unable to hear his voice.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:conference="com.drmax.conference.*"
			   xmlns:debugger="com.demonsters.debugger.*"
			   xmlns:bwchecker="com.drmax.bwchecker.*"
			   xmlns:debug="com.drmax.debug.*"
			   width="525" height="300" doubleClickEnabled="true" click="showAvatarList(event)" doubleClick="showDebugger(event)"
			   creationComplete="application_creationCompleteHandler(event)">
	<fx:Script>
		<![CDATA[
			import Skins.CSpSliderThumb;
			
			import com.drmax.conference.User;
			
			import mx.controls.Alert;
			import mx.core.mx_internal;
			import mx.events.CloseEvent;
			import mx.events.FlexEvent;
			import mx.events.SliderEvent;
			import mx.logging.ILogger;
			import mx.logging.Log;
			import mx.managers.PopUpManager;
			
			import spark.components.List;
			
			//bindable/embeded variables
			[Embed(source="images/image.png")]private var noImage:Class;
			
			//private variables
			private var users:User;
			private var nc:NetConnection;
			private var hostAudioStream:NetStream;
			private var hostVideoStream:NetStream;
			private var userAudioStream:NetStream;
			private var userVideoStream:NetStream;
			private var serverAddress:String;
			private var sessionId:String;
			private var userName:String;
			private var whoAmI:String;
			private var userAvatar:String;
			private var imageLoader:Loader;
			private var settingSO:SharedObject;
			private var camera:Camera;
			private var microphone:Microphone;
			private var isCamAvailable:Boolean;
			private var participants:Array;
			private var currentParticipant:User;
			private var menuList:List;
			private var userClicked:User;
			private var audioStreamList:ArrayCollection;
			private var leftParticipant:User;
			private var volumeTransform:SoundTransform;
			private var alertTimer:Timer;
			private var streamAlert:Alert;
			private var isStreaming:Boolean;
			
			//variables for bandwidth check
			private var bwCheckAlert:Alert;
			private var checkUploadTimer:Timer;
			private var minimalCamSettings:String;
			
			private var debugTimer:Timer = new Timer(1000);
			
			
			protected function application_creationCompleteHandler(event:FlexEvent):void
			{
				serverAddress = parameters['ServerAddress'];
				sessionId = parameters['SessionId'];
				whoAmI = parameters['whoAmI'];
				userAvatar = parameters['userAvatar'];
				userName = parameters['username'];
				minimalCamSettings = parameters['quality'];
				
				//start debugger.
				startDebugButton.visible = true;
				
				// Monster Debugger trace message
				monsterDebugger.trace(this,"Hello World!");
				
				// Flex trace message
				var logger:ILogger = Log.getLogger("Main.mxml");
				logger.error("Hello World!");
				
				if (serverAddress == "")
				{
					Alert.show("Please provide a valid RMTP server address for application to proceed");
					return;
				}
				
				//create a server address from serverId/sessionId
				completeServerAddress();
				
				//configure upload checker
				isStreaming = true;
				alertTimer = new Timer(1500);
				checkUploadTimer = new Timer(15000);
				
				debugTimer.addEventListener(TimerEvent.TIMER, startDebugging);
				
				audioStreamList = new ArrayCollection();
				hostImage.source = noImage;
				userImage.source = noImage;
				imageLoader = new Loader();
				imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadImageComplete);
				imageLoader.load(new URLRequest(encodeURI(userAvatar)));
				
				volumeSlider.value = 50;
				volumeTransform = new SoundTransform(volumeSlider.value);
				
				ExternalInterface.addCallback("setCam", setCamera);
				ExternalInterface.addCallback("muteMic", setMic);
				ExternalInterface.addCallback("changeCameraAndMic", changeCamSettings);
				setupCameraAndMic();
			}
			
			/////////////////////////////////////// Complete Server Address ///////////////////////////////////////////
			private function completeServerAddress():void
			{
				if (serverAddress == "" || serverAddress.indexOf("rtmp") == -1) {
					Alert.show("please correct the server address", "SERVER ADDRESS ERROR");
					return;
				}
				
				if (serverAddress.charAt(serverAddress.length-1) != "/") {
					serverAddress += "/";
				}
				
				serverAddress += sessionId;
				
				//Alert.show(serverAddress);
			}
			
			/////////////////////////////////////// Set Camera & Microphone ///////////////////////////////////////////
			private function setCamera():void
			{
				
				if (camera != null) {
					camera = null
					hostVideo.attachCamera(null);
					hostVideoStream.attachCamera(null);
					hostVideoStream.close();
					hostVideo.mx_internal::videoPlayer.close();
					hostVideo.mx_internal::videoPlayer.clear();
					hostImage.visible = true;
				} else {
					settingSO = SharedObject.getLocal("MicCamSettings");
					if(settingSO.size > 0) 
					{
						camera = Camera.getCamera(settingSO.data.cam);
						
					} else {
						camera = Camera.getCamera("0");

					}
					hostVideo.attachCamera(camera);
					hostVideoStream.attachCamera(camera);
					hostImage.visible = false;
					//uncomment this if its not working again.
					//startSendingStream();
				}
			}
			
			private function setMic():void
			{
				if (nc.connected) {
				  if (microphone.gain > 0 )
				  {
				  	microphone.gain = 0;
				  } else {
					microphone.gain = 50;
				  }
				}
			}
			
			public function changeCamSettings(camIndex:String, micIndex:int):void
			{
				try {
				camera = Camera.getCamera(camIndex);
				microphone = getEnhancedMicrophone(micIndex);
					
					hostVideo.attachCamera(camera);
					hostVideoStream.attachCamera(camera);
					hostVideoStream.attachAudio(microphone);
				
				} catch (e:Error)
				{
					monsterDebugger.trace(this, e);
				}
				startSendingStream();
				monsterDebugger.trace (this,microphone.name);
			}
			
			/////////////////////////////////////// get Enhanced Microphone ///////////////////////////////////////////
			private function getEnhancedMicrophone(index:int):Microphone
			{
				var mic:Microphone = Microphone.getEnhancedMicrophone(index);
				if (mic != null) {
					var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
					options.autoGain = false;
					options.echoPath = 128;
					options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
					options.nonLinearProcessing = true;
					mic.enhancedOptions = options;
					//mic.setLoopBack(true);
				} else {
					Alert.show("No Enhanced Micropone present");
				}
				return mic;
			}
			
			/////////////////////////////////////// Application click handler ///////////////////////////////////////////
			protected function showAvatarList(event:MouseEvent):void
			{
				if (event.target.toString().indexOf("userHolder") == -1){
					clickList.visible = false;
				}
				//trace (event.target.toString().indexOf("userHolder"),event.target);
			}
			
			
			///////////////////////////////////////////// Load Avatar ///////////////////////////////////////////////////
			private function loadImageComplete(eve:Event):void
			{
				hostImage.source = eve.currentTarget.content;
			}
			
			
			///////////////////////////////////////////// setting up camera and mic /////////////////////////////////////
			private function setupCameraAndMic():void
			{
				settingSO = SharedObject.getLocal("MicCamSettings");
				if(settingSO.size > 0) 
				{
					camera = Camera.getCamera(settingSO.data.cam);
					microphone = getEnhancedMicrophone(settingSO.data.mic);
					
				} else {
					camera = Camera.getCamera("0");
					microphone = getEnhancedMicrophone(0);
				}
				
				//see if the camera is null or microphone is null
				if (camera == null)
				{
					isCamAvailable = false;
				}else {
					isCamAvailable = true;
				}
				
				connectToServer();
			}
			
			///////////////////////////////////////////// connect to server //////////////////////////////////////
			private function connectToServer():void
			{
				nc = new NetConnection();
				nc.addEventListener(NetStatusEvent.NET_STATUS, checkNetConnectionStatus);
				nc.client = this;
				var info:Object = new Object();
				info.name = userName;
				info.avatar = userAvatar;
				info.type = "host";
				info.isCameraAvailable = isCamAvailable;
				nc.connect(serverAddress, info);
			}
			
			///////////////////////////////////////////// check server status //////////////////////////////////////
			private function checkNetConnectionStatus(eve:NetStatusEvent):void
			{
				var msg:String = eve.info.code;
				trace (msg);
				switch (msg)
				{
					case "NetConnection.Connect.Success":
						//startSendingStream();
						checkUploadBW();
						break;
					
					case "NetConnection.Connect.Reject":
						Alert.show(eve.info.application.message,"Connection Error",3,this,reconnect);
						break;
					
					case "NetConnection.Connect.Failed":
						Alert.show("Please wait we are trying to reconnect you to the live class feed.","Connection Error",3,this,reconnect);
						break;
					
					case "NetConnection.Connect.Closed":
						
						break;
				}
			}
			
			///////////////////////////////////////////// reconnect to server //////////////////////////////////////
			private function reconnect(eveObj:CloseEvent):void
			{
				if (eveObj.detail == Alert.YES)
				{
					connectToServer();
				}
			}
			
			/////////////////////////////////////start - check optimum camera settings/////////////////////////////////////
			
			private function checkUploadBW():void
			{
				/* if (minimalCamSettings != "")
				{
					bwCheckAlert = Alert.show("Checking your upload bandwidth for optimal camera settings.","CAMERA SETTINGS");
					bwCheckAlert.mx_internal::alertForm.mx_internal::buttons[0].visible = false;
					
					checkUploadTimer.start();
					checkUploadTimer.addEventListener(TimerEvent.TIMER, checkUploadComplete);
				} else { */
					setCameraQuality(minimalCamSettings);
				//}
			}
			
/* 			protected function checkUploadComplete(eve:TimerEvent):void
			{
				PopUpManager.removePopUp(bwCheckAlert);
				//set the quality of the camera to full
				checkUploadTimer.stop();
				if (UBWCheck.currentBW > 100) {
					minimalCamSettings = 'high';
				} else if (UBWCheck.currentBW > 50 && UBWCheck.currentBW < 100) {
					minimalCamSettings = 'medium';
				} else {
					minimalCamSettings = 'low';
				}
				
				setCameraQuality(minimalCamSettings);
			}
 */			
			private function setCameraQuality(quality:String):void
			{
				if (camera != null) {
					
					switch (quality) {
						
						case 'high':
							camera.setMode(290,220,15,true);
							camera.setQuality(0,95);
							break;
						
						case 'medium':
							camera.setMode(290,220,10,true);
							camera.setQuality(0,80);
							break;
						
						case 'low':
							camera.setMode(160,120,5,true);
							camera.setQuality(0,85);
							break;
					}	
				}
				startSendingStream();
			}
			
			
			///////////////////////////////////////////// start sending stream //////////////////////////////////////
			private function startSendingStream():void
			{
				if (hostVideoStream != null || hostAudioStream != null) {
					hostVideoStream.close();
					hostAudioStream.close();
					hostVideoStream = null;
					hostAudioStream = null;
				}
				hostVideoStream = new NetStream(nc);
				hostAudioStream = new NetStream(nc);
				hostAudioStream.attachAudio(microphone);
				
				hostNameLabel.text = userName;
				
				if (camera != null) {
					hostVideo.attachCamera(camera);
					hostImage.visible = false;
				}
				
				//start publishing audio / video 
				hostVideoStream.publish("hostVideoStream");
				hostAudioStream.publish("hostAudioStream");
			}
			
			///////////////////////////////////////////// start receving stream //////////////////////////////////////
			private function startAttendieStreamReceive(count:int):void
			{
				currentParticipant = userHolder.getElementAt(count) as User;
				//trace ("start receiving first video");
				startReceiving();
			}
			
			private function startReceiving():void
			{
				if (userAudioStream != null || userVideoStream != null) {
					userAudioStream.close();
					userVideoStream.close();
					userAudioStream = null;
					userVideoStream = null;
				}
				
				userAudioStream = new NetStream(nc);
				userVideoStream = new NetStream(nc);
				userAudioStream.addEventListener(NetStatusEvent.NET_STATUS, checkAudioStreamStatus);
				userVideoStream.addEventListener(NetStatusEvent.NET_STATUS,checkVideoStreamStatus);
				
				userNameLabel.text = currentParticipant.nametoDisplay;
				
				userAudioStream.play(currentParticipant.streamID + "AudioStream");
				audioStreamList.addItem({label:currentParticipant.streamID , data:userAudioStream});
				
				attendieVideo.mx_internal::videoPlayer.attachNetStream(userVideoStream);
				userVideoStream.play(currentParticipant.streamID + "VideoStream");
				attendieVideo.mx_internal::videoPlayer.visible = true;
				userImage.visible = false;
			}
			
			///////////////////////////////////////////// start receving stream //////////////////////////////////////
			private function startReceivingOnHostVideo():void
			{
				if (hostAudioStream != null || hostVideoStream != null) {
					hostAudioStream.close();
					hostVideoStream.close();
					hostAudioStream = null;
					hostVideoStream = null;
				}
				
				hostAudioStream = new NetStream(nc);
				hostVideoStream = new NetStream(nc);
				hostAudioStream.addEventListener(NetStatusEvent.NET_STATUS, checkAudioStreamStatus);
				hostVideoStream.addEventListener(NetStatusEvent.NET_STATUS,checkVideoStreamStatus);
				
				hostNameLabel.text = leftParticipant.nametoDisplay;
				
				userAudioStream.play(leftParticipant.streamID + "AudioStream");
				
				hostVideo.mx_internal::videoPlayer.attachNetStream(userVideoStream);
				hostVideoStream.play(leftParticipant.streamID + "VideoStream");
				hostVideo.mx_internal::videoPlayer.visible = true;
				hostImage.visible = false;
			}
			///////////////////////////////////////////// stream events //////////////////////////////////////
			private function checkVideoStreamStatus(eve:NetStatusEvent):void
			{
				var msg:String = eve.info.code;
				trace (eve.currentTarget,msg);
				if(msg == "NetStream.Play.StreamNotFound")
				{
					attendieVideo.mx_internal::videoPlayer.clear();
					loadAttendieAvatar();
					var stream:NetStream = NetStream(eve.currentTarget);
					stream.close();
					stream = null;
				} else {
					userImage.visible = false;
				}
			}
			
			///////////////////////////////////////////// stream events //////////////////////////////////////
			private function checkAudioStreamStatus(eve:NetStatusEvent):void
			{
				var msg:String = eve.info.code;
				trace (msg);
				if(msg == "NetStream.Play.StreamNotFound")
				{
					var stream:NetStream = NetStream(eve.currentTarget);
					stream.close();
					stream = null;
				}
			}
			
			///////////////////////////////////////////// load Attendie Avatar //////////////////////////////////////
			private function loadAttendieAvatar():void
			{
				imageLoader = new Loader();
				imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadAttendieAavatarComplete);
				imageLoader.load(new URLRequest(encodeURI(currentParticipant.avatar)));
			}
			
			///////////////////////////////////////////// Load Attendie Avatar //////////////////////////////////////////
			private function loadAttendieAavatarComplete(eve:Event):void
			{
				userImage.source = eve.currentTarget.content;
				userImage.visible = true;
			}
			
			///////////////////////////////////////////// show Menu onclick //////////////////////////////////////////
			private function showMenu(eve:MouseEvent):void
			{
				userClicked = eve.currentTarget as User;
				clickList.selectedItem = null;
				if (userClicked == leftParticipant && clickList.dataProvider.length < 4) {
					clickList.dataProvider.addItem("Take Camera Back");
				} else {
					if (clickList.dataProvider.length > 3) {
						clickList.dataProvider.removeItemAt(3);
					}
				}
				clickList.visible = true;
				clickList.x =  this.mouseX + 5;
				if (clickList.x + clickList.width > this.width) 
				{
					clickList.x = this.mouseX - (clickList.width + 5);
				}
				
			}
			
			///////////////////////////////////////////// on Menu Clicked Option //////////////////////////////////////////
			protected function clickList_clickHandler(event:MouseEvent):void
			{
				switch (clickList.selectedIndex)
				{
					case 0:
						AllowCameraSelectedUser();
						break;
					case 1:
						AllowCameraSelecterUserHost();
						break;
					case 2:
						disconnectSelectedUser();
						break;
					case 3:
						takeCameraBack();
						break;
				}
			}
			
			///////////////////////////////////////////// Allow Selected User Cam //////////////////////////////////////////
			private function AllowCameraSelectedUser():void
			{
				if (userClicked == currentParticipant)
				{
					Alert.show("Selected User is already streaming camera.");
				} else {
					currentParticipant = userClicked;
					var userInfo:Object = new Object();
					userInfo.name = currentParticipant.nametoDisplay;
					userInfo.avatar = currentParticipant.avatar;
					userInfo.type = currentParticipant.type;
					userInfo.isCameraAvailable = currentParticipant.isCameraAvailable;
					userInfo.id = currentParticipant.streamID;
					nc.call("changeRightVideoStream", null, userInfo);
					startReceiving();
				}
			}
			
			////////////////////////////////////// Allow Selected User Cam on Host //////////////////////////////////////////
			
			private function disconnectSelectedUser():void
			{
				if (userClicked == leftParticipant) {
					startSendingStream();
					nc.call("changeLeftVideoStream", null, null);
				}
				var userInfo:Object = new Object();
				trace (userClicked.nametoDisplay);
				userInfo.name = userClicked.nametoDisplay;
				userInfo.avatar = userClicked.avatar;
				userInfo.type = userClicked.type;
				userInfo.isCameraAvailable = userClicked.isCameraAvailable;
				userInfo.id = Number(userClicked.streamID);
				nc.call("KickUserOut", null, userInfo);
				trace (userInfo.name, userInfo.id);
				userClicked = null;
			}
			
			////////////////////////////////////// Disconnected Selected User //////////////////////////////////////////
			
			private function AllowCameraSelecterUserHost():void
			{
				if (userClicked == currentParticipant)
				{
					Alert.show("Selected User is already streaming camera.");
				} else {
					
					leftParticipant = userClicked;
					var userInfo:Object = new Object();
					userInfo.name = leftParticipant.nametoDisplay;
					userInfo.avatar = leftParticipant.avatar;
					userInfo.type = leftParticipant.type;
					userInfo.isCameraAvailable = leftParticipant.isCameraAvailable;
					userInfo.id = leftParticipant.streamID;
					nc.call("changeLeftVideoStream", null, userInfo);
					startReceivingOnHostVideo();
					isStreaming = false;
				}
			}
			
			////////////////////////////////////// Take Host Cam //////////////////////////////////////////
			
			private function takeCameraBack():void
			{
				leftParticipant = null;
				startSendingStream();
				nc.call("takeHostCameraback", null, null);
				//setup upload
				isStreaming = true;
			}
			
			////////////////////////////////////// create new Audio Stream //////////////////////////////////////////
			private function createNewAudioStream(sID:int):void
			{
				userAudioStream = new NetStream(nc);
				userAudioStream.addEventListener(NetStatusEvent.NET_STATUS, checkAudioStreamStatus);
				userAudioStream.play(sID+"AudioStream");
				trace ("playing :: " + sID + "AudioStream");
				audioStreamList.addItem({label:sID, data:userAudioStream});
				
			}
			
			//-------------------------------------- Server Side Functions -------------------------------------//
			
			///////////////////////////////////////////// get new client //////////////////////////////////////
			public function getNewParticipant(userInfo:Object):void 
			{
				users = new User();
				users.buttonMode = true;
				users.nametoDisplay = userInfo.name;
				users.avatar = userInfo.avatar;
				users.isCameraAvailable = userInfo.isCameraAvailable;
				users.type = userInfo.type;
				users.streamID = userInfo.id;
				
				userHolder.addElement(users);
				users.addEventListener(MouseEvent.CLICK, showMenu);
				
				//if its the first user
				if(userHolder.numElements == 1) {
					startAttendieStreamReceive(0);
				} else {
					createNewAudioStream(users.streamID);
				}
			}
			
			///////////////////////////////////////////// remove client //////////////////////////////////////
			public function removeParticipant(id:Number):void 
			{
				var currentUser:User;
				//remove from the list
				for (var count:int = 0; count < userHolder.numElements; count++)
				{
					currentUser = userHolder.getElementAt(count) as User;
					if (currentUser.streamID == id) {
						userHolder.removeElementAt(count);
						break;
					}
				}
				
				for (var scount:int = 0; scount < audioStreamList.length; scount++)
				{
					if (audioStreamList.getItemAt(scount).label == id)
					{
						var currentStream:NetStream = NetStream(audioStreamList.getItemAt(scount).data);
						audioStreamList.removeItemAt(scount);
						currentStream = null;
					}
				}
				
				if (userHolder.numElements > 0) {
					startAttendieStreamReceive(0);
					//call the server side function for changing the video stream on user disconnect.
					var userInfo:Object = new Object();
					userInfo.name = currentParticipant.nametoDisplay;
					userInfo.avatar = currentParticipant.avatar;
					userInfo.type = currentParticipant.type;
					userInfo.isCameraAvailable = currentParticipant.isCameraAvailable;
					userInfo.id = currentParticipant.streamID;
					nc.call("changeRightVideoStream", null, userInfo);
				}
			}
			
			///////////////////////////////////////////// change Attendie Video //////////////////////////////////////
			public function changeAttendieVideo(user:Object):void 
			{
				
			}
			
			///////////////////////////////////////////// change Attendie Video //////////////////////////////////////
			public function changeHostVideo(user:Object):void 
			{
				
			}
			
			///////////////////////////////////////////// on Server Error //////////////////////////////////////
			public function errorFromServer(msg:String):void 
			{
				
			}
			
			///////////////////////////////////////////// upload/download check //////////////////////////////////////
			//for DBWCheck 
			public function showLowDBWMessage():void
			{
				showMessage("Your download bandwidth is poor, trying to re-establish connection.");
			}
			//for UBWCheck
			public function showLowUBWMessage():void
			{
				if(nc.connected) {
					nc.call("lowBandwidthAlert",null, userName);
				}
			}
			//responder for serverside call.
			public function bandwidthUpdate(name:String):void
			{
				if (name != userName) {
					showMessage(name + "'s video is poor, trying to re-establish connection.");
				}
			}
			//show message function.
			private function showMessage(msg:String):void
			{
				if(alertTimer.running) {
					PopUpManager.removePopUp(streamAlert);
					alertTimer.stop();
					alertTimer.reset();	
				}
				streamAlert = Alert.show(msg);
				streamAlert.mx_internal::alertForm.mx_internal::buttons[0].visible = false;
				alertTimer.start();
				alertTimer.addEventListener(TimerEvent.TIMER, closeAlert);
			}
			//close the alert
			private function closeAlert(eve:TimerEvent):void
			{
				PopUpManager.removePopUp(streamAlert);
				alertTimer.reset();
			}
			///////////////////////////////////////////// volume sliders //////////////////////////////////////
			protected function volumeSlider_changeHandler(event:SliderEvent):void
			{
				try {
					volumeTransform.volume = Math.round(volumeSlider.value/100);
					userAudioStream.soundTransform = volumeTransform;
					var stream:NetStream;
					for (var count:int=0; count < audioStreamList.length; count++) 
					{
						stream = NetStream(audioStreamList.getItemAt(count).data);
						stream.soundTransform = volumeTransform;
					}
				} catch (e:Error)
				{
					trace (e.message);
				}
				
			}
			
			protected function volumeOnOff_clickHandler(event:MouseEvent):void
			{
				var stream:NetStream;
				var count:int;
				try {
					if (volumeSlider.enabled) {
						volumeTransform.volume = 0
						userAudioStream.soundTransform = volumeTransform;
						for (count=0; count < audioStreamList.length; count++) 
						{
							stream = NetStream(audioStreamList.getItemAt(count).data);
							stream.soundTransform = volumeTransform;
						}
						volumeSlider.enabled = false;
						volumeOnOff.alpha = 0.5;
						
					} else {
						volumeTransform.volume = Math.round(volumeSlider.value/100);
						userAudioStream.soundTransform = volumeTransform;
						
						for (count=0; count < audioStreamList.length; count++) 
						{
							stream = NetStream(audioStreamList.getItemAt(count).data);
							stream.soundTransform = volumeTransform;
						}
						volumeSlider.enabled = true;
						volumeOnOff.alpha = 1;
					}
				} catch (e:Error) {
					trace (e.message);
				}
			}
			
			protected function showDebugger(event:MouseEvent):void
			{
				if (event.ctrlKey) {
					debugwindow.visible = true;
				}
			}
			
			protected function startDebugging(event:TimerEvent):void
			{
				debugwindow.trace (microphone.name + " :: "+ microphone.activityLevel);
				debugwindow.trace ("total students in stream list :: " + audioStreamList.length);
				for (var count:int = 0; count < audioStreamList.length; count++) {
					debugwindow.trace ("Audio Bytes :: " + NetStream(audioStreamList.getItemAt(count).data).info.audioByteCount);
				}
			}
		
			protected function startDebug(event:MouseEvent):void
			{
				if (startDebugButton.label == "start") {
					startDebugButton.label = "stop";
					debugwindow.visible = true;
					debugTimer.start();
				} else {
					startDebugButton.label = "start";
					debugwindow.visible = false;
					debugTimer.stop();
				}
			}
			
		]]>
	</fx:Script>
	<fx:Declarations>
		
	</fx:Declarations>
	<!-- Design Layer -->
	<s:Rect left="5" right="5" top="5" bottom="5" >
		<s:stroke>
			<s:SolidColorStroke caps="none" color="#C3C3C3" joints="miter" miterLimit="4" weight="1"/>
		</s:stroke>
		<s:fill>
			<s:SolidColor color="#E1E1E1"/>
		</s:fill>
	</s:Rect>
	
	<mx:VideoDisplay id="hostVideo" x="10" y="10" width="240" height="180"/>
	<mx:VideoDisplay id="attendieVideo" x="275" y="10" width="240" height="180"/>
	<s:TileGroup id="userHolder" x="10" y="198" width="490" height="92">
	</s:TileGroup>
	<s:Image id="hostImage" x="10" y="10" width="240" height="180" backgroundColor="#000000"
			 smooth="true" source=""/>
	<s:Image id="userImage" x="275" y="9" width="240" height="180" backgroundColor="#000000"
			 smooth="true" source=""/>
	<s:Label id="hostNameLabel" x="10" y="169" width="240" height="21" backgroundAlpha="0.3"
			 backgroundColor="#000000" color="#FFFFFF" fontFamily="Verdana" fontWeight="bold"
			 textAlign="center" verticalAlign="middle"/>
	<s:Label id="userNameLabel" x="275" y="169" width="240" height="21" backgroundAlpha="0.3"
			 backgroundColor="#000000" color="#FFFFFF" fontFamily="Verdana" fontWeight="bold"
			 textAlign="center" verticalAlign="middle"/>
	<s:List id="clickList" visible="false" x="70" y="163" width="175" click="clickList_clickHandler(event)" >
		<s:layout>
			<s:VerticalLayout useVirtualLayout="false" requestedMinRowCount="1"/>
		</s:layout>

		<s:ArrayCollection>
			<fx:String>Allow Camera</fx:String>
			<fx:String>Allow Camera (Host video) </fx:String>
			<fx:String>Kick User</fx:String>
		</s:ArrayCollection>
	</s:List>
	<s:Image x="500" y="203" width="16" height="65" scaleMode="stretch" smooth="true"
			 source="@Embed('images/VolumeControl-_BG.png')"/>
	<mx:VSlider id="volumeSlider" x="501" y="210" width="15" height="50"
				change="volumeSlider_changeHandler(event)" liveDragging="true" maximum="100"
				minimum="0" showTrackHighlight="true" sliderThumbClass="{Skins.CSpSliderThumb}"
				trackHighlightSkin="{Skins.CustomSliderTrackHighlighterSkin}"
				trackSkin="{Skins.SliderTrack}"/>
	<s:Image x="498" y="270" scaleMode="stretch" smooth="true" smoothingQuality="high"
			 source="@Embed('images/Speaker_BG.png')"/>
	<s:Image id="volumeOnOff" x="500" y="274" scaleMode="stretch" smooth="true"
			 smoothingQuality="high" source="@Embed('images/Speaker.png')" 
			 buttonMode="true" click="volumeOnOff_clickHandler(event)"/>
	<debugger:MonsterDebuggerFlex id="monsterDebugger">
	</debugger:MonsterDebuggerFlex>
	<debug:debugger id="debugWindow" x="95" y="10" width="336" height="258">
	</debug:debugger>
	<s:Button id="startDebugButton" x="460" y="5" width="60" label="start" click="startDebug(event)"/>
</s:Application>



Is This A Good Question/Topic? 0
  • +

Replies To: Whats wrong with the code.

#2 drmaxmad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-April 12

Re: Whats wrong with the code.

Posted 12 April 2012 - 01:50 PM

Found the issue was with the server side file, still its a little slow forum.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1