Java Code Examples for android.support.v4.media.session.PlaybackStateCompat#STATE_BUFFERING

The following examples show how to use android.support.v4.media.session.PlaybackStateCompat#STATE_BUFFERING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FullScreenPlayerActivity.java    From LyricHere with Apache License 2.0 6 votes vote down vote up
private void connectToSession(MediaSessionCompat.Token token) {
    try {
        mMediaController = new MediaControllerCompat(FullScreenPlayerActivity.this, token);
        if (mMediaController.getMetadata() == null) {
            finish();
            return;
        }

        mMediaController.registerCallback(mCallback);
        PlaybackStateCompat state = mMediaController.getPlaybackState();
        updatePlaybackState(state);
        MediaMetadataCompat metadata = mMediaController.getMetadata();
        if (metadata != null) {
            updateMediaDescription(metadata.getDescription());
            updateDuration(metadata);
        }
        updateProgress();
        if (state != null && (state.getState() == PlaybackStateCompat.STATE_PLAYING ||
                state.getState() == PlaybackStateCompat.STATE_BUFFERING)) {
            scheduleSeekbarUpdate();
        }

    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: PlaybackControlsFragment.java    From LyricHere with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    PlaybackStateCompat stateObj = mMediaControllerProvider.getSupportMediaController().getPlaybackState();
    final int state = stateObj == null ?
            PlaybackStateCompat.STATE_NONE : stateObj.getState();
    LogUtils.d(TAG, "Button pressed, in state " + state);
    switch (v.getId()) {
        case R.id.play_pause:
            LogUtils.d(TAG, "Play button pressed, in state " + state);
            if (state == PlaybackStateCompat.STATE_PAUSED ||
                    state == PlaybackStateCompat.STATE_STOPPED ||
                    state == PlaybackStateCompat.STATE_NONE) {
                playMedia();
            } else if (state == PlaybackStateCompat.STATE_PLAYING ||
                    state == PlaybackStateCompat.STATE_BUFFERING ||
                    state == PlaybackStateCompat.STATE_CONNECTING) {
                pauseMedia();
            }
            break;
    }
}
 
Example 3
Source File: LocalPlayback.java    From LyricHere with Apache License 2.0 6 votes vote down vote up
@Override
public void seekTo(int position) {
    LogUtils.d(TAG, "seekTo called with ", position);

    if (mMediaPlayer == null) {
        // If we do not have a current media player, simply update the current position
        mCurrentPosition = position;
    } else {
        if (mMediaPlayer.isPlaying()) {
            mState = PlaybackStateCompat.STATE_BUFFERING;
        }
        mMediaPlayer.seekTo(position);
        if (mCallback != null) {
            mCallback.onPlaybackStatusChanged(mState);
        }
    }
}
 
Example 4
Source File: LocalPlayback.java    From YouTube-In-Background with MIT License 6 votes vote down vote up
@Override
public int getState()
{
    if (exoPlayer == null) {
        return exoPlayerNullIsStopped ? PlaybackStateCompat.STATE_STOPPED : PlaybackStateCompat.STATE_NONE;
    }

    switch (exoPlayer.getPlaybackState()) {
        case STATE_IDLE:
            return PlaybackStateCompat.STATE_PAUSED;
        case STATE_BUFFERING:
            return PlaybackStateCompat.STATE_BUFFERING;
        case STATE_READY:
            return exoPlayer.getPlayWhenReady() ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED;
        case STATE_ENDED:
            return PlaybackStateCompat.STATE_PAUSED;
        default:
            return PlaybackStateCompat.STATE_NONE;
    }
}
 
Example 5
Source File: TrackFragment.java    From Melophile with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.play_pause)
public void playPause() {
  lastState = null;
  MediaControllerCompat controllerCompat = MediaControllerCompat.getMediaController(getActivity());
  PlaybackStateCompat stateCompat = controllerCompat.getPlaybackState();
  if (stateCompat != null) {
    MediaControllerCompat.TransportControls controls =
            controllerCompat.getTransportControls();
    switch (stateCompat.getState()) {
      case PlaybackStateCompat.STATE_PLAYING:
      case PlaybackStateCompat.STATE_BUFFERING:
        controls.pause();
        break;
      case PlaybackStateCompat.STATE_NONE:
      case PlaybackStateCompat.STATE_PAUSED:
      case PlaybackStateCompat.STATE_STOPPED:
        controls.play();
        break;
      default:
        Log.d(TAG, "State " + stateCompat.getState());
    }
  }
}
 
