0
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

4

1 回答 1

0

似乎它只发生在 Mac Google Chrome 23.0.1271.101 中......

MAC:Safari,Firefox - 有效

Win8:Chrome,Firefox - 有效

于 2013-01-07T22:32:19.760 回答