我已经搜索了很长时间,但没有找到任何关于它的信息。是否可以?
问问题
2337 次
1 回答
2
AIR2 版本的 Galaxy-Tab1 设备在 3 年前测试时运行良好。
请参考我的代码。我可能会工作得很好。相信我。
这里使用的框架是链接。
WAVWriter: WAVWriter
ShineMP3Encoder: ShineMP3Encoder
此代码是骨架,但工作正常。
import com.adobe.audio.format.WAVWriter;
import fr.kikko.lab.ShineMP3Encoder;
import flash.events.SampleDataEvent;
import flash.media.Microphone;
import flash.media.Sound;
import flash.utils.ByteArray;
import flash.events.Event;
var mp3encoder:ShineMP3Encoder;
var microphone:Microphone;
var isRecording:Boolean=false;
var soundRecording:ByteArray;
function startMicRecording():void
{
isRecording=true;
soundRecording = new ByteArray();
microphone=Microphone.getMicrophone();
microphone.rate=44;
microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
}
function stopMicRecording():void {
isRecording=false;
microphone.removeEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
soundRecording.position=0;
convert2MP3();
}
function gotMicData(micData:SampleDataEvent):void
{
soundRecording.writeBytes(micData.data);
}
function convert2MP3():void
{
var wavWrite:WAVWriter = new WAVWriter();
wavWrite.numOfChannels=1;
wavWrite.sampleBitRate=16;
wavWrite.samplingRate=44100;
var wav:ByteArray = new ByteArray();
wavWrite.processSamples(wav, soundRecording, 44100,1);
wav.position=0;
/*
If the process is compressed into mp3 if you have big problems,
just as .wav format save. following code:
var file:FileReference = new FileReference();
file.save(wav,"your_file_name.wav");
*/
mp3encoder=new ShineMP3Encoder(wav);
mp3encoder.addEventListener(Event.COMPLETE, onEncoded);
mp3encoder.start();
}
function onEncoded(e:Event):void
{
mp3encoder.mp3Data.position=0;
mp3encoder.saveAs("your_file_name.mp3");
}
于 2012-08-09T16:05:10.450 回答