bigbluebutton-Github/bigbluebutton-client/src/MicrophoneCheck.mxml

101 lines
3.5 KiB
Plaintext
Raw Normal View History

2013-04-16 23:42:31 +08:00
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="215" height="138"
applicationComplete="appInit()">
<mx:Script>
<![CDATA[
private function appInit():void {
if (ExternalInterface.available) {
ExternalInterface.addCallback("showMicSettings", handleShowMicSettingsRequest);
2013-04-17 05:17:00 +08:00
ExternalInterface.addCallback("startTestMicrophone", handleStartTestMicrophoneRequest);
ExternalInterface.addCallback("stopTestMicrophone", handleStopTestMicrophoneRequest);
ExternalInterface.addCallback("showCamSettings", handleShowCamSettingsRequest);
2013-04-16 23:42:31 +08:00
}
// Tell out JS counterpart that we are ready.
if (ExternalInterface.available) {
ExternalInterface.call("BBBCheck.microphoneCheckAppReady");
}
}
private var mic:Microphone;
private function handleShowMicSettingsRequest():void {
mic = Microphone.getMicrophone();
if (mic != null) {
if (mic.muted) {
// user has disallowed access to the mic
mic.addEventListener(StatusEvent.STATUS, micStatusEventHandler);
Security.showSettings(SecurityPanel.PRIVACY);
} else {
// user has allowed access to the mic
2013-04-17 05:17:00 +08:00
handleStartTestMicrophoneRequest();
2013-04-16 23:42:31 +08:00
}
} else {
ExternalInterface.call("BBBCheck.noAvailableMicrophoneError");
}
}
private function micStatusEventHandler(event:StatusEvent):void {
switch(event.code) {
case "Microphone.Muted":
ExternalInterface.call("BBBCheck.microphoneAccessDenied");
break;
case "Microphone.Unmuted":
ExternalInterface.call("BBBCheck.microphoneAccessAllowed");
handleStartTestMicrophoneRequest();
break;
}
}
private function camStatusEventHandler(event:StatusEvent):void {
2013-04-16 23:42:31 +08:00
switch(event.code) {
case "Microphone.Muted":
ExternalInterface.call("BBBCheck.microphoneAccessDenied");
break;
case "Microphone.Unmuted":
ExternalInterface.call("BBBCheck.microphoneAccessAllowed");
2013-04-17 05:17:00 +08:00
handleStartTestMicrophoneRequest();
break;
case "Camera.Unmuted":
ExternalInterface.call("BBBCheck.camAccessAllowed");
2013-04-17 05:17:00 +08:00
break;
case "Camera.Muted":
ExternalInterface.call("BBBCheck.camAccessDenied");
2013-04-16 23:42:31 +08:00
break;
}
}
2013-04-17 05:17:00 +08:00
private function handleStartTestMicrophoneRequest():void {
2013-04-16 23:42:31 +08:00
if (mic != null) {
mic.setLoopBack(true);
mic.setUseEchoSuppression(true);
2013-04-17 05:17:00 +08:00
Security.showSettings(SecurityPanel.MICROPHONE);
}
}
private function handleStopTestMicrophoneRequest():void {
if (mic != null) {
2013-04-16 23:42:31 +08:00
mic.setLoopBack(false);
2013-04-17 05:17:00 +08:00
}
}
private var cam:Camera;
2013-04-17 05:17:00 +08:00
private function handleShowCamSettingsRequest():void {
cam = Camera.getCamera();
cam.addEventListener(StatusEvent.STATUS, camStatusEventHandler);
if (cam.muted) {
Security.showSettings(SecurityPanel.PRIVACY);
} else {
Security.showSettings(SecurityPanel.CAMERA);
}
2013-04-16 23:42:31 +08:00
}
2013-04-17 05:17:00 +08:00
2013-04-16 23:42:31 +08:00
]]>
</mx:Script>
</mx:Application>