2016-10-13 00:16:48 点击量:14 标签: 收藏本文
[AS3]as3加载外部mp3制作mp3音乐播放器源代码实例
- var SoundState:Boolean;
- var sndChannel:SoundChannel;
- var snd:Sound = new Sound();
- snd.addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
- snd.addEventListener(Event.COMPLETE, CompleteHandler);
- snd.load(new URLRequest("showroom.mp3"));
- var outputText:TextField=new TextField();
- outputText.width = 500;
- outputText.height = 20;
- addChild(outputText);
- //cuplayer.com提示,加载进度
- function ProgressHandler(e:ProgressEvent):void {
- outputText.text = "Loading: " + Math.round(100 * e.bytesLoaded / e.bytesTotal);
- trace("Loading: " + Math.round(100 * e.bytesLoaded / e.bytesTotal));
- }
- function CompleteHandler(e:Event):void {
- outputText.text = "Sound loaded - click the stage to play and stop";
- snd.removeEventListener(ProgressEvent.PROGRESS, ProgressHandler);
- snd.removeEventListener(Event.COMPLETE, CompleteHandler);
- stage.addEventListener(MouseEvent.CLICK, clickHandler);
- }
- //cuplayer.com提示,暂停、播放动作
- function clickHandler(e:Event):void {
- SoundState=!SoundState;
- trace(SoundState);
- if (SoundState) {
- outputText.text ="PLAY";
- sndsndChannel=snd.play(pausePosition);
- } else {
- var pausePosition:int = sndChannel.position;
- outputText.text ="PAUSE";
- sndsndChannel=snd.play(pausePosition);
- }
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室