AS3麦克风as3在一段时间后没有响应

时间:2013-01-07 21:56:40

标签: actionscript-3 microphone

package  {

import flash.display.MovieClip;
import flash.display.Sprite;
    import flash.events.*;
    import flash.media.Microphone;
    import flash.system.Security;
import flash.external.ExternalInterface;
import fl.controls.Slider; 
import fl.events.SliderEvent; 
import fl.controls.ProgressBar; 
import flash.events.ProgressEvent; 
import fl.controls.ProgressBarMode; 
import fl.controls.ProgressBarDirection; 
import flash.media.Sound; 

public class mic extends MovieClip {

    var micr:Microphone;
    var aSlider:Slider;
    var aPb:ProgressBar;
    var timeout:Number=1000;

    public function mic() {
        micr = Microphone.getMicrophone();
        micr.gain=60;
        micr.rate=5; 
        micr.setSilenceLevel(7,timeout);
        Security.showSettings("2");
        micr.setUseEchoSuppression(true);
        micr.setLoopBack(true);

        aSlider = new Slider(); 
        aSlider.width = 200; 
        aSlider.height = 3;
        aSlider.snapInterval = 1; 
        aSlider.tickInterval = 1; 
        aSlider.maximum = 20; 
        aSlider.minimum = 3; 
        aSlider.value = micr.silenceLevel;
        aSlider.move(25, 110);
        addChild(aSlider); 

        aPb = new ProgressBar(); 
        aPb.width = 200; 
        aPb.height = 3;
        aPb.move(25,130); 
        aPb.direction = ProgressBarDirection.RIGHT; 
        aPb.mode = ProgressBarMode.MANUAL; 
        aPb.minimum = 0; 
        aPb.maximum = 100; 
        addChild(aPb); 

        if (micr != null) {
            micr.setUseEchoSuppression(true);
            micr.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
            micr.addEventListener(StatusEvent.STATUS, statusHandler);
            aSlider.addEventListener(SliderEvent.CHANGE, changeHandler); 

        }
    }

      private function activityHandler(event:ActivityEvent):void {
        if(event.activating){
            ExternalInterface.call("noiseEvent()");
            trace("activating=" + event.activating + ", activityLevel=" +  this.micr.activityLevel); 
        }
        aPb.setProgress(this.micr.activityLevel, aSlider.value); 
    }

    private function statusHandler(event:StatusEvent):void {
        trace("statusHandler: " + event);
    }

    private function changeHandler(event:SliderEvent):void { 
        micr.setSilenceLevel(event.target.value, timeout);
    }
}

}

我需要监听麦克风活动,然后调用一些js函数。 这是我的全部代码。 它工作正常,但约5分钟。然后没有回应。有什么建议吗?

MacOSx ML, Adobe Flash Player 11.5.31.5 Shockwave Flash 11.5 r31

1 个答案:

答案 0 :(得分:0)

似乎仅在Mac Google Chrome 23.0.1271.101中发生...

MAC:Safari,Firefox - 工作

Win8:Chrome,Firefox - 正常工作