@Override
        public void onClick(View arg0) {

          // Remove the seekbar update runnable.
          mHandler.removeCallbacks(seekbarUpdateRunnable);

          /*
           * Scrolling the pager will automatically call the skipToTrack() method.
           * Since we're passing true for the dispatchToListener parameter, the
           * onPageSelected() listener will receive a callback once the scrolling
           * animation completes. This has the side-benefit of letting the animation
           * finish before starting playback (keeps the animation buttery smooth).
           */
          int newPosition = mViewPager.getCurrentItem() + 1;
          if (newPosition < mViewPagerAdapter.getCount()) {
            scrollViewPager(newPosition, true, 1, true);
          } else {
            if (mApp.getService().getRepeatMode() == Common.REPEAT_PLAYLIST)
              mViewPager.setCurrentItem(0, false);
            else Toast.makeText(mContext, R.string.no_songs_to_skip_to, Toast.LENGTH_SHORT).show();
          }

          // mApp.getService().skipToNextTrack();

        }
  /** Initializes the view pager. */
  private void initViewPager() {

    try {
      mViewPager.setVisibility(View.INVISIBLE);
      mViewPagerAdapter = new PlaylistPagerAdapter(getSupportFragmentManager());
      mViewPager.setAdapter(mViewPagerAdapter);
      mViewPager.setOffscreenPageLimit(0);
      mViewPager.setOnPageChangeListener(mPageChangeListener);
      mViewPager.setCurrentItem(mApp.getService().getCurrentSongIndex(), false);

      FadeAnimation fadeAnimation =
          new FadeAnimation(mViewPager, 600, 0.0f, 1.0f, new DecelerateInterpolator(2.0f));

      fadeAnimation.animate();

    } catch (IllegalStateException e) {
      /*
       * Catches any exceptions that may occur
       * as a result of the user rapidly changing
       * their device's orientation.
       */
    }

    // Delay loading extra fragments by 1000ms.
    new Handler()
        .postDelayed(
            new Runnable() {

              @Override
              public void run() {
                mViewPager.setOffscreenPageLimit(10);
              }
            },
            1000);
  }
        @Override
        public void onClick(View arg0) {

          // Remove the seekbar update runnable.
          mHandler.removeCallbacks(seekbarUpdateRunnable);

          /*
           * Scrolling the pager will automatically call the skipToTrack() method.
           * Since we're passing true for the dispatchToListener parameter, the
           * onPageSelected() listener will receive a callback once the scrolling
           * animation completes. This has the side-benefit of letting the animation
           * finish before starting playback (keeps the animation buttery smooth).
           */
          int newPosition = mViewPager.getCurrentItem() - 1;
          if (newPosition > -1) {
            scrollViewPager(newPosition, true, 1, true);
          } else {
            mViewPager.setCurrentItem(0, false);
          }
        }
  /**
   * Scrolls the ViewPager programmatically. If dispatchToListener is true, USER_SCROLL will be set
   * to true.
   */
  private void scrollViewPager(
      int newPosition, boolean smoothScroll, int velocity, boolean dispatchToListener) {

    USER_SCROLL = dispatchToListener;
    mViewPager.scrollToItem(newPosition, smoothScroll, velocity, dispatchToListener);
  }
        @Override
        public void onReceive(Context context, Intent intent) {

          // Grab the bundle from the intent.
          Bundle bundle = intent.getExtras();

          // Initializes the ViewPager.
          if (intent.hasExtra(Common.INIT_PAGER) || intent.hasExtra(Common.NEW_QUEUE_ORDER))
            initViewPager();

          // Updates the ViewPager's current page/position.
          if (intent.hasExtra(Common.UPDATE_PAGER_POSTIION)) {
            int currentPosition = mViewPager.getCurrentItem();
            int newPosition = Integer.parseInt(bundle.getString(Common.UPDATE_PAGER_POSTIION));
            if (currentPosition != newPosition) {

              if (newPosition > 0 && Math.abs(newPosition - currentPosition) <= 5) {
                // Smooth scroll to the new index.
                scrollViewPager(newPosition, true, 1, false);
              } else {
                // The new index is too far away, so avoid smooth scrolling to it.
                mViewPager.setCurrentItem(newPosition, false);
              }

              // Reinit the seekbar update handler.
              mHandler.post(seekbarUpdateRunnable);
            }
          }

          // Updates the playback control buttons.
          if (intent.hasExtra(Common.UPDATE_PLAYBACK_CONTROLS)) {
            setPlayPauseButton();
            setRepeatButtonIcon();
            setShuffleButtonIcon();
          }

          // Displays the audibook toast.
          if (intent.hasExtra(Common.SHOW_AUDIOBOOK_TOAST))
            displayAudiobookToast(Long.parseLong(bundle.getString(Common.SHOW_AUDIOBOOK_TOAST)));

          // Updates the duration of the SeekBar.
          if (intent.hasExtra(Common.UPDATE_SEEKBAR_DURATION))
            setSeekbarDuration(Integer.parseInt(bundle.getString(Common.UPDATE_SEEKBAR_DURATION)));

          // Hides the seekbar and displays the streaming progress bar.
          if (intent.hasExtra(Common.SHOW_STREAMING_BAR)) {
            mSeekbar.setVisibility(View.INVISIBLE);
            mStreamingProgressBar.setVisibility(View.VISIBLE);
            mHandler.removeCallbacks(seekbarUpdateRunnable);
          }

          // Shows the seekbar and hides the streaming progress bar.
          if (intent.hasExtra(Common.HIDE_STREAMING_BAR)) {
            mSeekbar.setVisibility(View.VISIBLE);
            mStreamingProgressBar.setVisibility(View.INVISIBLE);
            mHandler.postDelayed(seekbarUpdateRunnable, 100);
          }

          // Updates the buffering progress on the seekbar.
          if (intent.hasExtra(Common.UPDATE_BUFFERING_PROGRESS))
            mSeekbar.setSecondaryProgress(
                Integer.parseInt(bundle.getString(Common.UPDATE_BUFFERING_PROGRESS)));

          // Close this activity if the service is about to stop running.
          if (intent.hasExtra(Common.SERVICE_STOPPING)) {
            mHandler.removeCallbacks(seekbarUpdateRunnable);
            finish();
          }
        }