Android 12 Developer Preview is here! Try it out, and give us your feedback!

PlaybackGlue

abstract class PlaybackGlue
kotlin.Any
   ↳ androidx.leanback.media.PlaybackGlue

Base class for abstraction of media play/pause feature. A subclass of PlaybackGlue will contain implementation of Media Player or a connection to playback Service. App initializes PlaybackGlue subclass, associated it with a PlaybackGlueHost. PlaybackGlueHost is typically implemented by a Fragment or an Activity, it provides the environment to render UI for PlaybackGlue object, it optionally provides SurfaceHolder via SurfaceHolderGlueHost to render video. A typical PlaybackGlue should release resources (e.g. MediaPlayer or connection to playback Service) in onDetachedFromHost(). onDetachedFromHost() is called in two cases:

In rare case if an PlaybackGlue wants to live outside fragment / activity life cycle, it may manages resource release by itself.

Summary

Nested classes
abstract

Interface to allow clients to take action once the video is ready to play and start stop.

Public constructors
<init>(context: Context!)

Constructor.

Public methods
open Unit

Add a PlayerCallback.

open Context!

Returns the context.

open PlaybackGlueHost!

open Boolean

Returns true if media is currently playing.

open Boolean

Returns true when the media player is prepared to start media playback.

open Unit

Goes to the next media item.

open Unit

Pauses the media player.

open Unit

Starts the media player.

open Unit

Starts play when isPrepared() becomes true.

open Unit

Goes to the previous media item.

open Unit

Remove a PlayerCallback.

Unit

This method is used to associate a PlaybackGlue with the PlaybackGlueHost which provides UI and optional SurfaceHolderGlueHost.

Protected methods
open MutableList<PlaybackGlue.PlayerCallback!>!

open Unit

This method is called attached to associated PlaybackGlueHost.

open Unit

This method is called when current associated PlaybackGlueHost is attached to a different PlaybackGlue or PlaybackGlueHost is destroyed .

open Unit

This method is called when PlaybackGlueHost is paused.

open Unit

This method is called when PlaybackGlueHost is resumed.

open Unit

This method is called when PlaybackGlueHost is started.

open Unit

This method is called when PlaybackGlueHost is stopped.

Public constructors

<init>

PlaybackGlue(context: Context!)

Constructor.

Public methods

addPlayerCallback

open fun addPlayerCallback(playerCallback: PlaybackGlue.PlayerCallback!): Unit

Add a PlayerCallback.

Parameters
playerCallback PlaybackGlue.PlayerCallback!: The callback to add.

getContext

open fun getContext(): Context!

Returns the context.

getHost

open fun getHost(): PlaybackGlueHost!
Return
PlaybackGlueHost! Associated PlaybackGlueHost or null if not attached to host.