Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class PictureInPicture
- Object
- 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
implCodenameOneImplementation- 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
aspectWidthint- the width part of the aspect ratio
aspectHeightint- 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
listenerSuccessCallback<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
listenerSuccessCallback<Boolean>- the listener to remove