基于android系统的音乐播放器设计与实现_含源程序(编辑修改稿)内容摘要:

3info = (mp3info)。 String img = (img)。 dosomething(mp3info,img)。 (duration)。 ((int) currPos)。 (getTimeStr(currPos,false) + / + getTimeStr((long)duration,false))。 } else if (uiCmd==){ int duration=(duration, 0)。 (duration)。 (00:00/ + getTimeStr((long)duration,false))。 } else if (uiCmd==){ ()。 (0)。 } } } //捕捉和识别触屏事件 @Override public boolean onTouchEvent(MotionEvent event) { switch(()){ case : downX = ()。 downY = ()。 downT = ()。 break。 case : break。 基于 Android 系统的音乐播放器设计与实现 14 case : upX = ()。 upY = ()。 upT = ()。 break。 } relateX = downX upX。 relateY = downY upY。 //一次点击事件完成 if(upT 0){ //是一次点击事件 if((relateX) = CLICK_POINTOR amp。 amp。 (relateY) = CLICK_POINTOR){ //点击超过一秒,定义为长触屏事件 if(upT downT 500){ Intent intent = new Intent()。 (, )。 startActivity(intent)。 } else{ ()。 t = new Thread(tr)。 ()。 } } else if((relateX) (relateY)){ if(downX upX){ nextMusic()。 } else if(downX upX){ lastMusic()。 } } else if((relateX) (relateY)){ if(downY upY){ turnvol()。 } else if(downY upY){ 基于 Android 系统的音乐播放器设计与实现 15 turnvol()。 } } upT = 1。 //upX = upY = 0。 } return (event)。 } //代码复用,关于音量调节 public void turnvol(int value){ (, value,0)。 CurVolume = ()。 int num_pic = (7*CurVolume)/SysMaxVolume。 (vol_id[num_pic])。 ()。 Thread thread = new Thread(tv)。 ()。 } /** * 音量条延迟线程 */ Handler vhandler = new Handler()。 Runnable tv = new Runnable(){ @Override public void run() { try { (1000)。 } catch (InterruptedException e) { ()。 } (vr)。 } }。 Runnable vr = new Runnable(){ @Override 基于 Android 系统的音乐播放器设计与实现 16 public void run() { ()。 } }。 /** * 进 度条等按钮延迟线程 */ Handler handler = new Handler()。 Runnable tr = new Runnable(){ @Override public void run() { try { (5000)。 } catch (InterruptedException e) { ()。 } (r)。 } }。 Runnable r = new Runnable() { @Override public void run() { ()。 } }。 } package。 import。 import。 import。 import。 import。 基于 Android 系统的音乐播放器设计与实现 17 import。 import。 import。 public class ListSrv extends Service implements AppConstant{ private FileUtils files。 private Intent intentplay = null。 private MpsIterm mp3_next = null。 private MpsIterm mp3_last = null。 private int cmd =。 private int mode =。 private int position = 1。 private int nextp = 0。 private int lastp = 0。 private ArrayListMpsIterm list = null。 @Override public IBinder onBind(Intent intent) { // TODO Autogenerated method stub return null。 } @Override public void onDestroy() { // TODO Autogenerated method stub ()。 } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Autogenerated method stub cmd = (cmd, )。 switch(cmd){ case : files = new FileUtils()。 list = (ArrayListMpsIterm)(mp3)。 mode = (mode, )。 //(+ mode)。 position = (position, position)。 initPlayerSrv()。 (mp3, (position))。 startService(intentplay)。 whatsnext(mode,position)。 基于 Android 系统的音乐播放器设计与实现 18 break。 case : if(position 0)return 0。 initPlayerSrv()。 (mp3, mp3_next)。 startService(intentplay)。 position = nextp。 whatsnext(mode,position)。 break。 case : if(position 0)return 0。 initPlayerSrv()。 (mp3, mp3_last)。 startService(intentplay)。 position = lastp。 whatsnext(mode,position)。 break。 } return (intent, flags, startId)。 } public void whatsnext(int mode , int position){ if(list == null)return。 switch(mode){ case : lastp = nextp = position。 mp3_next = (nextp)。 mp3_last = (lastp)。 break。 case : //( + ())。 nextp = position + 1。 lastp = position 1。 if( nextp () 1 )nextp = 0。 if( lastp 0 )lastp = () 1。 mp3_next = (nextp)。 mp3_last = (lastp)。 break。 case : Random r = new Random()。 lastp = nextp = (())。 mp3_next = (nextp)。 基于 Android 系统的音乐播放器设计与实现 19 mp3_last = (lastp)。 break。 } } public void initPlayerSrv(){ intentplay = new Intent()。 (, )。 (mediaCmd, )。 } /*public void noteonActivity(MpsIterm mp3){ Intent intentact = new Intent()。 (mp3, mp3)。 (, )。 sendBroadcast(intentact)。 }*/ } package。 import。 import。 import。 import。 import。 import。 import。 import。 import。 import。 import。 import。 import。 public class PlayerSrv extends Service implements AppConstant{ private MpsIterm mp3=null。 private MediaPlayer mp=null。 private int mediaStatus=。 private int mediaCmd=。 private String [] arrMessages = null。 private long [] arrTimes = null。 private UpdateTimeCallback updateTimeCallback=null。 private Handler handler=null。 基于 Android 系统的音乐播放器设计与实现 20 private String message=null。 private int startTime=0。 private int currLrcIndex=0。 private String mp3info。 private String img。 @Override public IBinder onBind(Intent arg0) { // TODO Autogenerated method stub return null。 } //在 Mp3PlayerActivity 中的停止按钮的监听类中进行停止。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。