博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
博客中 Flex4/Flash mp3音乐播放器实例 含演示地址
阅读量:2222 次
发布时间:2019-05-08

本文共 10612 字,大约阅读时间需要 35 分钟。

要求

    • 必备知识

      本文要求基本了解 Adobe Flex编程知识和JAVA基础知识。

    • 开发环境

      MyEclipse10/Flash Builder4.6/Flash Player11及以上

    • 演示地址

 

播放器演示已经在博客banner部分给出了,下面还是上一截图吧:

 

下面是程序的核心业务代码:

//此状态为 暂停后点击播放按钮 状态 currentMusicChannel = currentMusicSound.play(currentMusicPosition); } isplaying=true; }else{ //暂停 //此状态为 播放过程中点击 暂停按钮 状态 currentMusicPosition = currentMusicChannel.position;//记录暂停位置 currentMusicChannel.stop();//暂停 isplaying=false; } //currentMusicChannel.addEventListener(Event.SOUND_COMPLETE,autoPlayNext);//自动播放下一首 } /** * 自动播放下一首 和 next按钮采用同样的方式吧 * @param event * */ protected function autoPlayNext(event:Event):void{
//过滤参数问题 getMusicItem(); if(currentMusicSound!=null&¤tMusicChannel!=null){ currentMusicChannel.stop();//暂停 } clearPar(); currentMusicUrlString=musicItem.uri; currentMusicUrlRequest =new URLRequest(currentMusicUrlString); currentMusicSound = new Sound(); currentMusicSound.load(currentMusicUrlRequest); currentMusicSound.addEventListener(Event.COMPLETE,load_CompleteHandler); playAndPause.selected=true; isplaying =true; currentMusicChannel = currentMusicSound.play();//开始播放 timer_GetCurrentPositionHandler();//同步更新已经播放的时间的计时器 currentMusicChannel.addEventListener(Event.SOUND_COMPLETE,autoPlayNext);//自动播放下一首 } /** * 正在播放的歌曲的总时长 */ private var len:int; /** * 文件加载完成 能读取到音乐的总时长 * @param event * */ protected function load_CompleteHandler(event:Event):void{ len = currentMusicSound.length; } /** * 同步更新已经播放的时间的计时器 * */ protected function timer_GetCurrentPositionHandler():void{ var clock:Timer = new Timer(100,int(len/1000/60*10));//每0.1秒更新一次 clock.start(); clock.addEventListener(TimerEvent.TIMER,showTime); } /** * 显示已经播放的总时间 * @param event * */ protected function showTime(event:Event):void{ playingProcess.maximum = int(len/1000)*10;//最大值 playingProcess.value = int(currentMusicPosition/1000*10); //当前值 currentMusicPosition = currentMusicChannel.position; } /** * 播放进度条 可以拖动 * @param event * */ protected function playingProcess_changeHandler(event:Event):void{ if(currentMusicChannel!=null){ currentMusicPosition = playingProcess.value*1000/10;//当前音乐播放进度 currentMusicChannel.stop(); currentMusicChannel = currentMusicSound.play(currentMusicPosition); isplaying=true; playAndPause.selected=true; currentMusicChannel.addEventListener(Event.SOUND_COMPLETE,autoPlayNext);//自动播放下一首 }else{ playingProcess.value=0; } } /** * 清除参数 * currentMusicSound = null; * currentMusicChannel = null; * currentMusicPosition = 0; * */ private function clearPar():void{ currentMusicSound = null; currentMusicChannel = null; currentMusicPosition = 0; } ]]>
作者:
出处:
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

转载于:https://www.cnblogs.com/Li-Cheng/p/3598324.html

你可能感兴趣的文章
Intellij IDEA使用(三)——在Intellij IDEA中配置Tomcat服务器
查看>>
Intellij IDEA使用(四)—— 使用Intellij IDEA创建静态的web(HTML)项目
查看>>
Intellij IDEA使用(五)—— Intellij IDEA在使用中的一些其他常用功能或常用配置收集
查看>>
Intellij IDEA使用(六)—— 使用Intellij IDEA创建Java项目并配置jar包
查看>>
Eclipse使用(十)—— 使用Eclipse创建简单的Maven Java项目
查看>>
Eclipse使用(十一)—— 使用Eclipse创建简单的Maven JavaWeb项目
查看>>
Intellij IDEA使用(十三)—— 在Intellij IDEA中配置Maven
查看>>
面试题 —— 关于main方法的十个面试题
查看>>
集成测试(一)—— 使用PHP页面请求Spring项目的Java接口数据
查看>>
使用Maven构建的简单的单模块SSM项目
查看>>
Intellij IDEA使用(十四)—— 在IDEA中创建包(package)的问题
查看>>
FastDFS集群架构配置搭建(转载)
查看>>
HTM+CSS实现立方体图片旋转展示效果
查看>>
FFmpeg 命令操作音视频
查看>>
问题:Opencv(3.1.0/3.4)找不到 /opencv2/gpu/gpu.hpp 问题
查看>>
目的:使用CUDA环境变量CUDA_VISIBLE_DEVICES来限定CUDA程序所能使用的GPU设备
查看>>
问题:Mysql中字段类型为text的值, java使用selectByExample查询为null
查看>>
程序员--学习之路--技巧
查看>>
解决问题之 MySQL慢查询日志设置
查看>>
contOS6 部署 lnmp、FTP、composer、ThinkPHP5、docker详细步骤
查看>>