The following example shows how you can request access to the user’s microphone using the static Microphone.getMicrophone() method and listening for the status event.

Full code after the jump.

// ActionScript 3.0
var mic:Microphone = Microphone.getMicrophone();
mic.setLoopBack();
mic.addEventListener(StatusEvent.STATUS, mic_status);
 
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.text = "Detecting microphone...";
addChild(tf);
 
function mic_status(evt:StatusEvent):void {
    tf.text = "Microphone is muted?: " + mic.muted;
    switch (evt.code) {
        case "Microphone.Unmuted":
            tf.appendText("\n" + "Microphone access was allowed.");
            break;
        case "Microphone.Muted":
            tf.appendText("\n" + "Microphone access was denied.");
            break;
    }
}
Tagged with:
 

7 Responses to Detecting the microphone in Flash using ActionScript 3.0

  1. Tamer says:

    Hi,
    We were looking for a way to capture the mic audio data and save it to mp3
    Will this really need a flash communication server!??!

    Please advise
    Thanks
    Tamer

  2. Echo says:

    hi,
    thanks for useful example you placed here. i am too excited in capturing sound and saving it to whatever format for now. any Idea ?

    Thanks Again
    Echo

  3. Jim says:

    I want to know microphone recording too.
    Must we need FMS?
    Why cant it be saved to somewhere upon finishing recording?

  4. houdini says:

    Hi there!

    Isn’t it possible to store recorded data in byte array?

    Greetings houdini

  5. sara says:

    thank you this example help me in my work thanks_Egypt

  6. Anthony says:

    Hi all,
    If your interested in saving the input to the file, your will need to store it in a byte array and then output the byte array data to a file of your choose with the right encoding of the file.

    Check out: http://theflashblog.com/?p=1426

    Thanks,
    Ant.

  7. raste says:

    Hi
    Im Raste Yousif Qadr
    im from kurdstan\Soran

    How to cerat Dectionary in action Script

    Thank For Us

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam Protection by WP-SpamFree