android / media-samples

Multiple samples showing the best practices in media APIs on Android (audio, video, etc.).
Apache License 2.0
1.28k stars 741 forks source link

Picture in Picture mode issue #20

Open pals-ric opened 6 years ago

pals-ric commented 6 years ago

I am trying to implement Picture in Picture mode independent from activities. For now i have pip functionality but its activity dependent.so i want to make it activity independent and it should continue for all over the app once this available for devices.

niravtopsy commented 5 years ago

Hello @pallavirichhariya22

Use below code for it.

@Override public void onUserLeaveHint() { if (!isInPictureInPictureMode()) { Rational aspectRatio = new Rational(vv.getWidth(), vv.getHeight()); pictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build(); enterPictureInPictureMode(pictureInPictureParamsBuilder.build()); } }