@Override public void onReceive(Context context, Intent intent) { if (LocalMediaUtil.getWhichOnRemote() != LocalMediaUtil.Defs.MUSIC) { try { mMusicProgress.setProgress((int) mMusicPlayService.position()); if (mMusicPlayService.isPlaying()) { updateMusicInfo(); mStatusButton.setImageResource(R.drawable.video_btn_pause); } else { mStatusButton.setImageResource(R.drawable.video_btn_start); } } catch (RemoteException e) { e.printStackTrace(); } } }
public void handleMessage(Message msg) { switch (msg.what) { case 0: try { updateMusicInfo(); mNowPosition.setText(setDurationFormat((int) mMusicPlayService.position())); mMusicProgress.setProgress((int) mMusicPlayService.position()); mRepeat.setOnClickListener(new RepeatBtnClickListener()); mShuffle.setOnClickListener(new ShuffleBtnClickListener()); mPostButton.setOnClickListener(new PostBtnListener()); if (mMusicPlayService.isPlaying()) { mStatusButton.setImageResource(R.drawable.video_btn_pause); } else { mStatusButton.setImageResource(R.drawable.video_btn_start); } if (mMusicPlayService.getShuffleMode()) { mShuffle.setBackgroundResource(R.drawable.music_bth_shuffle_play_normal); } else { mShuffle.setBackgroundResource(R.drawable.music_bth_shuffle_play_closed_normal); } if (mMusicPlayService.getRepeatMode() == 0) { mRepeat.setBackgroundResource(R.drawable.music_bth_list_normal); } else if (mMusicPlayService.getRepeatMode() == 1) { mRepeat.setBackgroundResource(R.drawable.music_bth_single_cycle_normal); mMusicPlayService.setShuffleMode(false); mShuffle.setBackgroundResource(R.drawable.music_bth_shuffle_play_closed_normal); } else if (mMusicPlayService.getRepeatMode() == 2) { mRepeat.setBackgroundResource(R.drawable.music_bth_repeat_play_normal); } mMusicProgress.setOnSeekBarChangeListener(new MusicProgressChangeListener()); if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { postGetPositionInfo(); if (!mIsOnRemotePause) { mStatusButton.setImageResource(R.drawable.video_btn_pause); } } } catch (RemoteException e) { e.printStackTrace(); } break; case 1: if (LocalMediaUtil.getWhichOnRemote() != LocalMediaUtil.Defs.MUSIC) { try { mMusicProgress.setProgress((int) mMusicPlayService.position()); if (mMusicPlayService.isPlaying()) { mNowPosition.setText(setDurationFormat((int) mMusicPlayService.position())); mNowPosition.setVisibility(View.VISIBLE); } else { int vis = mNowPosition.getVisibility(); mNowPosition.setVisibility( vis == View.INVISIBLE ? View.VISIBLE : View.INVISIBLE); } } catch (RemoteException e) { e.printStackTrace(); } } break; default: break; } };