public void updateMediaPlayerViews() { tvArtistName.setText(mTracks.get(mCurrentTrack).getArtist()); tvAlbumName.setText(mTracks.get(mCurrentTrack).getAlbum()); tvSongName.setText(mTracks.get(mCurrentTrack).getName()); Picasso.with(getActivity()) .load(mTracks.get(mCurrentTrack).getCoverImgs()) .placeholder(R.drawable.album_art_missing) .into(ivCoverPicture); if (mMediaPlayerService != null && mMediaPlayerService.isPlaying()) { ibPlayPause.setImageResource(R.drawable.ic_pause); } else if (mMediaPlayerService != null && !mMediaPlayerService.isPlaying()) { ibPlayPause.setImageResource(R.drawable.ic_play); } }
public int getCurrentPosition() { if (mMediaPlayerService != null && isMediaPlayerBound && mMediaPlayerService.isPlaying()) { return mMediaPlayerService.getPosition(); } else { return 0; } }
@Override public void onClick(View v) { int viewId = v.getId(); switch (viewId) { case R.id.ib_play_pause: if (mMediaPlayerService.isPlaying()) { mMediaPlayerService.pauseTrack(); seekHandler.removeCallbacks(updateSeekBar); ibPlayPause.setImageResource(R.drawable.ic_play); } else { mMediaPlayerService.resumeTrack(); seekHandler.postDelayed(updateSeekBar, 100); ibPlayPause.setImageResource(R.drawable.ic_pause); } break; case R.id.ib_previous: mCurrentTrack = mMediaPlayerService.playPrevious(); break; case R.id.ib_next: mCurrentTrack = mMediaPlayerService.playNext(); break; case R.id.ib_repeat: repeat = mMediaPlayerService.turnOnRepeateat(); updateRepeatIcon(repeat); break; case R.id.ib_shuffle: shuffle = mMediaPlayerService.turnOnShuffle(); updateShuffleIcon(shuffle); break; case R.id.ib_share: shareSong(); break; } }