android音乐播放器课程设计报告,基于AS3.0的音乐播放器设计课程设计报告.doc

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 开发技术大全 清华大学出版社

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值