概述
paraB.timer) {
return 1;
}
if (paraA.timerplayList.song.length() - 1)
{
currentSound = 1;
}
playList_cb.selectedIndex = currentSound;
loadSound(playList.song[currentSound].@data);
loadLrc(lrcList.lrc[currentSound].@data);
}
7.音量控制
volumeDegrees = volumeSlider_mc.volumeKnob_mc.x;//初始化
volumeSlider_mc.volumeKnob_mc.visible = true;
volumeSlider_mc.volumeKnob_mc.addEventListener(MouseEvent.MOUSE_DOWN, volumeKnobStartDrag);
function volumeKnobStartDrag(evt:MouseEvent):void
{
rec = new Rectangle(volumeSlider_mc.spanning_mc.x, volumeSlider_mc.volumeBar_mc.y, volumeSlider_mc.spanning_mc.width + 1, 0);
volumeSlider_mc.volumeKnob_mc.startDrag(false, rec);
stage.addEventListener(MouseEvent.MOUSE_MOVE, volumeAdjust);
stage.addEventListener(MouseEvent.MOUSE_UP, volumeKnobStopDrag);
}
function volumeKnobStopDrag(evt:MouseEvent):void
{
volumeSlider_mc.volumeKnob_mc.stopDrag();
if(volumeSlider_mc.volumeKnob_mc.x != 0)
{
volumeDegrees = volumeSlider_mc.volumeKnob_mc.x;
}
stage.removeEventListener(MouseEvent.MOUSE_UP, volumeKnobStopDrag);
volumeSlider_mc.volumeKnob_mc.removeEventListener(MouseEvent.MOUSE_MOVE, volumeAdjust);
}
function volumeAdjust(evt:MouseEvent = null):void
{
volumeSlider_mc.volumeBar_mc.width = volumeSlider_mc.volumeKnob_mc.x;
if(volumeSlider_mc.volumeKnob_mc.x == 0)
{
volumeIcon_mc.gotoAndStop("mute");
}
else
{
volumeIcon_mc.gotoAndStop("unmute");
//volumeDegrees = volumeSlider_mc.volumeKnob_mc.x;
}
if (soundControl != null)
{
xform = soundControl.soundTransform;
xform.volume = volumeSlider_mc.volumeKnob_mc.x / volumeSlider_mc.spanning_mc.width;
soundControl.soundTransform = xform;
}
}
volumeIcon_mc.visible = true;
volumeIcon_mc.addEventListener(MouseEvent.CLICK, switchVolumeStatus);
function switchVolumeStatus(evt:MouseEvent):void
{
if(volumeIcon_mc.currentLabel == "unmute")
{
volumeDegrees = volumeSlider_mc.volumeKnob_mc.x;
volumeSlider_mc.volumeKnob_mc.x = 0;
volumeAdjust();
volumeIcon_mc.gotoAndStop("mute");
}
else
{
volumeSlider_mc.volumeKnob_mc.x = volumeDegrees;
volumeAdjust();
volumeIcon_mc.gotoAndStop("unmute");
}
}
8.进度控制
//进度条控制
progKnob_mc.visible = true;
function progKnobUpdate(evt:Event):void
{
songtime_txt.text=getTimeFmt(soundControl.position);
songlenght_txt.text=getTimeFmt(sound.length);
var pos:Number = (progBar_mc.width - progKnob_mc.width) * soundControl.position / sound.length;
if(!isNaN(pos))
{
progKnob_mc.x = progBar_mc.x + pos;
}
else
{
progKnob_mc.x = progBar_mc.x;
}
}
progKnob_mc.addEventListener(MouseEvent.MOUSE_DOWN, progKnobStartDrag);
function progKnobStartDrag(evt:MouseEvent):void
{
if(sound != null)
{
pauseSound();
rec = new Rectangle(progBar_mc.x, progBar_mc.y, progBar_mc.width - progKnob_mc.width, 0);
progKnob_mc.startDrag(false, rec);
stage.addEventListener(MouseEvent.MOUSE_UP, progKnobStopDrag);
}
}
function progKnobStopDrag(evt:MouseEvent):void
{
progKnob_mc.stopDrag();
var pos:Number = sound.length * (progKnob_mc.x - progBar_mc.x) / (progBar_mc.width - progKnob_mc.width);
playSound(pos);
stage.removeEventListener(MouseEvent.MOUSE_UP, progKnobStopDrag);
}
9.频谱算法
//视觉化音频
var ba:ByteArray = new ByteArray();
var gr:Sprite = new Sprite();
gr.x = 88;
gr.y = 285;
addChild(gr);
var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER,timerHandler);
time.start();
function soundCompleteHandler(evt:Event):void
{
time.stop();
}
function timerHandler(evt:TimerEvent):void
{
SoundMixer.computeSpectrum(ba,true);
var i:int;
gr.graphics.clear();
gr.graphics.lineStyle(0, 0x341ed8);
gr.graphics.beginFill(0x341ed8);
gr.graphics.moveTo(0, 0);
var w:uint = 2;
for (i = 0; i < 126; i += w)
{
var t:Number = ba.readFloat();
var n:Number = (t * 25);
gr.graphics.drawRect(i * 1.43, 0, w*.5, -n);
}
}
10.时间算法
function getTimeFmt(ms:Number):String{
var s:int=int(ms/1000);
var m:int=int(s/60);
s-=m*60;
var h:int;
h=int(m/60);
m-=h*60;
return make2Str(m)+":"+make2Str(s);
}
function make2Str(i:int):String{
if(i<10) return "0"+i;
else return ""+i;
}
四、 参考资料
Adoble Flash cs4 Actioanscript3.0经典教程 人民邮电出版社
ActionScript3.0 开发技术大全 清华大学出版社
最后
以上就是积极雨为你收集整理的android音乐播放器课程设计报告,基于AS3.0的音乐播放器设计课程设计报告.doc的全部内容,希望文章能够帮你解决android音乐播放器课程设计报告,基于AS3.0的音乐播放器设计课程设计报告.doc所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复