是否可以使用Flash脚本直接在Linux服务器上录制声音片段,而无需使用Flash媒体服务器?
答案 0 :(得分:3)
使用MicRecorder。以下内容来自项目网站。
要在应用程序中录制麦克风的音频,只需使用以下几行:
// volume in the final WAV file will be downsampled to 50%
var volume:Number = .5;
// we create the WAV encoder to be used by MicRecorder
var wavEncoder:WaveEncoder = new WaveEncoder( volume );
// we create the MicRecorder object which does the job
var recorder:MicRecorder = new MicRecorder( wavEncoder );
// starts recording
recorder.record();
// stop recording
recorder.stop();
录制开始时,将调度RecordingEvent.RECORDING事件,为时间提供信息。录制停止时,会调度Event.COMPLETE,允许您使用简单的FileReference对象检索Micorder.output字节并保存音频流(在本例中为WAV):
recorder.addEventListener(RecordingEvent.RECORDING, onRecording);
recorder.addEventListener(Event.COMPLETE, onRecordComplete);
private function onRecording(event:RecordingEvent):void
{
trace ( event.time );
}
private function onRecordComplete(event:Event):void
{
fileReference.save ( recorder.output, "recording.wav" );
}
您还可以通过将原始WAV文件从漂亮的as3wavsound库传递到WavSound对象来重放已记录的内容:
private function onRecordComplete(event:Event):void
{
var player:WavSound = new WavSound(recorder.output);
player.play();
}
默认情况下,MicRecorder对象依赖于可用的默认麦克风设备,但您可以在创建MicRecorder对象时传递任何麦克风实例作为替换:
// a specific Microphone instance can be passed
var recorder:MicRecorder = new MicRecorder( wavEncoder, microphoneDevice );