[AS3]as3基于as3wavsound做的一款录音机源代码
4个按钮 一个文本框
两个类包
as3wavsound
micrecorder
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.Microphone;
import org.as3wavsound.WavSound;
import org.bytearray.micrecorder.MicRecorder;
import org.bytearray.micrecorder.encoder.WaveEncoder;
import org.bytearray.micrecorder.events.RecordingEvent;
import flash.display.MovieClip;
var recorder:MicRecorder = new MicRecorder( new WaveEncoder() );
var player:WavSound;
var _file:FileReference = new FileReference();
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
recorder.addEventListener(RecordingEvent.RECORDING, onRecording);
recorder.addEventListener(Event.COMPLETE, onRecordComplete);
bt2.visible = false;
bt3.visible = false;
bt4.visible = false;
bt1.addEventListener(MouseEvent.CLICK, bt1_ck);
function bt1_ck(event:MouseEvent):void
{
txtMsg.text = "正在录音";
recorder.record();
bt1.visible = false;
bt2.visible = true;
bt3.visible = false;
}
bt2.addEventListener(MouseEvent.CLICK, bt2_ck);
function bt2_ck(event:MouseEvent):void
{
txtMsg.text = "录制完成,可以播放";
//recorder.record();
recorder.stop();
bt1.visible = true;
bt2.visible = false;
bt3.visible = true;
bt4.visible = true;
}
bt3.addEventListener(MouseEvent.CLICK, bt3_ck);
function bt3_ck(event:MouseEvent):void
{
txtMsg.text = "正在播放";
player = new WavSound(recorder.output);
player.play();
bt1.visible = true;
bt2.visible = true;
bt3.visible = true;
}
bt4.addEventListener(MouseEvent.CLICK,bt4_ck);
function bt4_ck(event:MouseEvent):void
{
_file.save( recorder.output, "recorded.wav" );
}
function onRecording(event:RecordingEvent):void
{
//_display.text = "Recording since : " + event.time + " ms.";
}
function onRecordComplete(event:Event):void
{
//
}
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例