在我使用 flash cs6、as3 的项目中,我成功地使用 waveEncoder 类从麦克风编码字节数组并将其上传到服务器端需要帮助来编码 mp3 文件,当我尝试在 flash 中播放它时,这是我的代码
import org.bytearray.micrecorder.encoder.WaveEncoder;
var enco:WaveEncoder=new WaveEncoder();
function upload_s(user_name:String,user_id:String)
{
var SERVICE_PATH:String = "http://myserver.php";
var o:ByteArray=enco.encode(soundO3,1)
var soundFileName=user_name+user_id+".mp3"
var loaderjp:URLLoader = new URLLoader();
var url:String = SERVICE_PATH + "?name=" + soundFileName;
var req:URLRequest = new URLRequest(url);
// make sure the server knows it is getting an image
req.requestHeaders = new Array(new URLRequestHeader("Content-Type", "audio/mp3"));
loaderjp.dataFormat = URLLoaderDataFormat.BINARY;
req.contentType ="audio/mp3";
req.method = URLRequestMethod.POST;
req.data = o;
// send the file
loaderjp.load(req);
}
谢谢