From 82f8756b288c0a5be585ca815e5228a16acb21f7 Mon Sep 17 00:00:00 2001
From: Daniel Yu
Activity.enterPictureInPicture(). The following example switches
-to PIP mode when the user selects a dedicated PIP button on a media control
-bar:
+Activity.enterPictureInPictureMode(). The following example
+switches to PIP mode when the user selects a dedicated PIP button on a media
+control bar:
@Override
public void onActionClicked(Action action) {
if (action.getId() == R.id.lb_control_picture_in_picture) {
- getActivity().enterPictureInPicture();
+ getActivity().enterPictureInPictureMode();
return;
}
...
@@ -129,14 +129,14 @@ control bar PIP actions and uses the PIP icon.
When your activity enters PIP mode, your activity should only show video
playback. Remove UI elements before your activity enters PIP,
and restore these elements when your activity becomes full-screen again.
-Override Activity.onPictureInPictureChanged() or
-Fragment.onPictureInPictureChanged() and enable or
+Override Activity.onPictureInPictureModeChanged() or
+Fragment.onPictureInPictureModeChanged() and enable or
disable your UI elements as needed, for example:
@Override
-public void onPictureInPictureChanged(boolean inPictureInPicture) {
- if (inPictureInPicture) {
+public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
+ if (isInPictureInPictureMode) {
// Hide the controls in picture-in-picture mode.
...
} else {
@@ -159,8 +159,8 @@ example:
@Override
public void onPause() {
- // If called due to PIP, do not pause playback
- if (inPictureInPicture()) {
+ // If called while in PIP mode, do not pause playback
+ if (isInPictureInPictureMode()) {
// Continue playback
...
}