mp3播放器组件
作者 佚名技术
来源 服务器技术
浏览
发布时间 2012-07-12
ddB.onPress=function():Void { dealVolum(1); } this.vaddB.onRelease=function():Void { dealVolumOver(); } this.vaddB.onReleaseOutside=function():Void { dealVolumOver(); } //减 this.vdelB.onPress=function():Void { dealVolum(-1); } this.vdelB.onRelease=function():Void { dealVolumOver(); } this.vdelB.onReleaseOutside=function():Void { dealVolumOver(); } function dealVolum(ntype:Number):Void { volType=ntype; delete ntype; this.vbar.onEnterFrame=function():Void { volGet(); } } function volGet():Void { volNum=volNum+volType*stepCon; if(volNum<0) volNum=0; if(volNum>100) volNum=100; setMpVolume(volNum,0); this.vbar.stock._x=volNum/100*146; } function dealVolumOver():Void { delete this.vbar.onEnterFrame; } ////////////////////////////////////////// //音量平衡度调整函数/////// function setMpVolume(nvtNum:Number,ntype:Number):Void { if(ntype==0) { nSound.setVolume(nvtNum); } else if(ntype==1) { nSound.setPan(nvtNum); } delete nvtNum; delete ntype; } ///////////////歌曲控制按钮动作/////////////////////// this.playB.onPress=function() { if(this._parent.songUrl!="") { songPlay(); } else { if(this._parent.listLen>0) loadSong(0); } }; this.pauseB.onPress=function() { songPause(); }; this.preB.onPress=function() { changeSongPos(-1); }; this.nextB.onPress=function() { changeSongPos(1); }; function changeSongPos(ntype:Number):Void { if(listLen>0) { delete this.onEnterFrame; nSound.stop(); if(ntype==1) { //下一首 listNo=listNo else { //上一首 listNo=listNo>0?listNo-1:listLen-1; } loadSong(listNo); } } function songPause():Void { if(songUrl!="") { if(checkPause==0) { delete this.onEnterFrame; checkPause=1; curTime=nSound.position; nSound.stop(); //trace("pause"+curTime); } else { //trace("play"+curTime) checkPause=0; nSound.start(Math.round(curTime/1000-0.5)); this.onEnterFrame=function() { showProBar(); } } } } //////读取歌曲信息///////////// function scanSong():Void { var infoStr,artStr,disStr,songStr:String; artStr=disStr=songStr=""; infoStr=" [总时间 "+timeToString(timeSum,1)+""; songStr=toUTF(nSound.id3.TIT2); artStr=toUTF(nSound.id3.TPE1); disStr=toUTF(nSound.id3.TALB); if(songStr=="") songStr=songUrl; if(artStr=="") artStr="佚名艺术家"; if(disStr=="") disStr="佚名唱片"; infoStr=infoStr+"--"+songStr+"--"+artStr+"--"+disStr+"]"; songInfo=infoStr; delete infoStr; delete artStr; delete disStr; delete songStr; this.onEnterFrame=function() { showProBar(); } } function showProBar():Void { var perNum:Number; curTime=nSound.position; curTimeStr=timeToString(curTime,0); //当前播放百分比 perNum=Math.round(curTime/timeSum*100-0.5); this.perBar.stock._x=534*perNum/100; delete perNum; } /////////计时函数/////////////////////// function timeToString(ntime:Number,ntype:Number):String { var m1,m2,m3,m4,m5,m6,m7,ntime1:Number; var returnStr:String; ntime1=Math.round(ntime/1000-0.5); m1=Math.round |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 动画基础:动画的灵魂-动作下一篇: 永不重合的小球,简单的Action
关于mp3播放器组件的所有评论