Ejemplo n.º 1
0
 public void onPauseButtonClicked(View view) {
   if (mCurrentPlayerState.playing) {
     mPlayer.pause();
   } else {
     mPlayer.resume();
   }
 }
Ejemplo n.º 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));
   }
 }