2016-10-13 00:16:48 点击量:8 标签: 收藏本文
[AS3]as3的运用Sound类实现播放/暂停/停止mp3音乐播放器
- //number that is redefined when the pause button is hit
- var pausePoint:Number = 0.00;
- //a true or false value that is used to check whether the sound is currently playing
- var isPlaying:Boolean;
- //think of the soundchannel as a speaker system and the sound as an mp3 player
- var soundChannel:SoundChannel = new SoundChannel();
- var sound:Sound = new Sound(new URLRequest("CuPLayer_com/cuplayer.mp3"));
- //your stop button and play/pause buttons
- xstop.addEventListener(MouseEvent.CLICK, clickStop);
- xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);
- soundsoundChannel = sound.play();
- isPlaying = true;
- function clickPlayPause(evt:MouseEvent) {
- if (isPlaying) {
- pausePoint = soundChannel.position;
- soundChannel.stop();
- isPlaying = false;
- } else {
- soundsoundChannel = sound.play(pausePoint);
- isPlaying = true;
- }
- }
- function clickStop(evt:MouseEvent) {
- if (isPlaying) {
- soundChannel.stop();
- isPlaying = false;
- }
- pausePoint = 0.00;
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室