mankis
asked on
Flex - where to add this line of code
I need to set initial value in text field like this calleeInput.text = application.hisusername;
For now this value shows only when you connect, disconnect and than connect again.
This value is from html, flash parameters.
Where do I need to put calleeInput.text = application.hisusername; to set this value as soon as this field shows?
For now this value shows only when you connect, disconnect and than connect again.
This value is from html, flash parameters.
Where do I need to put calleeInput.text = application.hisusername; to set this value as soon as this field shows?
<?xml version="1.0" encoding="utf-8"?>
<!--
ADOBE SYSTEMS INCORPORATED
Copyright 2008-2011 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.
Author: Jozsef Vass
-->
<!-- Adobe labs limit width to 520 pixels. -->
<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" creationComplete="init()" backgroundColor="0xffffff" width="520" height="630">
<fx:Script>
<![CDATA[
import flash.events.SampleDataEvent;
import mx.charts.chartClasses.StackedSeries;
import mx.collections.ArrayList;
import mx.formatters.DateFormatter;
import mx.core.FlexGlobals;
import mx.controls.Alert;
import mx.utils.StringUtil;
// rtmfp server address (Adobe Cirrus or FMS)
//[Bindable] private var connectUrl:String = "rtmfp://operamundo.ch:1935/peer2peer-chat";
[Bindable] private var connectUrl:String = "rtmfp://p2p.rtmfp.net/b2ab58603fbd9fb7827128c0-5fa83c739c8f/";
// developer key, please insert your developer key here
private const DeveloperKey:String = "b2ab58603fbd9fb7827128c0-5fa83c739c8f";
// please insert your web service URL here for exchanging peer ID
private const WebServiceUrl:String = "http://www.operamundo.ch/VideoPhone-test/bin-debug/reg.php";
// this is the connection to rtmfp server
private var netConnection:NetConnection;
private var maxPeerConnections:uint = 100;
// outgoing media stream (audio, video, text and some control messages)
private var outgoingStream:NetStream;
// incoming media stream (audio, video, text and some control messages)
private var incomingStream:NetStream;
// ID management serice
private var idManager:AbstractIdManager;
private var remoteVideo:Video;
// login/registration states
private const LoginNotConnected:String = "LoginNotConnected";
private const LoginConnecting:String = "LoginConnecting";
private const LoginConnected:String = "LoginConnected";
private const LoginDisconnecting:String = "LoginDisconnecting";
// call states, only used when LoginConnected
private const CallReady:String = "CallReady";
private const CallCalling:String = "CallCalling";
private const CallRinging:String = "CallRinging";
private const CallEstablished:String = "CallEstablished";
private const CallFailed:String = "CallFailed";
// available microphone devices
[Bindable] private var micNames:ArrayList = new ArrayList();
private var micIndex:int = 0;
// available camera deviced
[Bindable] private var cameraNames:ArrayList = new ArrayList();
private var cameraIndex:int = 0;
private var activityTimer:Timer;
// user name is saved in local shared object
private var localSO:SharedObject;
[Bindable] private var application:Object;
[Bindable] private var remoteName:String = "";
private var remoteId:String = "";
private var callTimer:int;
// charts
private var audioRate:Array = new Array(30);
[Bindable] private var audioRateDisplay:ArrayList = new ArrayList();
private var videoRate:Array = new Array(30);
[Bindable] private var videoRateDisplay:ArrayList = new ArrayList();
private var srtt:Array = new Array(30);
[Bindable] private var srttDisplay:ArrayList = new ArrayList();
private var ringer:Sound;
private var ringerChannel:SoundChannel;
// signaling
/**
* Simple request-reply protocol.
*
* Call flow 1, caller cancels call
* FP1 --- Invite --> FP2
* FP1 --- Cancel --> FP2
* FP1 <-- Ok ------- FP2
*
* Call flow 2, callee rejects call
* FP1 --- Invite --> FP2
* FP1 <-- Reject --- FP2
*
* * Call flow 3, call established and caller ends call
* FP1 --- Invite --> FP2
* FP1 <-- Accept --- FP2
* FP1 --- Bye -----> FP2
* FP1 <-- Ok ------- FP2
*/
private const Relay:String = "relay";
private const Invite:String = "invite";
private const Cancel:String = "cancel";
private const Accept:String = "accept";
private const Reject:String = "reject";
private const Bye:String = "bye";
private const Ok:String = "ok";
// called when application is loaded
private function init():void
{
status("Player: " + Capabilities.version + "\n");
currentState = LoginNotConnected;
localSO = SharedObject.getLocal("videoPhoneSettings");
application = FlexGlobals.topLevelApplication.parameters;
if (localSO.data.hasOwnProperty("user"))
{
userNameInput.text = localSO.data.user;
}else{
userNameInput.text = FlexGlobals.topLevelApplication.parameters.username;
}
if (localSO.data.hasOwnProperty("hisusername"))
{
calleeInput.text = localSO.data.hisusername;
//Alert.show(StringUtil.substitute("Hello {0}! calleeInput.text", calleeInput.text));
}else{
calleeInput.text = application.hisusername;
//Alert.show(StringUtil.substitute("Hello {0}!", application.hisusername));
}
var mics:Array = Microphone.names;
if (mics)
{
micNames.source = mics;
}
else
{
status("No microphone available.\n");
}
var cameras:Array = Camera.names;
if (cameras)
{
cameraNames.source = cameras;
}
else
{
status("No camera available.\n");
}
// statistics timer
activityTimer = new Timer(1000);
activityTimer.addEventListener(TimerEvent.TIMER, onActivityTimer);
activityTimer.start();
// selected mic device
micIndex = 0;
if (localSO.data.hasOwnProperty("micIndex"))
{
micIndex = localSO.data.micIndex;
}
micSelection.selectedIndex = micIndex;
// selected camera device
if (localSO.data.hasOwnProperty("cameraIndex"))
{
cameraIndex = localSO.data.cameraIndex;
}
cameraSelection.selectedIndex = cameraIndex;
// mic volume
var micVolume:int = 50;
if (localSO.data.hasOwnProperty("micVolume"))
{
micVolume = localSO.data.micVolume;
}
micVolumeSlider.value = micVolume;
// speaker volume
var speakerVolume:Number = 80;
if (localSO.data.hasOwnProperty("speakerVolume"))
{
speakerVolume = localSO.data.speakerVolume;
}
speakerVolumeSlider.value = speakerVolume;
// configure audio and video
var mic:Microphone = getMicrophone();
if (mic)
{
mic.gain = micVolume;
mic.addEventListener(StatusEvent.STATUS, onDeviceStatus);
mic.addEventListener(ActivityEvent.ACTIVITY, onDeviceActivity);
handleCodecChange();
}
var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
camera.addEventListener(StatusEvent.STATUS, onDeviceStatus);
camera.addEventListener(ActivityEvent.ACTIVITY, onDeviceActivity);
cameraChanged();
}
}
private function status(msg:String):void
{
statusArea.text += msg;
statusArea.validateNow();
trace("ScriptDebug: " + msg);
}
// user clicked connect
private function onConnect():void
{
statusArea.text = "";
//localSO.data.user = userNameInput.text;
localSO.data.user = FlexGlobals.topLevelApplication.parameters.username;
localSO.data.hisusername = application.hisusername;
try
{
localSO.flush();
}
catch (e:Error)
{
status("Cannot write shared object\n");
}
netConnection = new NetConnection();
netConnection.maxPeerConnections = this.maxPeerConnections;
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionHandler);
// incoming call coming on NetConnection object
var c:Object = new Object();
c.onRelay = function(id:String, action:String, name:String):void
{
status("Request: " + action + " from: " + id + " (" + name + ")\n");
if (Invite == action)
{
if (currentState == CallReady)
{
calleeInput.text = application.hisusername;
ring();
currentState = CallRinging;
// callee subscribes to media, to be able to get the remote user name
incomingStream = new NetStream(netConnection, id);
incomingStream.addEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
incomingStream.play("media-caller");
// set volume for incoming stream
var st:SoundTransform = new SoundTransform(speakerVolumeSlider.value / 100);
incomingStream.soundTransform = st;
incomingStream.receiveAudio(false);
incomingStream.receiveVideo(false);
var i:Object = new Object;
i.onIm = function(name:String, text:String):void
{
textOutput.text += name + ": " + text + "\n";
textOutput.validateNow();
}
incomingStream.client = i;
remoteName = name;
remoteId = id;
}
else
{
status("Call rejected due to state: " + currentState + "\n");
netConnection.call(Relay, null, id, Reject, userNameInput.text);
}
}
else if (Reject == action)
{
currentState = CallReady;
onHangup();
}
else if (Accept == action)
{
if (currentState != CallCalling)
{
status("Call accept: Wrong call state: " + currentState + "\n");
return;
}
currentState = CallEstablished;
}
else if (Bye == action)
{
netConnection.call(Relay, null, id, Ok, userNameInput.text);
currentState = CallReady;
onHangup();
}
else if (Cancel == action)
{
netConnection.call(Relay, null, id, Ok, userNameInput.text);
currentState = CallReady;
onHangup();
}
}
netConnection.client = c;
try
{
netConnection.connect(connectUrl, DeveloperKey);
}
catch (e:ArgumentError)
{
status("Incorrect connet URL\n");
return;
}
currentState = LoginConnecting;
status("Connecting to " + connectUrl + "\n");
}
private function netConnectionHandler(event:NetStatusEvent):void
{
status("NetConnection event: " + event.info.code + "\n");
switch (event.info.code)
{
case "NetConnection.Connect.Success":
connectSuccess();
break;
case "NetConnection.Connect.Closed":
currentState = LoginNotConnected;
break;
case "NetStream.Connect.Success":
// we get this when other party connects to our outgoing stream
status("Connection from: " + event.info.stream.farID + "\n");
break;
case "NetConnection.Connect.Failed":
status("Unable to connect to " + connectUrl + "\n");
currentState = LoginNotConnected;
break;
}
}
private function outgoingStreamHandler(event:NetStatusEvent):void
{
status("Outgoing stream event: " + event.info.code + "\n");
}
private function incomingStreamHandler(event:NetStatusEvent):void
{
status("Incoming stream event: " + event.info.code + "\n");
}
// connection to rtmfp server succeeded and we register our peer ID with an id exchange service
// other clients can use id exchnage service to lookup our peer ID
private function connectSuccess():void
{
status("Connected, my ID: " + netConnection.nearID + "\n");
// exchange peer id using web service
idManager = new HttpIdManager();
idManager.service = WebServiceUrl;
idManager.addEventListener("registerSuccess", idManagerEvent);
idManager.addEventListener("registerFailure", idManagerEvent);
idManager.addEventListener("lookupFailure", idManagerEvent);
idManager.addEventListener("lookupSuccess", idManagerEvent);
idManager.addEventListener("idManagerError", idManagerEvent);
idManager.register(userNameInput.text, netConnection.nearID);
}
private function placeCall(user:String, identity:String):void
{
status("Calling " + user + ", id: " + identity + "\n");
if (identity.length != 64)
{
status("Invalid remote ID, call failed\n");
currentState = CallFailed;
return;
}
netConnection.call(Relay, null, identity, Invite, userNameInput.text);
// caller publishes media stream
outgoingStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, outgoingStreamHandler);
outgoingStream.publish("media-caller");
var o:Object = new Object
o.onPeerConnect = function(caller:NetStream):Boolean
{
status("Callee connecting to media stream: " + caller.farID + "\n");
return true;
}
outgoingStream.client = o;
startAudio();
startVideo();
// caller subscribes to callee's media stream
incomingStream = new NetStream(netConnection, identity);
incomingStream.addEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
incomingStream.play("media-callee");
// set volume for incoming stream
var st:SoundTransform = new SoundTransform(speakerVolumeSlider.value / 100);
incomingStream.soundTransform = st;
var i:Object = new Object;
i.onIm = function(name:String, text:String):void
{
textOutput.text += name + ": " + text + "\n";
}
incomingStream.client = i;
remoteVideo = new Video();
remoteVideo.width = 320;
remoteVideo.height = 240;
remoteVideo.attachNetStream(incomingStream);
remoteVideoDisplay.addChild(remoteVideo);
remoteName = user;
remoteId = identity;
currentState = CallCalling;
}
// process successful response from id manager
private function idManagerEvent(e:Event):void
{
status("ID event: " + e.type + "\n");
if (e.type == "registerSuccess")
{
switch (currentState)
{
case LoginConnecting:
currentState = LoginConnected;
break;
case LoginDisconnecting:
case LoginNotConnected:
currentState = LoginNotConnected;
return;
case LoginConnected:
return;
}
currentState = CallReady;
}
else if (e.type == "lookupSuccess")
{
// party query response
var i:IdManagerEvent = e as IdManagerEvent;
placeCall(i.user, i.id);
}
else
{
// all error messages ar IdManagerError type
var error:IdManagerError = e as IdManagerError;
status("Error description: " + error.description + "\n")
onDisconnect();
}
}
// user clicked accept button
private function acceptCall():void
{
stopRing();
incomingStream.receiveAudio(true);
incomingStream.receiveVideo(true);
remoteVideo = new Video();
remoteVideo.width = 320;
remoteVideo.height = 240;
remoteVideo.attachNetStream(incomingStream);
remoteVideoDisplay.addChild(remoteVideo);
// callee publishes media
outgoingStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, outgoingStreamHandler);
outgoingStream.publish("media-callee");
var o:Object = new Object
o.onPeerConnect = function(caller:NetStream):Boolean
{
status("Caller connecting to media stream: " + caller.farID + "\n");
return true;
}
outgoingStream.client = o;
netConnection.call(Relay, null, remoteId, Accept, userNameInput.text);
startVideo();
startAudio();
currentState = CallEstablished;
}
private function onDisconnect():void
{
status("Disconnecting.\n");
onHangup();
if (idManager)
{
idManager.unregister();
idManager = null;
}
currentState = LoginNotConnected;
netConnection.close();
netConnection = null;
}
// placing a call
private function onCall():void
{
if (netConnection && netConnection.connected)
{
if (calleeInput.text.length == 0)
{
status("Please enter name to call\n");
return;
}
// first, we need to lookup callee's peer ID
if (idManager)
{
idManager.lookup(calleeInput.text);
}
else
{
status("Not registered.\n");
return;
}
}
else
{
status("Not connected.\n");
}
}
private function startAudio():void
{
if (sendAudioCheckbox.selected)
{
var mic:Microphone = getMicrophone();
if (mic && outgoingStream)
{
outgoingStream.attachAudio(mic);
}
}
else
{
if (outgoingStream)
{
outgoingStream.attachAudio(null);
}
}
}
private function startVideo():void
{
if (sendVideoCheckbox.selected)
{
var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
localVideoDisplay.attachCamera(camera);
if (outgoingStream)
{
outgoingStream.attachCamera(camera);
}
}
}
else
{
localVideoDisplay.attachCamera(null);
if (outgoingStream)
{
outgoingStream.attachCamera(null);
}
}
}
// this function is called in every second to update charts, microhone level, and call timer
private function onActivityTimer(e:TimerEvent):void
{
var mic:Microphone = getMicrophone();
if (mic)
{
micActivityLabel.text = mic.activityLevel.toString();
}
if (currentState == CallEstablished && incomingStream && outgoingStream && outgoingStream.peerStreams.length == 1)
{
var recvInfo:NetStreamInfo = incomingStream.info;
var sentInfo:NetStreamInfo = outgoingStream.peerStreams[0].info;
audioRate.shift();
var a:Object = new Object;
a.Recv = recvInfo.audioBytesPerSecond * 8 / 1024;
a.Sent = sentInfo.audioBytesPerSecond * 8 / 1024;
audioRate.push(a);
audioRateDisplay.source = audioRate;
videoRate.shift();
var v:Object = new Object;
v.Recv = recvInfo.videoBytesPerSecond * 8 / 1024;
v.Sent = sentInfo.videoBytesPerSecond * 8 / 1024;
videoRate.push(v);
videoRateDisplay.source = videoRate;
srtt.shift();
var s:Object = new Object;
s.Data = recvInfo.SRTT;
srtt.push(s);
srttDisplay.source = srtt;
}
if (currentState == CallEstablished)
{
callTimer++;
var elapsed:Date = new Date(2008, 4, 12);
elapsed.setTime(elapsed.getTime() + callTimer * 1000);
var formatter:DateFormatter = new DateFormatter();
var format:String = "JJ:NN:SS";
if (callTimer < 60)
{
format = "SS";
}
else if (callTimer < 60 * 60)
{
format = "NN:SS";
}
formatter.formatString = format
callTimerText.text = formatter.format(elapsed);
}
}
private function onDeviceStatus(e:StatusEvent):void
{
status("Device status: " + e.code + "\n");
}
private function onDeviceActivity(e:ActivityEvent):void
{
// status("Device activity: " + e.activating + "\n");
}
private function onHangup():void
{
status("Hanging up call\n");
// signaling based on state
if (CallEstablished == currentState)
{
netConnection.call(Relay, null, remoteId, Bye, userNameInput.text);
}
else if (CallCalling == currentState)
{
netConnection.call(Relay, null, remoteId, Cancel, userNameInput.text);
}
else if (CallRinging == currentState)
{
netConnection.call(Relay, null, remoteId, Reject, userNameInput.text);
}
stopRing();
//calleeInput.text = FlexGlobals.topLevelApplication.parameters.hisusername;
calleeInput.text = application.hisusername;
currentState = CallReady;
if (incomingStream)
{
incomingStream.close();
incomingStream.removeEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
}
if (outgoingStream)
{
outgoingStream.close();
outgoingStream.removeEventListener(NetStatusEvent.NET_STATUS, outgoingStreamHandler);
}
incomingStream = null;
outgoingStream = null;
remoteName = "";
remoteId = "";
receiveAudioCheckbox.selected = true;
receiveVideoCheckbox.selected = true;
callTimer = 0;
}
private function getMicrophone():Microphone
{
if (enhancedCheckbox.selected)
{
return Microphone.getEnhancedMicrophone(micIndex);
}
else
{
return Microphone.getMicrophone(micIndex);
}
}
private function speakerVolumeChanged(e:Event):void
{
if (incomingStream)
{
var volume:Number = e.target.value / 100;
var st:SoundTransform = new SoundTransform(volume);
incomingStream.soundTransform = st;
status("Setting speaker volume to: " + volume + "\n");
}
localSO.data.speakerVolume = e.target.value;
try
{
localSO.flush();
}
catch (e:Error)
{
status("Cannot write shared object\n");
}
}
private function micVolumeChanged(e:Event):void
{
var mic:Microphone = getMicrophone();
if (mic)
{
mic.gain = e.target.value;
localSO.data.micVolume = e.target.value;
localSO.flush();
status("Setting mic volume to: " + e.target.value + "\n");
}
}
// sending text message
private function onSend():void
{
var msg:String = textInput.text;
if (msg.length != 0 && outgoingStream)
{
textOutput.text += userNameInput.text + ": " + msg + "\n";
outgoingStream.send("onIm", userNameInput.text, msg);
textInput.text = "";
}
}
private function micChanged(event:Event):void
{
micIndex = micSelection.selectedIndex;
var mic:Microphone = getMicrophone();
// set the new microphne values based on UI
mic.gain = micVolumeSlider.value;
mic.addEventListener(StatusEvent.STATUS, onDeviceStatus);
mic.addEventListener(ActivityEvent.ACTIVITY, onDeviceActivity);
handleCodecChange();
if (currentState == CallEstablished)
{
outgoingStream.attachAudio(mic);
}
localSO.data.micIndex = micIndex;
try
{
localSO.flush();
}
catch (e:Error)
{
status("Cannot write shared object\n");
}
}
private function cameraChanged(event:Event = null):void
{
cameraIndex = cameraSelection.selectedIndex;
var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
camera.setMode(320, 240, 15);
camera.setQuality(0, videoQualitySlider.value);
}
// when user changes video device, we want to show preview
localVideoDisplay.attachCamera(camera);
if (currentState == CallEstablished)
{
outgoingStream.attachCamera(camera);
}
localSO.data.cameraIndex = cameraIndex;
try
{
localSO.flush();
}
catch (e:Error)
{
status("Cannot write shared object\n");
}
}
private function videoQualityChanged(e:Event = null):void
{
var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
camera.setQuality(0, videoQualitySlider.value);
status("Setting camera quality to: " + videoQualitySlider.value + "\n");
}
}
private function onAudioMuted():void
{
if (incomingStream)
{
incomingStream.receiveAudio(receiveAudioCheckbox.selected);
}
}
private function onVideoPaused():void
{
if (incomingStream)
{
incomingStream.receiveVideo(receiveVideoCheckbox.selected);
}
}
private function handleCodecChange():void
{
var mic:Microphone = getMicrophone();
if (mic)
{
if (codecGroup.selectedValue == "speex")
{
codecPropertyStack.selectedChild = speexProperties;
mic.codec = SoundCodec.SPEEX;
mic.framesPerPacket = 1;
mic.encodeQuality = int(speexQualitySelector.selectedItem);
mic.setSilenceLevel(0);
}
else
{
codecPropertyStack.selectedChild = nellymoserProperties;
mic.codec = SoundCodec.NELLYMOSER;
mic.rate = int(nellymoserRateSelector.selectedItem);
mic.setSilenceLevel(0);
}
}
}
private function speexQuality(e:Event):void
{
var mic:Microphone = getMicrophone();
if (mic)
{
var quality:int = int(e.target.selectedItem);
mic.encodeQuality = quality;
status("Setting speex quality to: " + quality + "\n");
}
}
private function nellymoserRate(e:Event):void
{
var mic:Microphone = getMicrophone();
if (mic)
{
var rate:int = int(e.target.selectedItem);
mic.rate = rate;
status("Setting Nellymoser rate to: " + rate + "\n");
}
}
private function ring():void
{
ringer = new Sound();
ringer.addEventListener("sampleData", ringTone);
ringerChannel = ringer.play();
}
private function stopRing():void
{
if (ringerChannel)
{
ringerChannel.stop();
ringer.removeEventListener("sampleData", ringTone);
ringer = null;
ringerChannel = null;
}
}
private function ringTone(event:SampleDataEvent):void
{
for (var c:int=0; c<8192; c++)
{
var pos:Number = Number(c + event.position) / Number(6 * 44100);
var frac:Number = pos - int(pos);
var sample:Number;
if (frac < 0.066)
{
sample = 0.4 * Math.sin(2* Math.PI / (44100/784) * (Number(c + event.position)));
}
else if (frac < 0.333)
{
sample = 0.2 * (Math.sin(2* Math.PI / (44100/646) * (Number(c + event.position)))
+ Math.sin(2* Math.PI / (44100/672) * (Number(c + event.position)))
+ Math.sin(2* Math.PI / (44100/1034) * (Number(c + event.position)))
+ Math.sin(2* Math.PI / (44100/1060) * (Number(c + event.position))));
}
else
{
sample = 0;
}
event.data.writeFloat(sample);
event.data.writeFloat(sample);
}
}
]]>
</fx:Script>
<fx:Style>
.buttonStyle {
color: "0x000000";
textRollOverColor: "0x000000";
textSelectedColor: "0x000000";
}
.checkboxStyle
{
color: "0xffffff";
textRollOverColor: "0xffffff";
textSelectedColor: "0xffffff";
}
</fx:Style>
<s:states>
<s:State name="LoginNotConnected"/>
<s:State name="LoginConnecting"/>
<s:State name="LoginConnected"/>
<s:State name="LoginDisconnecting"/>
<s:State name="CallReady"/>
<s:State name="CallCalling"/>
<s:State name="CallRinging"/>
<s:State name="CallEstablished"/>
<s:State name="CallFailed"/>
</s:states>
<fx:Declarations>
<s:RadioButtonGroup id="codecGroup" change="handleCodecChange()"/>
</fx:Declarations>
<s:BorderContainer backgroundColor="0x194872" borderStyle="solid" cornerRadius="10"
backgroundColor.CallCalling="0x194872"
backgroundColor.CallEstablished="0x194872"
backgroundColor.CallFailed="0x194872"
backgroundColor.CallReady="0x194872"
backgroundColor.CallRinging="0x194872"
backgroundColor.LoginConnected="0x194872"
backgroundColor.LoginConnecting="0x194872"
backgroundColor.LoginDisconnecting="0x194872"
backgroundColor.LoginNotConnected="#194872">
<s:layout>
<s:VerticalLayout paddingTop="5" paddingLeft="5" paddingBottom="5" paddingRight="5"/>
</s:layout>
<!-- Login pane -->
<s:HGroup includeIn="LoginNotConnected" verticalAlign="middle">
<s:Label text="User Name: " color="0xffffff"/>
<s:TextArea id="userNameInput" includeIn="LoginNotConnected" width="104" height="23"
editable="true"/>
<s:Button label="CONNECT" click="onConnect()" enabled="{userNameInput.text.length > 0}" styleName="buttonStyle"/>
</s:HGroup>
<s:HGroup includeIn="LoginConnecting" verticalAlign="middle">
<s:Label text="Connecting to {connectUrl}" color="0xffffff"/>
<s:Button label="CANCEL" click="onDisconnect()" styleName="buttonStyle"/>
</s:HGroup>
<s:HGroup includeIn="LoginConnected, CallReady, CallCalling, CallRinging, CallEstablished, CallFailed" verticalAlign="middle">
<s:Label text="Connected as {userNameInput.text}" color="0xffffff"/>
<s:Button label="DISCONNECT" click="onDisconnect()" styleName="buttonStyle"/>
</s:HGroup>
<s:HGroup includeIn="LoginDisconnecting">
<s:Label text="Disconnecting from {connectUrl}" color="0xffffff"/>
</s:HGroup>
<!-- Call status pane -->
<s:Label text="Please enter user name and connect" color="0xffffff" height="22" includeIn="LoginNotConnected, LoginConnecting, LoginDisconnecting"/>
<s:HGroup includeIn="CallReady" verticalAlign="middle">
<s:TextInput id="calleeInput" width="96" editable="true" enter="onCall()" text="{application.hisusername}"/>
<s:Button label="CALL" click="onCall()" styleName="buttonStyle" enabled="{calleeInput.text.length > 0}"/>
</s:HGroup>
<s:HGroup includeIn="CallCalling" verticalAlign="middle">
<s:Label text="Calling {remoteName}" color="0xffffff"/>
<s:Button label="CANCEL" click="onHangup()" styleName="buttonStyle"/>
</s:HGroup>
<s:HGroup includeIn="CallRinging" verticalAlign="middle">
<s:Label text="Incoming call from: {remoteName}" color="0xffffff"/>
<s:Button label="ACCEPT" click="acceptCall()" styleName="buttonStyle"/>
<s:Button label="REJECT" click="onHangup()" styleName="buttonStyle"/>
</s:HGroup>
<s:HGroup includeIn="CallEstablished" verticalAlign="middle">
<s:Label text="Call in progress with {remoteName}" color="0xffffff"/>
<s:Button label="HANGUP" click="onHangup()" styleName="buttonStyle"/>
<s:Label id="callTimerText" color="0xffffff"/>
</s:HGroup>
<s:HGroup includeIn="CallFailed" verticalAlign="middle">
<s:Label text="Call failed to {calleeInput.text}" color="0xffffff"/>
<s:Button label="HANGUP" click="onHangup()" styleName="buttonStyle"/>
</s:HGroup>
<s:HGroup>
<mx:VideoDisplay id="remoteVideoDisplay" width="320" height="240" />
<s:VGroup>
<mx:VideoDisplay id="localVideoDisplay" width="180" height="135" />
<mx:Spacer height="10" />
<s:HGroup>
<s:Label text="Mic level:" color="0xffffff" width="56"/>
<s:Label id="micActivityLabel" color="0xffffff"/>
</s:HGroup>
<s:HGroup>
<s:Label text="Mic:" color="0xffffff" width="56"/>
<s:HSlider id="micVolumeSlider" showDataTip="false" width="120" minimum="0" maximum="100" change="micVolumeChanged(event)"/>
</s:HGroup>
<s:HGroup>
<s:Label text="Speaker:" color="0xffffff" width="56"/>
<s:HSlider id="speakerVolumeSlider" showDataTip="false" width="120" minimum="0" maximum="100" change="speakerVolumeChanged(event)"/>
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:Label text="Receive:" color="0xffffff" width="60"/>
<s:CheckBox id="receiveAudioCheckbox" label="Audio" fontSize="9" click="onAudioMuted()" enabled="{currentState == CallEstablished}" selected="true" styleName="checkboxStyle"/>
<s:CheckBox id="receiveVideoCheckbox" label="Video" fontSize="9" click="onVideoPaused()" enabled="{currentState == CallEstablished}" selected="true" styleName="checkboxStyle"/>
</s:HGroup>
</s:VGroup>
</s:HGroup>
<s:TextArea id="textOutput" width="509" height="100" editable="false" verticalScrollPolicy="auto"/>
<s:HGroup>
<s:TextInput id="textInput" width="432" enter="onSend()" />
<s:Button label="SEND" click="onSend()" styleName="buttonStyle" enabled="{textInput.text.length > 0 && currentState == CallEstablished}"/>
</s:HGroup>
<s:TabBar dataProvider="{optionsStack}" width="509" styleName="buttonStyle" />
<mx:ViewStack id="optionsStack" borderStyle="solid" creationPolicy="all" >
<s:NavigatorContent label="STATUS" color="0xffffff">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:TextArea id="statusArea" width="507" height="120" editable="false" verticalScrollPolicy="auto" color="black"/>
<s:Button label="CLEAR" click="statusArea.text=''" styleName="buttonStyle"/>
</s:NavigatorContent>
<s:NavigatorContent label="DEVICES" color="0xffffff" enabled="{currentState != LoginNotConnected}">
<s:layout>
<s:VerticalLayout paddingTop="5" paddingLeft="5" />
</s:layout>
<s:HGroup verticalAlign="middle">
<s:Label text="Audio capture: " color="0xffffff"/>
<s:ComboBox id="micSelection" dataProvider="{micNames}" change="micChanged(event)" color="black"/>
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:Label text="Video capture: " color="0xffffff"/>
<s:ComboBox id="cameraSelection" dataProvider="{cameraNames}" change="cameraChanged(event)" color="black"/>
</s:HGroup>
</s:NavigatorContent>
<s:NavigatorContent label="AUDIO/VIDEO" enabled="{currentState != LoginNotConnected}">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:Panel title="Audio Codec" width="247" height="135" backgroundColor="0xA0A0A0">
<s:layout>
<s:VerticalLayout paddingLeft="8"/>
</s:layout>
<s:HGroup>
<s:RadioButton groupName="codecGroup" value="speex" label="Speex" selected="true" />
<s:RadioButton groupName="codecGroup" value="nellymoser" label="Nellymoser" />
</s:HGroup>
<mx:ViewStack id="codecPropertyStack" resizeToContent="true" >
<s:NavigatorContent id="speexProperties">
<s:layout>
<s:HorizontalLayout verticalAlign="middle"/>
</s:layout>
<s:Label text="Encode quality: " />
<s:ComboBox id="speexQualitySelector" selectedIndex="6" change="speexQuality(event)" width="50">
<s:dataProvider>
<s:ArrayList>
<fx:int>0</fx:int>
<fx:int>1</fx:int>
<fx:int>2</fx:int>
<fx:int>3</fx:int>
<fx:int>4</fx:int>
<fx:int>5</fx:int>
<fx:int>6</fx:int>
<fx:int>7</fx:int>
<fx:int>8</fx:int>
<fx:int>9</fx:int>
<fx:int>10</fx:int>
</s:ArrayList>
</s:dataProvider>
</s:ComboBox>
</s:NavigatorContent>
<s:NavigatorContent id="nellymoserProperties">
<s:layout>
<s:HorizontalLayout verticalAlign="middle"/>
</s:layout>
<s:Label text="Encode rate [kHz]: " />
<s:ComboBox id="nellymoserRateSelector" selectedIndex="1" change="nellymoserRate(event)" width="50">
<s:dataProvider>
<s:ArrayList>
<fx:int>5</fx:int>
<fx:int>8</fx:int>
<fx:int>11</fx:int>
<fx:int>16</fx:int>
<fx:int>22</fx:int>
<fx:int>44</fx:int>
</s:ArrayList>
</s:dataProvider>
</s:ComboBox>
</s:NavigatorContent>
</mx:ViewStack>
<s:CheckBox id="sendAudioCheckbox" label="Send Audio" click="startAudio()" selected="true" />
<s:CheckBox id="enhancedCheckbox" label="Acoustic Echo Cancellation" selected="true" click="handleCodecChange(); startAudio()"/>
</s:Panel >
<s:Panel title="Video Quality" width="247" height="135" backgroundColor="0xA0A0A0">
<s:layout>
<s:VerticalLayout paddingLeft="8"/>
</s:layout>
<s:HSlider id="videoQualitySlider" width="220" showDataTip="false" minimum="1" maximum="100" value="80" change="videoQualityChanged(event)"/>
<s:CheckBox id="sendVideoCheckbox" label="Send Video" click="startVideo()" selected="true" />
</s:Panel>
</s:NavigatorContent>
<s:NavigatorContent label="STATISTICS" enabled="{currentState != LoginNotConnected}">
<s:Scroller width="100%" height="100%">
<s:VGroup>
<mx:LineChart id="audioRateChart" dataProvider="{audioRateDisplay}" height="105" width="485" color="0xffffff">
<mx:series>
<mx:LineSeries yField="Recv" displayName="Received Audio Rate [kbps]"/>
<mx:LineSeries yField="Sent" displayName="Sent Audio Rate [kbps]" />
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{audioRateChart}" direction="horizontal" color="0xffffff"/>
<mx:LineChart id="videoRateChart" dataProvider="{videoRateDisplay}" height="105" width="485" color="0xffffff">
<mx:series>
<mx:LineSeries yField="Recv" displayName="Received Video Rate [kbps]"/>
<mx:LineSeries yField="Sent" displayName="Sent Video Rate [kbps]" />
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{videoRateChart}" direction="horizontal" color="0xffffff"/>
<mx:LineChart id="rttChart" dataProvider="{srttDisplay}" height="105" width="485" color="0xffffff">
<mx:series>
<mx:LineSeries yField="Data" displayName="RTT [ms]" />
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{rttChart}" color="0xffffff"/>
</s:VGroup>
</s:Scroller>
</s:NavigatorContent>
</mx:ViewStack>
</s:BorderContainer>
</s:Application>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
uh, whole time I have been uploading to the wrong folder
ASKER