I am using this Github project for my app to play you tube videos using Youtube API.. I have the following code in my onInitializationSuccess
method..
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
this.player = player;
player.setPlayerStateChangeListener(playerStateChangeListener);
player.setPlaybackEventListener(playbackEventListener);
if (!wasRestored) {
player.cueVideo("I0D-fkypQQw");
}
}
I coded this YouTubePlayerView
to play in PIP mode in the following way :
enter_pip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Intent i = new Intent(getBaseContext(), PipActivity.class);
// startActivity(i);
if (android.os.Build.VERSION.SDK_INT >= 26) {
//Trigger PiP mode
try {
Rational rational = new Rational(youTubeView.getWidth(), youTubeView.getHeight());
PictureInPictureParams mParams =
new PictureInPictureParams.Builder()
.setAspectRatio(rational)
.build();
enterPictureInPictureMode(mParams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
} else {
Toast.makeText(MainActivity.this, "API 26 needed to perform PiP", Toast.LENGTH_SHORT).show();
}
}
});
}
The video successfully enters the PIP Mode, but the problem is the video stops after entering PIP mode , i want it to continue from where it was when not in PIP mode..
Please guide me on adding the picture-in-picture mode wherein the picture in picture mode should continue playing rather than stop.. I am looking for a youtube like PIP wherein the video plays at the bottom with Play/Pause Button and Close Button on its right..
I am looking for a PIP as in this image