加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flash AS3录音回放保存到本地

发布时间:2020-12-15 18:47:31 所属栏目:百科 来源:网络整理
导读:http://www.flash34.com/blog/2735.htm 可以实现录音,回放,还可以把录音保存到本地(wav文件) 主要代码 import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.even

http://www.flash34.com/blog/2735.htm


可以实现录音,回放,还可以把录音保存到本地(wav文件)
主要代码
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 { ?// }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读