Example 6
Source File: Playback.java    From react-native-audio-streaming-player with MIT License 5 votes vote down vote up
public void seekTo(int position) {
    if (mMediaPlayer == null) {
        // If we do not have a current media player, simply update the current position
        mCurrentPosition = position;
    } else {
        if (mMediaPlayer.isPlaying()) {
            mState = PlaybackStateCompat.STATE_BUFFERING;
        }
        registerAudioNoisyReceiver();
        mMediaPlayer.seekTo(position);
        if (mCallback != null) {
            mCallback.onPlaybackStateChanged(mState);
        }
    }
}
 
Example 7
Source File: Playback.java    From react-native-audio-streaming-player with MIT License 5 votes vote down vote up
/**
 * Reconfigures MediaPlayer according to audio focus settings and
 * starts/restarts it. This method starts/restarts the MediaPlayer
 * respecting the current audio focus state. So if we have focus, it will
 * play normally; if we don't have focus, it will either leave the
 * MediaPlayer paused or set it to a low volume, depending on what is
 * allowed by the current focus settings. This method assumes mPlayer !=
 * null, so if you are calling it, you have to do so from a context where
 * you are sure this is the case.
 */
private void configMediaPlayerState() {
    if (mAudioFocus == AUDIO_NO_FOCUS_NO_DUCK) {
        // If we don't have audio focus and can't duck, we have to pause,
        if (mState == PlaybackStateCompat.STATE_PLAYING) {
            pause();
        }
    } else {  // we have audio focus:
        registerAudioNoisyReceiver();
        if (mAudioFocus == AUDIO_NO_FOCUS_CAN_DUCK) {
            mMediaPlayer.setVolume(VOLUME_DUCK, VOLUME_DUCK); // we'll be relatively quiet
        } else {
            if (mMediaPlayer != null) {
                mMediaPlayer.setVolume(VOLUME_NORMAL, VOLUME_NORMAL); // we can be loud again
            } // else do something for remote client.
        }
        // If we were playing when we lost focus, we need to resume playing.
        if (mPlayOnFocusGain) {
            if (mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
                if (mCurrentPosition == mMediaPlayer.getCurrentPosition()) {
                    mMediaPlayer.start();
                    mState = PlaybackStateCompat.STATE_PLAYING;
                } else {
                    mMediaPlayer.seekTo(mCurrentPosition);
                    mState = PlaybackStateCompat.STATE_BUFFERING;
                }
            }
            mPlayOnFocusGain = false;
        }
    }
    if (mCallback != null) {
        mCallback.onPlaybackStateChanged(mState);
    }
}
 
Example 8
Source File: Playback.java    From react-native-audio-streaming-player with MIT License 5 votes vote down vote up
/**
 * Called when MediaPlayer has completed a seek
 *
 * @see OnSeekCompleteListener
 */
@Override
public void onSeekComplete(MediaPlayer mp) {
    mCurrentPosition = mp.getCurrentPosition();
    if (mState == PlaybackStateCompat.STATE_BUFFERING) {
        registerAudioNoisyReceiver();
        mMediaPlayer.start();
        mState = PlaybackStateCompat.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlaybackStateChanged(mState);
    }
}
 
Example 9
Source File: PlayerController.java    From klingar with Apache License 2.0 5 votes vote down vote up
private void updatePlayButton(@State int state) {
  if (state == PlaybackStateCompat.STATE_PLAYING
      || state == PlaybackStateCompat.STATE_BUFFERING) {
    playPauseButton.setImageState(PAUSE, true);
    playPauseButton.setContentDescription(descPause);
  } else {
    playPauseButton.setImageState(PLAY, true);
    playPauseButton.setContentDescription(descPlay);
  }
}
 
