3

我使用 ActionScript 3 构建了一个在 Desktop 中录制声音的应用程序,现在我将应用程序转换为 Andriod 应用程序,但是存在 SampleDataEvent.SAMPLE_DATA 事件没有接收到任何要记录的数据的问题这是代码:

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);
}
}

任何人都可以在这里提供帮助

4

1 回答 1

3

我想,也许您没有查看 AIR for Android 设置。如果您没有签入 RECORD_AUDIO。你应该检查一下。

参考下图。

在此处输入图像描述

于 2013-07-17T13:10:33.083 回答