MKPictureInPictureApi

interface MKPictureInPictureApi: Any

Represents the base functions required by MKPlayer to enable and handle Picture-In-Picture mode.

To implement PictureInPicture in application, please make manifest changes as mentioned in https://developer.android.com/guide/topics/ui/picture-in-picture

To use MKPlayer api's to enter Picture-in-picture mode please see below code snippet


val configuration = MKPlayerConfiguration()

// Pass as true if Bitmovin UI is required
this.configuration!!.isUiEnabled = false

// Enable Pip
this.configuration?.isPictureInPictureEnabled = true

val mkplayer = MKPlayer(
applicationContext,
pip_rootView,
configuration!!
)

// Pass activity to create Pip Handler
mkplayer.setPictureInPictureHandler(this)

// Call enterPictureInPicture on user action of minimise or
// while leaving activity in onUserLeavingHint().
mkplayer.enterPictureInPicture()

In Activity override onPictureInPictureModeChanged method, which is called by the system when the activity changes to and from picture-in-picture mode, inside call onPictureInPictureModeChanged method.



override fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean, newConfig: Configuration
) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)

mkplayer.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
}

Fields

Name Description
abstract isPictureInPictureAvailable: Boolean

Whether Picture-In-Picture (PiP) mode is available.

abstract isPictureInPicture: Boolean

Whether the view is currently in Picture-In-Picture (PiP) mode.

Methods

enterPictureInPicture

abstract fun enterPictureInPicture()

Puts the view into Picture-In-Picture (PiP) mode. Has no effect if isPictureInPictureAvailable is false or if the view is already in PiP mode.

ReturnValue

Name Description
Unit

exitPictureInPicture

abstract fun exitPictureInPicture()

Pulls the view out of Picture-In-Picture (PiP) mode. Has no effect if isPictureInPictureAvailable is false or if the view is currently not in PiP mode.

ReturnValue

Name Description
Unit

onPictureInPictureModeChanged

abstract fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?)

When using Picture-in-Picture feature, this method has to be called from Activity.

Parameters

Name Description
isInPictureInPictureMode: Boolean

True if the activity is in picture-in-picture mode.

newConfig: Configuration?

The new configuration of the activity with the state

ReturnValue

Name Description
Unit