<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init();"> <s:layout> <s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/> </s:layout> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ import flash.events.Event; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.net.URLRequest; import flash.xml.*; private var _xmlDoc:String; private var _xmlObj:XML; private var _soundObj:Sound; private var _soundTransform:SoundTransform; private var _soundChannel:SoundChannel; private var _currentArrayNum:int; private var _currentSndPosition:Number; private var _isPlayingSound:Boolean; //helps you keep track of if the song is playing or not. private function init():void { _xmlDoc = '<?xml version="1.0" encoding="utf-8"?><mp3><songURL>I Need You Come Back.mp3</songURL>' + '<songURL>Boom Boom Pow.mp3</songURL></mp3>'; _xmlObj = new XML(_xmlDoc); trace(_xmlObj..songURL); trace(_xmlObj..songURL[0]); //if there were more "songURL" tags then you could treat this like like an array. the first song being in position 0 _currentArrayNum = 0; //this var helps keep track of where you are in the array when you click next or previous. _soundObj = new Sound(); _soundObj.load(new URLRequest(_xmlObj..songURL[_currentArrayNum])); _soundChannel = new SoundChannel(); _soundTransform = new SoundTransform(); VSlider.snapInterval =.1; VSlider.addEventListener(Event.CHANGE, ChangeVolume); } private function playSound():void { _soundChannel = _soundObj.play(); _isPlayingSound = true; _soundTransform.volume = .5; _soundChannel.soundTransform = _soundTransform; } private function pauseSound():void { if(_isPlayingSound == true){ //保存播放的点 _currentSndPosition = _soundChannel.position; trace("_currentSndPosition = " + _currentSndPosition); _isPlayingSound = false; _soundChannel.stop(); }else{ //从上次断点开始播放 _soundChannel = _soundObj.play(_currentSndPosition); _isPlayingSound = true; trace("_currentSndPosition = " + _currentSndPosition); } } //if your var's value is not yet the equal fo the highest number in your songURL array. then add 1 and load the next //the opposite is true going backwards private function nextSound():void { trace(_currentArrayNum+" "+_xmlObj..songURL.length()) ; if(_currentArrayNum != _xmlObj..songURL.length()){ _currentArrayNum ++; _soundObj.load(new URLRequest(_xmlObj.songURL[_currentArrayNum])); playSound(); } } private function prevSound():void { if(_currentArrayNum !=0){ _currentArrayNum --; _soundObj.load(new URLRequest(_xmlObj..songURL[_currentArrayNum])); playSound(); } } //the slider has a min value of 0 and a max value of 1 and will snap to each position in between (.1) //what ever that number is in between 0 and 1 is the new volume private function ChangeVolume(evt:Event):void{ _soundTransform.volume = evt.target.value; _soundChannel.soundTransform = _soundTransform; trace(evt.target.value); } ]]> </fx:Script> <s:Label text="MP3播放器" /> <s:HGroup> <s:Button label="Play" click="playSound();"/> <s:Button label="Pause" click="pauseSound();"/> <s:Button label="Next" click="nextSound();"/> <s:Button label="Previous" click="prevSound()"/> <s:HSlider id="VSlider" minimum="0" maximum="1" /> </s:HGroup> </s:Application>
发表评论
-
全面认识Flex六大要素
2011-05-08 12:56 805在学习Flex应用程序的 ... -
Flex4之将Sprite控件添加到FLEX UI中
2011-05-08 12:54 1347在Flex的帮助文档里,有很多例子都是扩展Sprite类的。如 ... -
Flex4之元数据标签详解
2011-05-07 23:57 1277Flex 元数据标签 1、[ArrayElementT ... -
Flex4之关于Embed外部资源的使用方法
2011-05-07 20:56 1005Flex软件中经常需要 ... -
Flex之使用ActionScript构造组件
2011-05-07 20:04 900因为是专门针对ActionScript来写的篇章,所以,对于A ... -
Flex获取RGB的值,R、G、B
2011-05-06 20:35 968<?xml version="1.0" ... -
Flex自制简单菜单
2011-05-06 20:22 942<?xml version="1.0" ... -
Flex4之为ToolTip设置旋转特效及字体
2011-05-05 21:04 1734<?xml version="1.0" ... -
Flex的Alert中加入超链接
2011-05-05 20:57 1180<?xml version="1.0" ... -
FLEX4之内存释放优化原则
2011-05-05 13:28 6581. 被删除对象在外部的所有引用一定要被删除干净才能被系统 ... -
Flex4之DataGrid示例【客户端和服务器端]
2011-05-03 19:27 1667由于我的DataGrid与JAVA后 ... -
Flex4表单验证
2011-05-01 22:34 1981这里主要讲Combox的验证。其他几个略带说说。 ... -
Flex4之与后台服务器通信方式:URLRequest+URLLoader【JAVA方式】
2011-04-21 20:16 1862URLRequest是ActionScript和服务端通信的最 ... -
Flex4 事件详解
2011-04-17 16:10 955第一、Flex事件简介 ... -
向Tree空间添加删除XML数据节点_Flex4
2011-03-31 20:50 2046Flex4控件例程: 基于Http ...
相关推荐
FLEX播放器 flex 开发AIR及Flex之mp3播放器教程 FLEX播放器 flex 开发AIR及Flex之mp3播放器教程
自己写的一个MP3 用FLEX写的 比较简易的
flex MP3播放器,具有歌词同步、波形显示。 本人花了3天时间做的,供大家参考。
Flex 超炫 MP3播放器 Flex 超炫 MP3播放器 Flex 超炫 MP3播放器
flex 简易计算器flex 简易计算器flex 简易计算器flex 简易计算器
一款不错flex制作的MP3播放器,适合下载学习使用
使用flex builder 进行开发的一个简简单单的播放器。
运用flashbuilder4.0制作的简易Mp3播放器!
NULL 博文链接:https://zhongrenmeng.iteye.com/blog/1454995
一个Flex Air的播放器,可以修改为在线播放器。
flex+PHP mp3音乐播放器,播放器地址分享功能,mp3下载让您随时随地分享音乐
flex编写mp3播放器,适合于刚开始学习flex的学者,更深一层的学习.
flex 和 flash cs5集合的mp3播放器
NULL 博文链接:https://wptc.iteye.com/blog/586754
flex漂亮MP3播放器源码,结合flash、CSS等制作精美皮肤…… 具有一般的mp3播放、声音调节、进度条、3种频谱显示方式,内带flash素材源文件…… Drag.as通用拖动源代码…… Visualization Explorer……
直接上代码,在Flash Builder 4中新建 FLEX项目,复制代码可以可以直接运行 需要将 file = "D:\\voice\\3791.MP3"; 改为自己的路径 以后还准备增加流式播放!
自己做的flex AIR MP3 播放器 实现了一般的功能,歌曲列表、波形图、添加本地歌曲列表(分为选择文件夹和多选文件) 、添加网络歌曲 、歌曲顺序播放
这只是个实现小小功能的mp3播放器: 播放进度、声道调节、音量调节、播放列表、播放、暂停、停止 播放列表里的歌曲是网上的资源,有一定的时效性,可能会不能正常播放.
Flex在线MP3媒体播放器功能如下: 1.播放音乐时显示波形谱 2.歌词同步显示 3.播放模式调节(顺序播放、单曲循环、随机播放) 4.播放歌曲时显示进度条 5.快进 6.快退 7.声量调节 8.歌曲列表 9.播放控制(上一首、下一首...
一款用flex做的音乐播放器,对于flex学习者很有用