Example 10
Source File: AudioPlaybackListener.java    From DMAudioStreamer with Apache License 2.0 5 votes vote down vote up
private void configMediaPlayerState() {
    Logger.d(TAG, "configMediaPlayerState. mAudioFocus=", mAudioFocus);
    if (mAudioFocus == AUDIO_NO_FOCUS_NO_DUCK) {
        // If we don't have audio focus and can't duck, we have to pause,
        if (mState == PlaybackStateCompat.STATE_PLAYING) {
            mPlayOnFocusGain = false;
            pause();
        }
    } else {  // we have audio focus:
        registerAudioNoisyReceiver();
        if (mAudioFocus == AUDIO_NO_FOCUS_CAN_DUCK) {
            mMediaPlayer.setVolume(VOLUME_DUCK, VOLUME_DUCK); // we'll be relatively quiet
        } else {
            if (mMediaPlayer != null) {
                mMediaPlayer.setVolume(VOLUME_NORMAL, VOLUME_NORMAL); // we can be loud again
            } // else do something for remote client.
        }
        // If we were playing when we lost focus, we need to resume playing.
        if (mPlayOnFocusGain) {
            if (mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
                Logger.d(TAG, "configMediaPlayerState startMediaPlayer. seeking to ",
                        mCurrentPosition);
                if (mCurrentPosition == mMediaPlayer.getCurrentPosition()) {
                    mMediaPlayer.start();
                    mState = PlaybackStateCompat.STATE_PLAYING;
                } else {
                    mMediaPlayer.seekTo(mCurrentPosition);
                    mState = PlaybackStateCompat.STATE_BUFFERING;
                }
            }
            mPlayOnFocusGain = false;
        }
    }
    if (mCallback != null) {
        mCallback.onPlaybackStatusChanged(mState);
    }
}
 
Example 11
Source File: MediaSessionManager.java    From react-native-jw-media-player with MIT License 5 votes vote down vote up
private void updatePlaybackState(PlayerState playerState) {
	PlaybackStateCompat.Builder newPlaybackState = getPlaybackStateBuilder();
	long capabilities = getCapabilities(playerState);
	//noinspection WrongConstant
	newPlaybackState.setActions(capabilities);

	int playbackStateCompat = PlaybackStateCompat.STATE_NONE;
	switch (playerState) {
		case PLAYING:
			playbackStateCompat = PlaybackStateCompat.STATE_PLAYING;
			break;
		case PAUSED:
			playbackStateCompat = PlaybackStateCompat.STATE_PAUSED;
			break;
		case BUFFERING:
			playbackStateCompat = PlaybackStateCompat.STATE_BUFFERING;
			break;
		case IDLE:
			if (mReceivedError) {
				playbackStateCompat = PlaybackStateCompat.STATE_ERROR;
			} else {
				playbackStateCompat = PlaybackStateCompat.STATE_STOPPED;
			}
			break;
	}

	if (mPlayer != null) {
		newPlaybackState.setState(playbackStateCompat, (long)mPlayer.getPosition(), mPlayer.getPlaybackRate()); // PLAYBACK_RATE
		mMediaSessionCompat.setPlaybackState(newPlaybackState.build());
		mNotificationWrapper
				.createNotification(mPlayer.getContext(), mMediaSessionCompat, capabilities);
	}
}
 
Example 12
Source File: MediaPlayback.java    From Melophile with Apache License 2.0 5 votes vote down vote up
@Override
public void startPlayer() {
  createPlayerIfNeeded();
  try {
    playerState = PlaybackStateCompat.STATE_BUFFERING;
    player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    player.setDataSource(currentUrl);
    player.prepareAsync();
  } catch (IOException ex) {
    ex.printStackTrace();
    //notify UI
    if (callback != null) callback.onError();
  }
}
 
