public class PictureInPictureManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_CLOSED_CAPTION_REDUCTION_SCALE_FACTOR
The default value is to reduce Closed Captions by 50% when in Picture-in-Picture mode.
|
Modifier and Type | Method and Description |
---|---|
void |
enterPictureInPictureMode()
This method puts the registered Activity into Picture-in-Picture mode.
|
BrightcovePictureInPictureParams |
getBrightcovePictureInPictureParams() |
static PictureInPictureManager |
getInstance() |
boolean |
isInPictureInPictureMode()
Checks if there is a registered activity and calls that activity
method
Activity.isInPictureInPictureMode() . |
boolean |
isPictureInPictureEnabled()
PictureInPictureManager will be disabled if there is no Activity registered or
if the Activity previously registered was destroyed.
|
void |
onPictureInPictureModeChanged(boolean isInPictureInPictureMode,
android.content.res.Configuration newConfig)
This method reacts to the Picture-in-Picture changes and emits
EventType.DID_ENTER_PICTURE_IN_PICTURE_MODE
and EventType.DID_EXIT_PICTURE_IN_PICTURE_MODE events. |
void |
onUserLeaveHint()
This method calls
enterPictureInPictureMode() if the PictureInPictureManager is configured
to do so. |
void |
registerActivity(android.app.Activity activity,
BaseVideoView videoView)
This method registers and holds a weak reference to the Activity
that will be put into Picture-in-Picture mode.
|
PictureInPictureManager |
setAspectRatio(android.util.Rational aspectRatio)
Sets the aspect ratio.
|
PictureInPictureManager |
setClosedCaptionsEnabled(boolean closedCaptionsEnabled)
Enables or disables closed captions for Picture in Picture mode.
|
PictureInPictureManager |
setClosedCaptionsReductionScaleFactor(float scaleFactor)
Sets reduction the scale factor for closed captions when entering
Picture in Picture mode.
|
PictureInPictureManager |
setOnUserLeaveEnabled(boolean onUserLeaveEnabled)
Enables or disables entering into Picture in Picture mode when the user has put the activity in
the background, for example, when of pressing the Home key.
|
PictureInPictureManager |
setSourceRectHint(android.graphics.Rect sourceRectHint)
Sets the source bounds hint.
|
PictureInPictureManager |
setUserActions(java.util.List<android.app.RemoteAction> userActions)
Sets the user actions.
|
void |
unregisterActivity(android.app.Activity activity)
Unregister the previously registered activity and clean its references.
|
public static final float DEFAULT_CLOSED_CAPTION_REDUCTION_SCALE_FACTOR
public static PictureInPictureManager getInstance()
public void registerActivity(@NonNull android.app.Activity activity, @NonNull BaseVideoView videoView)
Build.VERSION_CODES#O
,
otherwise the method will not do anything.activity
- the ActivityvideoView
- the BaseVideoViewpublic void unregisterActivity(android.app.Activity activity)
activity
- the activity to unregister.public void enterPictureInPictureMode()
Build.VERSION_CODES#O
,
otherwise the method will not do anything.PictureInPictureManagerException
- throws the exception if an activity has not been
registered. You must call registerActivity(Activity, BaseVideoView)
.registerActivity(Activity, BaseVideoView)
public boolean isInPictureInPictureMode()
Activity.isInPictureInPictureMode()
.
This only applies for Android Oreo or higher, otherwise it will always return false.Activity.isInPictureInPictureMode()
public boolean isPictureInPictureEnabled()
public void onUserLeaveHint()
enterPictureInPictureMode()
if the PictureInPictureManager is configured
to do so. You can enable this behavior by calling setOnUserLeaveEnabled(boolean)
to true.
By Default this behavior is disabled.
This method must be called from the Activity.onUserLeaveHint()
method.public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, android.content.res.Configuration newConfig)
EventType.DID_ENTER_PICTURE_IN_PICTURE_MODE
and EventType.DID_EXIT_PICTURE_IN_PICTURE_MODE
events.
This method must be called from the Activity.onPictureInPictureModeChanged(boolean, Configuration)
()} method.isInPictureInPictureMode
- true if it is in Picture-inPicture mode.newConfig
- the new configuration.public BrightcovePictureInPictureParams getBrightcovePictureInPictureParams()
PictureInPictureManagerException
- throws the exception if an activity has not been
registered. You must call registerActivity(Activity, BaseVideoView)
.public PictureInPictureManager setAspectRatio(@Nullable android.util.Rational aspectRatio)
aspectRatio
- the new aspect ratio for the activity in picture-in-picture, must be
between 2.39:1 and 1:2.39 (inclusive).public PictureInPictureManager setUserActions(@Nullable java.util.List<android.app.RemoteAction> userActions)
Activity.getMaxNumPictureInPictureActions()
actions, then the input list
will be truncated to that number.userActions
- the new actions to show in the picture-in-picture menu.RemoteAction
public PictureInPictureManager setSourceRectHint(@Nullable android.graphics.Rect sourceRectHint)
sourceRectHint
- window-coordinate bounds indicating the area of the activity that
will still be visible following the transition into picture-in-picture (eg. the video
view bounds in a video player)public PictureInPictureManager setClosedCaptionsEnabled(boolean closedCaptionsEnabled)
closedCaptionsEnabled
- true to enable closed captions.public PictureInPictureManager setOnUserLeaveEnabled(boolean onUserLeaveEnabled)
onUserLeaveEnabled
- true to enable.public PictureInPictureManager setClosedCaptionsReductionScaleFactor(float scaleFactor)
scaleFactor
- the scale factor