在以下代码中如何将扬声器静音
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="300"
height="100"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.media.*;
import flash.net.NetStream;
private var myMic:Microphone;
private var recordingState:String = "idle";
private function init():void {
myMic = Microphone.getMicrophone();
myMic.setSilenceLevel(0);
myMic.rate = 44;
myMic.gain = 100;
myMic.setUseEchoSuppression(true);
micLevel.visible = true;
//Security.showSettings(SecurityPanel.MICROPHONE);
myMic.setLoopBack(true);
if (myMic != null)
{
myMic.setUseEchoSuppression(true);
micLevel.setProgress(myMic.activityLevel, 100);
addEventListener(Event.ENTER_FRAME, showMicLevel);
//micLevel.setProgress(myMic.activityLevel, 100);
}
}
private function showMicLevel(event:Event):void{
switch (recordingState){
case "idle" :
micLevel.setProgress(myMic.activityLevel, 100);
break;
}
}
]]>
</mx:Script>
<mx:ProgressBar x="0" y="36" mode="manual" id="micLevel" label="" labelPlacement="bottom" width="100" fontSize="10" fontWeight="normal"/>
答案 0 :(得分:2)
如果你只是想让麦克风的声音进入扬声器,那么</ p>
myMic.setLoopBack(false);
这将禁用麦克风检测到的声音在扬声器中播放。
EDIT1:
//use the function to disable sound completely.
private function disableSound():void
{
var newSoundTransform:SoundTransform=new SoundTransform();
newSoundTransform.volume=0;
this.soundTransform=newSoundTransform;
}
在init()函数中调用上述函数。 这将完全禁用来自应用程序的所有声音。