url = bundle.getString(“url”);
listPosition = bundle.getInt(“listPosition”);
repeatState = bundle.getInt(“repeatState”);
isShuffle = bundle.getBoolean(“shuffleState”);
flag = bundle.getInt(“MSG”);
currentTime = bundle.getInt(“currentTime”);
duration = bundle.getInt(“duration”);
initView();
}
/**
- 初始化界面
*/
public void initView() {
musicTitle.setText(title);
musicArtist.setText(artist);
music_progressBar.setProgress(currentTime);
music_progressBar.setMax(duration);
switch (repeatState) {
case isCurrentRepeat: // 单曲循环
shuffleBtn.setClickable(false);
repeatBtn.setBackgroundResource(R.drawable.repeat_current_selector);
break;
case isAllRepeat: // 全部循环
shuffleBtn.setClickable(false);
repeatBtn.setBackgroundResource(R.drawable.repeat_all_selector);
break;
case isNoneRepeat: // 无重复
shuffleBtn.setClickable(true);
repeatBtn.setBackgroundResource(R.drawable.repeat_none_selector);
break;
}
if(isShuffle) {
isNoneShuffle = false;
shuffleBtn.setBackgroundResource(R.drawable.shuffle_selector);
repeatBtn.setClickable(false);
} else {
isNoneShuffle = true;
shuffleBtn.setBackgroundResource(R.drawable.shuffle_none_selector);
repeatBtn.setClickable(true);
}
if(flag == AppConstant.PlayerMsg.PLAYING_MSG) { //如果播放信息是正在播放
Toast.makeText(PlayerActivity.this, “正在播放–” + title, 1).show();
}
else if(flag == AppConstant.PlayerMsg.PLAY_MSG) { //如果是点击列表播放歌曲的话
play();
}
playBtn.setBackgroundResource(R.drawable.play_selector);
isPlaying = true;
isPause = false;
}
/**
- 反注册广播
*/
@Override
protected void onStop() {
super.onStop();
unregisterReceiver(playerReceiver);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
/**
-
控件点击事件
-
@author wwj
*/
private class ViewOnclickListener implements OnClickListener {
Intent intent = new Intent();
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.play_music:
if (isPlaying) {
playBtn.setBackgroundResource(R.drawable.pause_selector);
intent.setAction(“com.wwj.media.MUSIC_SERVICE”);
intent.putExtra(“MSG”, AppConstant.PlayerMsg.PAUSE_MSG);
startService(intent);
isPlaying = false;
isPause = true;
} else if (isPause) {
playBtn.setBackgroundResource(R.drawable.play_selector);
intent.setAction(“com.wwj.media.