Example 13
Source File: Playback.java    From react-native-streaming-audio-player with MIT License 5 votes vote down vote up
public void seekTo(int position) {
    if (mMediaPlayer == null) {
        // If we do not have a current media player, simply update the current position
        mCurrentPosition = position;
    } else {
        if (mMediaPlayer.isPlaying()) {
            mState = PlaybackStateCompat.STATE_BUFFERING;
        }
        registerAudioNoisyReceiver();
        mMediaPlayer.seekTo(position);
        if (mCallback != null) {
            mCallback.onPlaybackStateChanged(mState);
        }
    }
}
 
Example 14
Source File: Playback.java    From react-native-streaming-audio-player with MIT License 5 votes vote down vote up
/**
 * Reconfigures MediaPlayer according to audio focus settings and
 * starts/restarts it. This method starts/restarts the MediaPlayer
 * respecting the current audio focus state. So if we have focus, it will
 * play normally; if we don't have focus, it will either leave the
 * MediaPlayer paused or set it to a low volume, depending on what is
 * allowed by the current focus settings. This method assumes mPlayer !=
 * null, so if you are calling it, you have to do so from a context where
 * you are sure this is the case.
 */
private void configMediaPlayerState() {
    if (mAudioFocus == AUDIO_NO_FOCUS_NO_DUCK) {
        // If we don't have audio focus and can't duck, we have to pause,
        if (mState == PlaybackStateCompat.STATE_PLAYING) {
            pause();
        }
    } else {  // we have audio focus:
        registerAudioNoisyReceiver();
        if (mAudioFocus == AUDIO_NO_FOCUS_CAN_DUCK) {
            mMediaPlayer.setVolume(VOLUME_DUCK, VOLUME_DUCK); // we'll be relatively quiet
        } else {
            if (mMediaPlayer != null) {
                mMediaPlayer.setVolume(VOLUME_NORMAL, VOLUME_NORMAL); // we can be loud again
            } // else do something for remote client.
        }
        // If we were playing when we lost focus, we need to resume playing.
        if (mPlayOnFocusGain) {
            if (mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
                if (mCurrentPosition == mMediaPlayer.getCurrentPosition()) {
                    mMediaPlayer.start();
                    mState = PlaybackStateCompat.STATE_PLAYING;
                } else {
                    mMediaPlayer.seekTo(mCurrentPosition);
                    mState = PlaybackStateCompat.STATE_BUFFERING;
                }
            }
            mPlayOnFocusGain = false;
        }
    }
    if (mCallback != null) {
        mCallback.onPlaybackStateChanged(mState);
    }
}
 
Example 15
Source File: Playback.java    From react-native-streaming-audio-player with MIT License 5 votes vote down vote up
/**
 * Called when MediaPlayer has completed a seek
 *
 * @see OnSeekCompleteListener
 */
@Override
public void onSeekComplete(MediaPlayer mp) {
    mCurrentPosition = mp.getCurrentPosition();
    if (mState == PlaybackStateCompat.STATE_BUFFERING) {
        registerAudioNoisyReceiver();
        mMediaPlayer.start();
        mState = PlaybackStateCompat.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlaybackStateChanged(mState);
    }
}
 
Example 16
Source File: RemoteControlClientLP.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setPlaybackState(int state, int index, int queueSize) {
	PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder();

	int newState = PlaybackStateCompat.STATE_NONE;
	switch(state) {
		case RemoteControlClient.PLAYSTATE_PLAYING:
			newState = PlaybackStateCompat.STATE_PLAYING;
			break;
		case RemoteControlClient.PLAYSTATE_STOPPED:
			newState = PlaybackStateCompat.STATE_STOPPED;
			break;
		case RemoteControlClient.PLAYSTATE_PAUSED:
			newState = PlaybackStateCompat.STATE_PAUSED;
			break;
		case RemoteControlClient.PLAYSTATE_BUFFERING:
			newState = PlaybackStateCompat.STATE_BUFFERING;
			break;
	}

	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	builder.setState(newState, position, 1.0f);
	DownloadFile downloadFile = downloadService.getCurrentPlaying();
	Entry entry = null;
	boolean isSong = true;
	if(downloadFile != null) {
		entry = downloadFile.getSong();
		isSong = entry.isSong();
	}

	builder.setActions(getPlaybackActions(isSong, index, queueSize));

	if(entry != null) {
		addCustomActions(entry, builder);
		builder.setActiveQueueItemId(entry.getId().hashCode());
	}

	PlaybackStateCompat playbackState = builder.build();
	mediaSession.setPlaybackState(playbackState);
	previousState = state;
}
 
