1600802093
一、实现的界面(图1:播放界面。图2:播放列表)
图1:播放界面 图2:播放列表
二、可以播放多个音乐,如上图所示49首(自己手机里的sdcard音乐)
三、关键代码:(播放、暂停、停止、上一曲、下一曲)
public void onClick(View v) { switch (v.getId()) { case R.id.bt_choose: chooseMusic(); bt_pre.setEnabled(true); bt_next.setEnabled(true); break; case R.id.bt_playOrpause: String path = et_path.getText().toString().trim(); if (TextUtils.isEmpty(path)) { Toast.makeText(this, "路径不能为空", Toast.LENGTH_SHORT).show(); return; } if (isPlaying) { myBinder.callpause(); bt_play.setText("播放"); } else { myBinder.callplay(path); bt_play.setText("暂停"); } isPlaying = !isPlaying; break; case R.id.bt_stop: // 停止 myBinder.callstop(); bt_play.setText("播放"); isPlaying = false; break; case R.id.bt_pre: // 上一曲 myBinder.callstop(); position--; if (position < 0) { position = MyApplication.list.size() - 1; } String prepath = MyApplication.list.get(position); et_path.setText(prepath); myBinder.callplay(prepath); bt_play.setText("暂停"); isPlaying = true; break; case R.id.bt_next: // 下一曲 myBinder.callstop(); position++; if (position > MyApplication.list.size() - 1) { position = 0; } String nextpath = MyApplication.list.get(position); et_path.setText(nextpath); myBinder.callplay(nextpath); bt_play.setText("暂停"); isPlaying = true; break; default: break; }
四、项目代码链接:https://git.coding.net/Kencondor/MusicPlayer.git
五、apk链接:https://coding.net/u/Kencondor/p/MusicPlayer/git/raw/master/app/release/app-release.apk
六、apk测试录屏视频连接:https://www.bilibili.com/video/av39910423/