private void initiatePlayButtonState() {
   if (mMediaService.isPlaying()) {
     mPlayButton.setImageResource(R.drawable.ic_pause_black_36dp);
   } else if (mIsCompletedPlaying) {
     mPlayButton.setImageResource(R.drawable.ic_replay_black_36dp);
   } else if (mMediaService.isPaused()) {
     mPlayButton.setImageResource(R.drawable.ic_play_black_36dp);
   }
 }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();
    mRootView = inflater.inflate(R.layout.fragment_dialog_player, null);
    builder.setView(mRootView);

    initializeViews();

    if (savedInstanceState != null) {
      mDoPlayTrack = savedInstanceState.getBoolean("doPlayTrack");
      mPosition = savedInstanceState.getInt("position");
      mPreviewUrl = savedInstanceState.getString("previewUrl");
      mTrackInfos = savedInstanceState.getParcelableArrayList("tracklist");
      mArtist = savedInstanceState.getString("artist");
      int mScrubBarPosition = savedInstanceState.getInt("seekPosition");
      mMediaService = MediaService.getMediaServiceInstance();
      if (!mMediaService.isPlaying()) {
        mScrubBar.setEnabled(false);
        mScrubBar.setProgress(mScrubBarPosition);
      } else {
        mScrubBar.setEnabled(true);
      }

      setAlbumArt(mArtist, mTrackInfos.get(mPosition));

      mFormatedDuration = savedInstanceState.getString("trackDuration");
      mDurationTextView.setText("(" + mFormatedDuration + ")");

      mFormatterPlayed = savedInstanceState.getString("trackPlayed");
      mTimePlayedView.setText(mFormatterPlayed);

      initiatePlayButtonState();
      initializeOnClicks();
    }

    if (MediaService.getMediaServiceInstance() != null) {
      initializeMediaService();
    }
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);

    return alertDialog;
  }