Sameer H. Ibra
Sameer H. Ibra

Reputation: 1826

Record Sound in Android using ActionScript 3

i build a application that record sound in Desktop using ActionScript 3 , now i convert the application to Andriod Application but there is a problem that SampleDataEvent.SAMPLE_DATA event doesn't receive any data to record Here is the code :

private var _microphone:Microphone;
private var _buffer:ByteArray = new ByteArray();
private var _difference:uint;

public function record():void
{
    if ( _microphone == null )
        _microphone = Microphone.getMicrophone();

    _difference = getTimer();
    _microphone.setSilenceLevel(_silenceLevel, _timeOut);
    _microphone.gain = _gain;
    _microphone.rate = _rate;
    _buffer.length = 0;
    _microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
    _microphone.addEventListener(StatusEvent.STATUS, onStatus);
} 

private function onSampleData(event:SampleDataEvent):void
{
    _recordingEvent.time = getTimer() - _difference;
    dispatchEvent( _recordingEvent );
    var buteData:Number;
    while(event.data.bytesAvailable > 0)
    {
        buteData = event.data.readFloat();
        _buffer.writeFloat(buteData);
        soundBytes.writeFloat( buteData);
}
}

anyone can help here Thanx

Upvotes: 3

Views: 480

Answers (1)

bitmapdata.com
bitmapdata.com

Reputation: 9600

I think, maybe you don't check out about AIR for Android settings. If you not checked in the RECORD_AUDIO. you should check it.

refer a below image.

enter image description here

Upvotes: 3

Related Questions