2

In the following code how to mute the speakers

<?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"/>

Rajeev
  • 44,985
  • 76
  • 186
  • 285

1 Answers1

2

If you just want to disble the voice from microphone to come into the speakers do

myMic.setLoopBack(false);

This will disable the sound detected by microphone to be played in the speakers.

EDIT1:

//use the function to disable sound completely.


 private function disableSound():void
 {
    var newSoundTransform:SoundTransform=new SoundTransform();
    newSoundTransform.volume=0;
    this.soundTransform=newSoundTransform;
}

Call the above function in init() function. This will completely disable all sounds coming from the application.

Neeraj
  • 8,408
  • 8
  • 41
  • 69
  • Actually when i increase the volume on the system it just reproduces some unwanted noise so trying to get rid of it.. – Rajeev Jan 18 '11 at 09:21
  • if you want to completely disable sound for your application, then you can simply use a soundTransform object on the application.Ill edit my answer with the required changes shortly. – Neeraj Jan 18 '11 at 09:27
  • I 2 found a fix but not so sure of it,in the above code itself Mymic.gain *= 0.8; seems like it solved my problem.Is this a valid fix? Also how will i change the bar color in the above code – Rajeev Jan 18 '11 at 09:54
  • Rajeev, the fix if working seems to be a good way to do it.Also to change the colour use – Neeraj Jan 18 '11 at 09:58
  • Are you sure about it the flex compiler had given me some error i tried it days ago – Rajeev Jan 18 '11 at 10:02
  • im sorry to change the colour of the progress bar you need .Please try this out.This will surely work – Neeraj Jan 18 '11 at 10:07
  • That worked but even the background color changed ?Can we not retain the background color and change only the bar color – Rajeev Jan 18 '11 at 10:12
  • try using labelPlacement="bottom" , that would actully reduce the size of the progressbar and you would see two seperate colous for the progressbar and the label. – Neeraj Jan 18 '11 at 10:38
  • And neeraj is there a way to disable the security question that is been asked when the microphone is accessed Allow/Deny.. – Rajeev Jan 18 '11 at 10:43
  • I checked a few places, it doesnt seem possible, the reason is that, the browser doesn't allow any webapp to directly access low level resources like webcam data, without users permission. – Neeraj Jan 18 '11 at 14:44
  • Thanks for all the help Neeraj.Appreciate it – Rajeev Jan 18 '11 at 17:43