-
public class PictureInPictureManager
The class responsible to manage the Picture-in-Picture mode.
-
-
Field Summary
Fields Modifier and Type Field Description public final static float
DEFAULT_CLOSED_CAPTION_REDUCTION_SCALE_FACTOR
private Rational
aspectRatio
private List<RemoteAction>
userActions
private Rect
sourceRectHint
private boolean
closedCaptionsEnabled
private boolean
onUserLeaveEnabled
-
Method Summary
Modifier and Type Method Description PictureInPictureManager
setAspectRatio(@Nullable() Rational aspectRatio)
Sets the aspect ratio. List<RemoteAction>
getUserActions()
PictureInPictureManager
setUserActions(@Nullable() List<RemoteAction> userActions)
Sets the user actions. PictureInPictureManager
setSourceRectHint(@Nullable() Rect sourceRectHint)
Sets the source bounds hint. PictureInPictureManager
setClosedCaptionsEnabled(boolean closedCaptionsEnabled)
Enables or disables closed captions for Picture in Picture mode. PictureInPictureManager
setOnUserLeaveEnabled(boolean onUserLeaveEnabled)
Enables or disables entering into Picture in Picture mode when the user has put the activity inthe background, for example, when of pressing the Home key. static PictureInPictureManager
getInstance()
void
registerActivity(@NonNull() Activity activity, @NonNull() BaseVideoView videoView)
This method registers and holds a weak reference to the Activitythat will be put into Picture-in-Picture mode.You can have only one registered Activity at a time. void
unregisterActivity(Activity activity)
Unregister the previously registered activity and clean its references. void
enterPictureInPictureMode()
This method puts the registered Activity into Picture-in-Picture mode. boolean
isInPictureInPictureMode()
Checks if there is a registered activity and calls that activitymethod isInPictureInPictureMode.This only applies for Android Oreo or higher, otherwise it will always return false. boolean
isPictureInPictureEnabled()
PictureInPictureManager will be disabled if there is no Activity registered orif the Activity previously registered was destroyed.This only applies for Android Oreo or higher, otherwise it will always return false.PictureInPictureManager will be temporarily disabled if the current videois a 360 video, which is currently not supported in Picture-in-Picture mode. void
onUserLeaveHint()
This method calls enterPictureInPictureMode if the PictureInPictureManager is configuredto do so. void
onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig)
This method reacts to the Picture-in-Picture changes and emits DID_ENTER_PICTURE_IN_PICTURE_MODE and DID_EXIT_PICTURE_IN_PICTURE_MODE events. BrightcovePictureInPictureParams
getBrightcovePictureInPictureParams()
PictureInPictureManager
setClosedCaptionsReductionScaleFactor(float scaleFactor)
Sets reduction the scale factor for closed captions when enteringPicture in Picture mode.The values accepted must be between 0 and 1. -
-
Method Detail
-
setAspectRatio
PictureInPictureManager setAspectRatio(@Nullable() Rational aspectRatio)
Sets the aspect ratio. This aspect ratio is defined as the desired width / height, anddoes not change upon device rotation.
- Parameters:
aspectRatio
- the new aspect ratio for the activity in picture-in-picture, must bebetween 2.39:1 and 1:2.39 (inclusive).
-
getUserActions
@NonNull() List<RemoteAction> getUserActions()
-
setUserActions
PictureInPictureManager setUserActions(@Nullable() List<RemoteAction> userActions)
Sets the user actions. If there are more than getMaxNumPictureInPictureActions actions, then the input listwill be truncated to that number.
- Parameters:
userActions
- the new actions to show in the picture-in-picture menu.
-
setSourceRectHint
PictureInPictureManager setSourceRectHint(@Nullable() Rect sourceRectHint)
Sets the source bounds hint. These bounds are only used when an activity first enterspicture-in-picture, and describe the bounds in window coordinates of activity enteringpicture-in-picture that will be visible following the transition. For the best effect,these bounds should also match the aspect ratio in the arguments.
- Parameters:
sourceRectHint
- window-coordinate bounds indicating the area of the activity thatwill still be visible following the transition into picture-in-picture (eg.
-
setClosedCaptionsEnabled
PictureInPictureManager setClosedCaptionsEnabled(boolean closedCaptionsEnabled)
Enables or disables closed captions for Picture in Picture mode.
- Parameters:
closedCaptionsEnabled
- true to enable closed captions.
-
setOnUserLeaveEnabled
PictureInPictureManager setOnUserLeaveEnabled(boolean onUserLeaveEnabled)
Enables or disables entering into Picture in Picture mode when the user has put the activity inthe background, for example, when of pressing the Home key.
- Parameters:
onUserLeaveEnabled
- true to enable.
-
getInstance
static PictureInPictureManager getInstance()
-
registerActivity
void registerActivity(@NonNull() Activity activity, @NonNull() BaseVideoView videoView)
This method registers and holds a weak reference to the Activitythat will be put into Picture-in-Picture mode.You can have only one registered Activity at a time.This method is only supported for Android versions equal or greater than O,otherwise the method will not do anything.
- Parameters:
activity
- the ActivityvideoView
- the BaseVideoView
-
unregisterActivity
void unregisterActivity(Activity activity)
Unregister the previously registered activity and clean its references.
- Parameters:
activity
- the activity to unregister.
-
enterPictureInPictureMode
void enterPictureInPictureMode()
This method puts the registered Activity into Picture-in-Picture mode.This method is only supported for Android versions equal or greater than O,otherwise the method will not do anything.
-
isInPictureInPictureMode
boolean isInPictureInPictureMode()
Checks if there is a registered activity and calls that activitymethod isInPictureInPictureMode.This only applies for Android Oreo or higher, otherwise it will always return false.
-
isPictureInPictureEnabled
boolean isPictureInPictureEnabled()
PictureInPictureManager will be disabled if there is no Activity registered orif the Activity previously registered was destroyed.This only applies for Android Oreo or higher, otherwise it will always return false.PictureInPictureManager will be temporarily disabled if the current videois a 360 video, which is currently not supported in Picture-in-Picture mode.
-
onUserLeaveHint
void onUserLeaveHint()
This method calls enterPictureInPictureMode if the PictureInPictureManager is configuredto do so. You can enable this behavior by calling setOnUserLeaveEnabled to true.By Default this behavior is disabled.This method must be called from the onUserLeaveHint method.
-
onPictureInPictureModeChanged
void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig)
This method reacts to the Picture-in-Picture changes and emits DID_ENTER_PICTURE_IN_PICTURE_MODE and DID_EXIT_PICTURE_IN_PICTURE_MODE events.This method must be called from the onPictureInPictureModeChanged ()} method.
- Parameters:
isInPictureInPictureMode
- true if it is in Picture-inPicture mode.newConfig
- the new configuration.
-
getBrightcovePictureInPictureParams
BrightcovePictureInPictureParams getBrightcovePictureInPictureParams()
-
setClosedCaptionsReductionScaleFactor
PictureInPictureManager setClosedCaptionsReductionScaleFactor(float scaleFactor)
Sets reduction the scale factor for closed captions when enteringPicture in Picture mode.The values accepted must be between 0 and 1.
- Parameters:
scaleFactor
- the scale factor
-
-
-
-