开发者

Flash and media (sound) files without media server

Is it possible to record a sound clip directly on a linux server using a flash script wit开发者_运维百科hout having a flash media server?


use MicRecorder. The follow comes from the projects site.

To record audio from the Microphone in your application, just use those few lines :

// 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();

When recording starts a RecordingEvent.RECORDING event is dispatched giving infos about time. When recording it stopped an Event.COMPLETE is dispatched allowing you to retrieve the Micorder.output bytes and save the audio stream (in this case as a WAV) using a simple FileReference object :

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

You can also replay what has been recorded by passing the raw WAV file to the WavSound object from the nice as3wavsound library :

private function onRecordComplete(event:Event):void
{
     var player:WavSound = new WavSound(recorder.output);
     player.play();
}

The MicRecorder object relies by default on the default Microphone device available, but you can pass any Microphone instance as replacement when creating the MicRecorder object :

// a specific Microphone instance can be passed
var recorder:MicRecorder = new MicRecorder( wavEncoder, microphoneDevice );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