Example 17
Source File: TrackFragment.java    From Melophile with Apache License 2.0 4 votes vote down vote up
public void updatePlaybackState(PlaybackStateCompat stateCompat) {
  if (stateCompat == null) return;
  lastState = stateCompat;
  updateRepeatMode(isActionApplied(stateCompat.getActions(),
          PlaybackStateCompat.ACTION_SET_REPEAT_MODE));
  updateShuffleMode(isActionApplied(stateCompat.getActions(),
          PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE_ENABLED));
  //check the state
  switch (stateCompat.getState()) {
    case PlaybackStateCompat.STATE_PLAYING:
      playPause.setVisibility(VISIBLE);
      if (playPause.isPlay()) {
        playPause.change(false, true);
      }
      startSeekBarUpdate();
      break;
    case PlaybackStateCompat.STATE_PAUSED:
      // mControllers.setVisibility(VISIBLE);
      // mLoading.setVisibility(INVISIBLE);
      playPause.setVisibility(VISIBLE);
      if (!playPause.isPlay()) {
        playPause.change(true, true);
      }
      stopSeekBarUpdate();
      break;
    case PlaybackStateCompat.STATE_NONE:
    case PlaybackStateCompat.STATE_STOPPED:
      playPause.setVisibility(VISIBLE);
      if (playPause.isPlay()) {
        playPause.change(false, true);
      }
      stopSeekBarUpdate();
      break;
    case PlaybackStateCompat.STATE_BUFFERING:
      playPause.setVisibility(INVISIBLE);
      stopSeekBarUpdate();
      break;
    default:
      Log.d(TAG, "Unhandled state " + stateCompat.getState());
  }
}
 
Example 18
Source File: LocalPlayback.java    From LyricHere with Apache License 2.0 4 votes vote down vote up
@Override
public void play(QueueItem item) {
    mPlayOnFocusGain = true;
    tryToGetAudioFocus();
    registerAudioNoisyReceiver();
    String mediaId = item.getDescription().getMediaId();
    boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);
    if (mediaHasChanged) {
        mCurrentPosition = 0;
        mCurrentMediaId = mediaId;
    }

    if (mState == PlaybackStateCompat.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) {
        configMediaPlayerState();
    } else {
        mState = PlaybackStateCompat.STATE_STOPPED;
        relaxResources(false); // release everything except MediaPlayer
        MediaMetadataCompat track = mMusicProvider.getMusic(
                MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId()));

        String source = track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE);

        try {
            createMediaPlayerIfNeeded();

            mState = PlaybackStateCompat.STATE_BUFFERING;

            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mMediaPlayer.setDataSource(source);

            // Starts preparing the media player in the background. When
            // it's done, it will call our OnPreparedListener (that is,
            // the onPrepared() method on this class, since we set the
            // listener to 'this'). Until the media player is prepared,
            // we *cannot* call start() on it!
            mMediaPlayer.prepareAsync();

            // If we are streaming from the internet, we want to hold a
            // Wifi lock, which prevents the Wifi radio from going to
            // sleep while the song is playing.
            mWifiLock.acquire();

            if (mCallback != null) {
                mCallback.onPlaybackStatusChanged(mState);
            }

        } catch (IOException ex) {
            LogUtils.e(TAG, ex, "Exception playing song");
            if (mCallback != null) {
                mCallback.onError(ex.getMessage());
            }
        }
    }
}
 
