已注销用户2014-05-24 12:23:20
Flex开发实例教程-Mp3播放器代码demo分享
本例中的MP3播放器是用Flex做的,主要是ActionScript和MXML。主要的功能有 播放,暂停,音量控制,播放进度显示。好了先给大家看看界面吧!如下:
总体的设计还是用了PureMVC框架。项目目录:
这里简单的说说几个功能点吧!
1.播放进度
显示歌曲播放的进度可以使用Flex中 提供的ProgressBar控件,这个控件可以事实的去显示歌曲进行的任务完成的情况!代码如下:
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" height="30"> <mx:ProgressBar id="progressBar" left="10" top="10" label="" mode="manual"/> </mx:Canvas>
2.歌曲列表
在Flex 里面提供了List,DataGrid等数据控件。本例中就三个字段 我们可以选择DataGrid控件来显示歌曲列表。在该控件里面可以使用DataGridColumn来自定义列的标题,宽度,显示内容,本例中的歌曲列表代码如下:
<mx:DataGrid id="songDataGrid" dataProvider="{songs}" width="200" height="150" left="10" click="if (songDataGrid.selectedIndex != -1) sendEvent(SELECT)"> <mx:columns> <mx:DataGridColumn dataField="songName" headerText="歌曲"/> <mx:DataGridColumn dataField="songArtist" headerText="歌手"/> <mx:DataGridColumn dataField="songDuring" headerText="时间"/> </mx:columns> </mx:DataGrid>
3.播放
播放功能是播放器程序里面最核心的应用,当我们点击播放的时候,系统会相应去调用事件函数。如下:
<?xml version="1.0" encoding="utf-8"?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" height="30" horizontalAlign="center"> <mx:Script> <![CDATA[ public static const PLAY:String = "play";//播放 静态变量 private function controlHandle(note:String):void { dispatchEvent(new Event(note));// 派发 事件 } ]]> </mx:Script> <mx:Image id="btnPlay" source="@Embed(source='/assets/play.png')" buttonMode="true" click="controlHandle(PLAY)"/> </mx:HBox>
暂停控制,停止控制,音量调节等我就不继续详细介绍了!
说明:有需要的牛牛们可以下载下来看看,有bug可以一起解决,因为我也是因为兴趣 学习没几天,Flex方面的大牛请勿笑喷!
由最代码官方编辑于2016-9-1 9:55:27
猜你喜欢
请下载代码后再发表评论
文件名:MP3Player.rar,文件大小:12997.946K下载
- /
- /MP3Player
- /MP3Player/.actionScriptProperties
- /MP3Player/.flexProperties
- /MP3Player/.project
- /MP3Player/.settings
- /MP3Player/.settings/org.eclipse.core.resources.prefs
- /MP3Player/bin-debug
- /MP3Player/bin-debug/AC_OETags.js
- /MP3Player/bin-debug/assets
- /MP3Player/bin-debug/assets/next.png
- /MP3Player/bin-debug/assets/pause.png
- /MP3Player/bin-debug/assets/play.png
- /MP3Player/bin-debug/assets/previous.png
- /MP3Player/bin-debug/assets/stop.png
- /MP3Player


Echo123abc LV62020年12月20日
litiansoft LV22019年9月1日
FWG201018 LV22019年6月19日
最代码故戌 LV202019年4月17日
fenting LV12018年3月23日
君知否 LV172017年11月14日
敏哥gege LV432017年8月12日
ok-wap LV192016年12月22日
smmvssss2016 LV12016年1月26日
小码农@猪猪猪 LV122015年10月20日

暂无贡献等级
18781170695 LV62020年12月29日
Echo123abc LV62020年12月19日
yangctz LV242020年11月17日
denyihao LV12020年11月1日
16434543032020年7月18日
暂无贡献等级
13336135399 LV12020年6月11日
落夏yyyy LV22020年5月24日
jiqingxings LV42020年3月10日
乔纳森小磊老师 LV22020年3月4日