AS3 audiioencoder转换为音频 [英] AS3 audiioencoder to convert to audio

查看:432
本文介绍了AS3 audiioencoder转换为音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在操作脚本如何转换使用音频编码器从麦克风录制的字节数组到MP3

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

如何使用音频编码器将recordingData保存到mp3

解决方案

你会发现自己有一个在Flash播放器中运行的MP3编码库。一个简单的谷歌搜索发现闪耀是相当受欢迎的。另一个选择是将音频流式传输到服务器并在那里进行编码。

根据您的环境,您可以使用 LAME ,如果你在Air,并且愿意构建本地扩展来编码。



如果您使用Shine,我发现一个项目中的例子,这意味着编码很简单:

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


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

解决方案

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

这篇关于AS3 audiioencoder转换为音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