Example 19
Source File: MusicActivity.java    From DMAudioStreamer with Apache License 2.0 4 votes vote down vote up
@Override
public void updatePlaybackState(int state) {
    Logger.e("updatePlaybackState: ", "" + state);
    switch (state) {
        case PlaybackStateCompat.STATE_PLAYING:
            pgPlayPauseLayout.setVisibility(View.INVISIBLE);
            btn_play.Play();
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_PLAYING);
                notifyAdapter(currentSong);
            }
            break;
        case PlaybackStateCompat.STATE_PAUSED:
            pgPlayPauseLayout.setVisibility(View.INVISIBLE);
            btn_play.Pause();
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_PAUSED);
                notifyAdapter(currentSong);
            }
            break;
        case PlaybackStateCompat.STATE_NONE:
            currentSong.setPlayState(PlaybackStateCompat.STATE_NONE);
            notifyAdapter(currentSong);
            break;
        case PlaybackStateCompat.STATE_STOPPED:
            pgPlayPauseLayout.setVisibility(View.INVISIBLE);
            btn_play.Pause();
            audioPg.setValue(0);
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_NONE);
                notifyAdapter(currentSong);
            }
            break;
        case PlaybackStateCompat.STATE_BUFFERING:
            pgPlayPauseLayout.setVisibility(View.VISIBLE);
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_NONE);
                notifyAdapter(currentSong);
            }
            break;
    }
}
 
Example 20
Source File: BackgroundAudioService.java    From YouTube-In-Background with MIT License 4 votes vote down vote up
/**
     * Extracts link from youtube video ID, so mediaPlayer can play it
     */
    private void extractUrlAndPlay()
    {
//        LogHelper.e(TAG, "extractUrlAndPlay: extracting url for video id=" + currentVideo.getId());
        final String youtubeLink = "http://youtube.com/watch?v=" + currentVideo.getId();
//        LogHelper.e(TAG, youtubeLink);

        YouTubeUriExtractor ytEx = new YouTubeUriExtractor(this)
        {
            @Override
            public void onUrisAvailable(String videoId, final String videoTitle,
                                        SparseArray<YtFile> ytFiles)
            {
                if (ytFiles != null) {
                    YtFile ytFile = getBestStream(ytFiles);

                    playOnFocusGain = true;
                    currentPosition = 0;
                    tryToGetAudioFocus();
                    registerAudioNoisyReceiver();
                    playState = PlaybackStateCompat.STATE_STOPPED;
                    relaxResources(false); // Release everything except MediaPlayer

                    try {
//                        LogHelper.e(TAG, ytFile.getUrl());
//                        LogHelper.e(TAG, "extractUrlAndPlay: Start playback");

                        createMediaPlayerIfNeeded();

                        playState = PlaybackStateCompat.STATE_BUFFERING;

                        mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
                        mediaPlayer.setDataSource(ytFile.getUrl());
                        mediaPlayer.setOnPreparedListener(backgroundAudioService);
                        currentVideoTitle = videoTitle;

                        // Starts preparing the media player in the background. When
                        // it's done, it will call our OnPreparedListener (that is,
                        // the onPrepared() method on this class, since we set the
                        // listener to 'this'). Until the media player is prepared,
                        // we *cannot* call start() on it!
                        mediaPlayer.prepareAsync();

                        // If we are streaming from the internet, we want to hold a
                        // Wifi lock, which prevents the Wifi radio from going to
                        // sleep while the song is playing.
                        wifiLock.acquire();
//                            mediaPlayer.start();

//                        if (callback != null) {
//                            callback.onPlaybackStatusChanged(playState);
//                        }
                    } catch (IOException io) {
//                        LogHelper.e(TAG, io, "extractUrlAndPlay: Exception playing song");
                        io.printStackTrace();
                    }
                }
            }
        };
        // Ignore the webm container formatViewCount
//         ytEx.setIncludeWebM(false);
//         ytEx.setParseDashManifest(true);
        // Lets execute the request
        ytEx.execute(youtubeLink);
    }