Пример #1
0
 @Override
 public void onPlayerState(PlayerState playerState) {
   if (playerState.playing) {
     playPauseFloatingActionButton.setImageBitmap(
         BitmapFactory.decodeResource(getResources(), R.mipmap.ic_pause_white));
   } else {
     playPauseFloatingActionButton.setImageBitmap(
         BitmapFactory.decodeResource(getResources(), R.mipmap.ic_play_arrow_white));
   }
 }
Пример #2
0
 @Override
 public void onPlayerState(PlayerState playerState) {
   /*
      Determine Plater State and play, Pause, or resume track
   */
   SharedPreferences playerPreferences = getSharedPreferences(PLAYER_PREFS, MODE_PRIVATE);
   if (playerState.playing) {
     mPlayer.pause();
     playPauseFloatingActionButton.setImageBitmap(
         BitmapFactory.decodeResource(getResources(), R.mipmap.ic_play_arrow_white));
   } else if (playerState.trackUri != null && !playerState.trackUri.equals("")) {
     mPlayer.resume();
     playPauseFloatingActionButton.setImageBitmap(
         BitmapFactory.decodeResource(getResources(), R.mipmap.ic_pause_white));
   } else {
     /*
        TODO: Implement an solution for storing
     */
     String trackUri = "spotify:track:6QPKYGnAW9QozVz2dSWqRg";
     mPlayer.play(trackUri);
     playPauseFloatingActionButton.setImageBitmap(
         BitmapFactory.decodeResource(getResources(), R.mipmap.ic_pause_white));
   }
 }