Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class PictureInPicture

  1. Object
  2. PictureInPicture

Picture in picture: shrinks the app into a floating window while video keeps playing, so the user can work in another app.

Supported on Android 8 and later, where the whole app window becomes the floating window. Hide controls and other chrome while #isActive() is true, leaving only the video. Referencing this class makes the Android build declare supportsPictureInPicture on the main activity. iOS and the simulator report #isSupported() as false.

if (PictureInPicture.isSupported()) {
    PictureInPicture.addListener(new SuccessCallback<Boolean>() {
        public void onSucess(Boolean active) {
            Log.p("Picture in picture: " + active);
        }
    });
    PictureInPicture.enter(16, 9);
}

Methods

public static void setImplementation(CodenameOneImplementation impl)Invoked internally from Display, this method is for internal use only
public static boolean isSupported()True when the app can enter picture in picture.
public static boolean enter(int aspectWidth, int aspectHeight)Asks the system to enter picture in picture with the given aspect ratio, for example 16 by 9.
public static boolean isActive()True while the app is shown as a picture in picture window.
public static void addListener(SuccessCallback<Boolean> listener)Adds a listener told, on the EDT, when the app enters or leaves picture in picture.
public static void removeListener(SuccessCallback<Boolean> listener)Removes a listener added with #addListener(SuccessCallback).

Inherited methods

Method details

setImplementation

public static void setImplementation(CodenameOneImplementation impl)
Invoked internally from Display, this method is for internal use only

Parameters

impl CodenameOneImplementation
implementation instance

isSupported

public static boolean isSupported()
True when the app can enter picture in picture.

Returns

true when supported

enter

public static boolean enter(int aspectWidth, int aspectHeight)
Asks the system to enter picture in picture with the given aspect ratio, for example 16 by 9.

Parameters

aspectWidth int
the width part of the aspect ratio
aspectHeight int
the height part of the aspect ratio

Returns

true when the request was accepted

isActive

public static boolean isActive()
True while the app is shown as a picture in picture window.

Returns

true while active

addListener

public static void addListener(SuccessCallback<Boolean> listener)
Adds a listener told, on the EDT, when the app enters or leaves picture in picture.

Parameters

listener SuccessCallback<Boolean>
receives true on entering and false on leaving

removeListener

public static void removeListener(SuccessCallback<Boolean> listener)
Removes a listener added with #addListener(SuccessCallback).

Parameters

listener SuccessCallback<Boolean>
the listener to remove