[AS3]as3加载外部mp3制作mp3音乐播放器源代码实例
[AS3]as3加载外部mp3制作mp3音乐播放器源代码实例
[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);
- }
- }
热门文章推荐
- [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示例
请稍候...