@Override public void onGetPositioninforesult(Map obj) { if (obj != null) { int positionInt = (int) fromDateStringToInt((String) obj.get("relTime")); mRemotePlayPosition = positionInt; if (!mSeekBarTouchMode && (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC)) { mNowPosition.setText(setDurationFormat(positionInt)); mMusicProgress.setProgress(positionInt); postGetPositionInfo(); } } else { // mIsPlayOnLocal = true; try { // mMusicPlayService.setPlayOnPhone(true); mMusicPlayService.seekTo(mRemotePlayPosition); } catch (RemoteException e) { e.printStackTrace(); } try { if (mMusicPlayService.isPlaying()) { mStatusButton.setImageResource(R.drawable.video_btn_pause); } else { mStatusButton.setImageResource(R.drawable.video_btn_start); } } catch (RemoteException e) { e.printStackTrace(); } } }
@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(); } } }
@Override public void onGetPlayresult(Boolean obj) { if (obj) { mPostButton.setClickable(true); try { mStatusButton.setImageResource(R.drawable.video_btn_pause); mMusicPlayService.pause(); // mIsPlayOnLocal = false; postGetPositionInfo(); } catch (RemoteException e) { e.printStackTrace(); } } else { } }
public void doClick(View view) throws RemoteException { switch (view.getId()) { case R.id.pause_play: if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { if (mIsOnRemotePause) { postPauseToPlay(); mStatusButton.setImageResource(R.drawable.video_btn_pause); mIsOnRemotePause = false; } else { postpause(); mStatusButton.setImageResource(R.drawable.video_btn_start); mIsOnRemotePause = true; } } else { mMusicPlayService.pauseButtonPressed(); } break; case R.id.stop: if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { poststop(); LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.NOT_ANY_ONE); mIsOnRemotePause = true; } mMusicPlayService.stop(); MusicData.setNowPlayingMusic(null); mMusicPlayService.setInitialed(false); finish(); overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out); break; case R.id.next: mMusicPlayService.next(); updateMusicInfo(); if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { MusicItem music = MusicData.getNowPlayingMusic(); mMusicPlayService.pause(); // mMusicProgress.setMax((int) mMusicPlayService.duration()); // mArtistTextView.setText(music.getArtist()); // mTitleTextView.setText(music.getTitle()); // mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration()))); postNext(music.getItemUri(), music.metaData); } else { if (mMusicPlayService.getPreparedStatus()) { mMusicPlayService.play(); } } break; case R.id.prev: mMusicPlayService.prev(); updateMusicInfo(); if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { MusicItem music = MusicData.getNowPlayingMusic(); mMusicPlayService.pause(); // mMusicProgress.setMax((int) mMusicPlayService.duration()); // mArtistTextView.setText(music.getArtist()); // mTitleTextView.setText(music.getTitle()); // mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration()))); postNext(music.getItemUri(), music.metaData); } else { if (mMusicPlayService.getPreparedStatus()) { mMusicPlayService.play(); } } break; case R.id.post: break; case R.id.nowplayinglist: MusicData.setMusicShowList(MusicData.getMusicPlayList()); Intent intent = new Intent(); intent.putExtra("title", getResources().getString(R.string.playing_list)); intent.putExtra("scrollto", true); intent.setClass(getApplicationContext(), MusicListActivity.class); startActivityForResult(intent, 0); overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out); break; } }
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; } };