attachBackgroundHandling

fun KitePlayerPlatform.attachBackgroundHandling(player: KitePlayer, context: Context, policy: BackgroundPolicy = BackgroundPolicy.ContinueAudio): AutoCloseable

Deprecated

Use KitePlayer.attachMediaSession, which owns this part and closes with the player.

Stops player decoding video for a screen nobody is looking at.

Follows started activities through the application's own callbacks, so no lifecycle library is added and the application registers nothing itself. No started activity means the application is in the background. Attaching after an activity started, from onResume or from a composable, works too: the process importance at attach time says whether one was already on screen.

With BackgroundPolicy.ContinueAudio, this handle only parks the picture, so sound in the background also needs the media notification to keep the process alive.

Throws

when context does not belong to an Application.

fun KitePlayerPlatform.attachBackgroundHandling(player: KitePlayer, policy: BackgroundPolicy = BackgroundPolicy.ContinueAudio): AutoCloseable

Deprecated

Use KitePlayer.attachMediaSession, which owns this part and closes with the player.

Stops player decoding video for a screen nobody is looking at.

Watches the two application state notifications. Nothing is registered in the app's own delegate, and nothing is required of it beyond the background audio capability when the policy is BackgroundPolicy.ContinueAudio.

Close the handle with the player.


fun KitePlayerPlatform.attachBackgroundHandling(player: KitePlayer, policy: BackgroundPolicy = BackgroundPolicy.ContinueAudio, pictureInPicture: KitePlayerPictureInPicture?): AutoCloseable

Deprecated

Use KitePlayer.attachMediaSession, which owns this part and closes with the player.

Stops player decoding video for a screen nobody is looking at, and keeps it on while the small window of pictureInPicture shows.

The viewer still watches the picture in that window, so leaving the app parks nothing while it shows. When the window closes while the app is away, the policy acts then, and coming back undoes it as usual. A window the system opens after the app has left brings parked video back.

Null behaves exactly as the overload without it. Close the handle with the player.