Class 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);
}
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddListener(SuccessCallback<Boolean> listener) Adds a listener told, on the EDT, when the app enters or leaves picture in picture.static booleanenter(int aspectWidth, int aspectHeight) Asks the system to enter picture in picture with the given aspect ratio, for example 16 by 9.static booleanisActive()True while the app is shown as a picture in picture window.static booleanTrue when the app can enter picture in picture.static voidremoveListener(SuccessCallback<Boolean> listener) Removes a listener added with#addListener(SuccessCallback).static voidsetImplementation(com.codename1.impl.CodenameOneImplementation impl) Invoked internally from Display, this method is for internal use only
-
Method Details
-
setImplementation
public static void setImplementation(com.codename1.impl.CodenameOneImplementation impl) Invoked internally from Display, this method is for internal use only
Parameters
impl: 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: the width part of the aspect ratio -
aspectHeight: 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
Adds a listener told, on the EDT, when the app enters or leaves picture in picture.
Parameters
listener: receives true on entering and false on leaving
-
removeListener
Removes a listener added with
#addListener(SuccessCallback).Parameters
listener: the listener to remove
-