使用ActionScript 3在Android中录制声音
作者:互联网
我使用ActionScript 3构建了一个在桌面上录制声音的应用程序,现在我将该应用程序转换为Andriod Application,但是存在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);
}
}
任何人都可以在这里帮助
谢谢
解决方法:
我认为,也许您不了解AIR for Android设置.如果您未签入RECORD_AUDIO.你应该检查一下.
请参考下图.
标签:record,actionscript-3,android 来源: https://codeday.me/bug/20191123/2064408.html