AS3 audiioencoder to convert to audio

ε祈祈猫儿з 提交于 2020-01-07 02:57:07

问题


In action script how to convert using audio encoder a recorded byte array from microphone to MP3

     public var recordedData:ByteArray;          
     recordedData.writeBytes(sample.data, 0, sample.data.bytesAvailable);

How to save recordedData to mp3 using audio encoder


回答1:


You find yourself an MP3 encoding library that runs in the Flash player. A simple google search finds Shine to be pretty popular. Another option is to stream the audio up to the server and encode there.

Depending on your environment, you might be able to use something like LAME if you are in Air and are willing to build a native extension to do the encoding.

EDIT

If you are using Shine, I found an example in the project that implies that encoding is easy:

private var mp3Encoder:ShineMP3Encoder;

private function encodeClicked(event:Event):void {
    mp3Encoder = new ShineMP3Encoder(wavLoader.data);
    mp3Encoder.addEventListener(Event.COMPLETE, mp3EncodeComplete);
    mp3Encoder.addEventListener(ProgressEvent.PROGRESS, mp3EncodeProgress);
    mp3Encoder.addEventListener(ErrorEvent.ERROR, mp3EncodeError);
    mp3Encoder.start();
}

private function saveClicked(event : MouseEvent) : void {
    mp3Encoder.saveAs();
}


来源:https://stackoverflow.com/questions/10448179/as3-audiioencoder-to-convert-to-audio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!