It's happening now, watch the livestream.

PlaybackSupportFragment

open class PlaybackSupportFragment : Fragment
kotlin.Any
   ↳ androidx.fragment.app.Fragment
   ↳ androidx.leanback.app.PlaybackSupportFragment

A fragment for displaying playback controls and related content.

A PlaybackSupportFragment renders the elements of its ObjectAdapter as a set of rows in a vertical list. The Adapter's PresenterSelector must maintain subclasses of RowPresenter.

A playback row is a row rendered by PlaybackRowPresenter. App can call setPlaybackRow(Row) to set playback row for the first element of adapter. App can call setPlaybackRowPresenter(PlaybackRowPresenter) to set presenter for it. setPlaybackRow(Row) and setPlaybackRowPresenter(PlaybackRowPresenter) are optional, app can pass playback row and PlaybackRowPresenter in the adapter using setAdapter(ObjectAdapter).

Hiding and showing controls: the controls are initially visible and automatically show/hide when play/pause or user interacts with fragment.

  • App may manually call showControlsOverlay(boolean) or hideControlsOverlay(boolean) to show or hide the controls.
  • The controls are visible by default upon onViewCreated(). To make it initially invisible, call hideControlsOverlay(false) in overridden onViewCreated().
  • Upon play or pause, PlaybackControlGlue or PlaybackTransportControlGlue will fade-in the controls and automatically fade out after a delay customized by R.attr#playbackControlsAutoHideTimeout. To disable the fade in and fade out behavior: call #setControlsOverlayAutoHideEnabled(boolean) with false.
  • Upon user interaction event, fragment will fade-in the controls and automatically fade out after a delay customized by R.attr#playbackControlsAutoHideTickleTimeout. To disable the fade in and fade out behavior, call with false.

Summary

Constants

static Int

A dark translucent background.

static Int

A light translucent background.

static Int

No background.

Public constructors

Public methods

open Unit

Fades out the playback overlay immediately.

open ObjectAdapter!

open Int

Returns the background type.

open ProgressBarManager!

Returns the ProgressBarManager that will show or hide progress bar in onBufferingStateChanged(boolean).

open Unit

Hide controls overlay.

open Boolean

Returns true if controls will be auto hidden after a delay when fragment is resumed.

open Boolean

Returns true if controls overlay is visible, false otherwise.

open Boolean

open Boolean

Returns true if showing and auto-hiding controls when user interacts; false otherwise.

open Unit

Updates the ui when the row data changes.

open Unit
onCreate(savedInstanceState: Bundle?)

open View?
onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?)

open Unit

open Unit

open Unit

open Unit

open Unit

open Unit

open Unit
onViewCreated(@NonNull view: View, @Nullable savedInstanceState: Bundle?)

open Unit

Sets the list of rows for the fragment.

open Unit

Sets the background type.

open Unit

Enables or disables auto hiding controls overlay after a short delay fragment is resumed.

open Unit

open Unit

Sets the PlaybackGlueHost.HostCallback.

open Unit

This listener is called every time there is a click in RowsSupportFragment.

open Unit

This listener is called every time there is a selection in RowsSupportFragment.

Unit

Sets the input event handler.

open Unit

Sets the BaseOnItemViewClickedListener that would be invoked for clicks only on androidx.leanback.widget.PlaybackRowPresenter.ViewHolder.

open Unit

Sets the playback row for the playback controls.

open Unit

Sets the presenter for rendering the playback row set by setPlaybackRow(Row).

open Unit

Interface to be implemented by UI widget to support PlaybackSeekUi.

open Unit

Sets the selected row position with smooth animation.

open Unit
setSelectedPosition(position: Int, smooth: Boolean)

Sets the selected row position.

open Unit
setShowOrHideControlsOverlayOnUserInteraction(showOrHideControlsOverlayOnUserInteraction: Boolean)

Enables or disables showing and auto-hiding controls when user interacts.

open Unit

Show controls overlay.

open Unit

Tickles the playback controls.

Protected methods

open Unit

Called when media has start or stop buffering.

open Unit
onError(errorCode: Int, errorMessage: CharSequence!)

Called when media has error.

open Unit
onVideoSizeChanged(videoWidth: Int, videoHeight: Int)

Called when size of the video changes.

Inherited functions

Constants

BG_DARK

static val BG_DARK: Int

A dark translucent background.

Value: 1

BG_LIGHT

static val BG_LIGHT: Int

A light translucent background.

Value: 2

BG_NONE

static val BG_NONE: Int

No background.

Value: 0

Public constructors

<init>

PlaybackSupportFragment()

Public methods

fadeOut

open fun fadeOut(): Unit

Deprecated: Call hideControlsOverlay(boolean)

Fades out the playback overlay immediately.

getAdapter

open fun getAdapter(): ObjectAdapter!

getBackgroundType

open fun getBackgroundType(): Int

Returns the background type.

getProgressBarManager

open fun getProgressBarManager(): ProgressBarManager!

Returns the ProgressBarManager that will show or hide progress bar in onBufferingStateChanged(boolean).

Return
ProgressBarManager!: The ProgressBarManager that will show or hide progress bar in onBufferingStateChanged(boolean).

hideControlsOverlay

open fun hideControlsOverlay(runAnimation: Boolean): Unit

Hide controls overlay.

Parameters
runAnimation Boolean: True to run animation, false otherwise.

isControlsOverlayAutoHideEnabled

open fun isControlsOverlayAutoHideEnabled(): Boolean

Returns true if controls will be auto hidden after a delay when fragment is resumed.

isControlsOverlayVisible

open fun isControlsOverlayVisible(): Boolean

Returns true if controls overlay is visible, false otherwise.

Return
Boolean: True if controls overlay is visible, false otherwise.

isFadingEnabled

open fun isFadingEnabled(): Boolean

Deprecated: Uses isControlsOverlayAutoHideEnabled()

isShowOrHideControlsOverlayOnUserInteraction

open fun isShowOrHideControlsOverlayOnUserInteraction(): Boolean

Returns true if showing and auto-hiding controls when user interacts; false otherwise.

notifyPlaybackRowChanged

open fun notifyPlaybackRowChanged(): Unit

Updates the ui when the row data changes.

onCreate

open fun onCreate(savedInstanceState: Bundle?): Unit

onCreateView

open fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View?

onDestroy

open fun onDestroy(): Unit

onDestroyView

open fun onDestroyView(): Unit

onPause

open fun onPause(): Unit

onResume

open fun onResume(): Unit

onStart

open fun onStart(): Unit

onStop

open fun onStop(): Unit

onViewCreated

open fun onViewCreated(@NonNull view: View, @Nullable savedInstanceState: Bundle?): Unit

setAdapter

open fun setAdapter(adapter: ObjectAdapter!): Unit

Sets the list of rows for the fragment. A default ClassPresenterSelector will be created if ObjectAdapter#getPresenterSelector() is null. if user provides setPlaybackRow(Row) and setPlaybackRowPresenter(PlaybackRowPresenter), the row and presenter will be set onto the adapter.

Parameters
adapter ObjectAdapter!: The adapter that contains related rows and optional playback row.

setBackgroundType

open fun setBackgroundType(type: Int): Unit

Sets the background type.

Parameters
type Int: One of BG_LIGHT, BG_DARK, or BG_NONE.

setControlsOverlayAutoHideEnabled

open fun setControlsOverlayAutoHideEnabled(enabled: Boolean): Unit

Enables or disables auto hiding controls overlay after a short delay fragment is resumed. If enabled and fragment is resumed, the view will fade out after a time period. User interaction will kill the timer, next time fragment is resumed, the timer will be started again if isControlsOverlayAutoHideEnabled() is true.

In most cases app should not directly call setControlsOverlayAutoHideEnabled() as it's called by androidx.leanback.media.PlaybackBaseControlGlue on play or pause.

setFadingEnabled

open fun setFadingEnabled(enabled: Boolean): Unit

Deprecated: Uses setControlsOverlayAutoHideEnabled(boolean)

setHostCallback

open fun setHostCallback(hostCallback: PlaybackGlueHost.HostCallback!): Unit

Sets the PlaybackGlueHost.HostCallback. Implementor of this interface will take appropriate actions to take action when the hosting fragment starts/stops processing.

setOnItemViewClickedListener

open fun setOnItemViewClickedListener(listener: BaseOnItemViewClickedListener<Any!>!): Unit

This listener is called every time there is a click in RowsSupportFragment. This can be used by users to take additional actions such as animations.

setOnItemViewSelectedListener

open fun setOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener<Any!>!): Unit

This listener is called every time there is a selection in RowsSupportFragment. This can be used by users to take additional actions such as animations.

setOnKeyInterceptListener

fun setOnKeyInterceptListener(handler: OnKeyListener!): Unit

Sets the input event handler.

setOnPlaybackItemViewClickedListener

open fun setOnPlaybackItemViewClickedListener(listener: BaseOnItemViewClickedListener<Any!>!): Unit

Sets the BaseOnItemViewClickedListener that would be invoked for clicks only on androidx.leanback.widget.PlaybackRowPresenter.ViewHolder.

setPlaybackRow

open fun setPlaybackRow(row: Row!): Unit

Sets the playback row for the playback controls. The row will be set as first element of adapter if the adapter is ArrayObjectAdapter or SparseArrayObjectAdapter.

Parameters
row Row!: The row that represents the playback.

setPlaybackRowPresenter

open fun setPlaybackRowPresenter(presenter: PlaybackRowPresenter!): Unit

Sets the presenter for rendering the playback row set by setPlaybackRow(Row). If adapter does not set a PresenterSelector, setAdapter(ObjectAdapter) will create a ClassPresenterSelector by default and map from the row object class to this PlaybackRowPresenter.

Parameters
presenter PlaybackRowPresenter!: Presenter used to render setPlaybackRow(Row).

setPlaybackSeekUiClient

open fun setPlaybackSeekUiClient(client: PlaybackSeekUi.Client!): Unit

Interface to be implemented by UI widget to support PlaybackSeekUi.

setSelectedPosition

open fun setSelectedPosition(position: Int): Unit

Sets the selected row position with smooth animation.

setSelectedPosition

open fun setSelectedPosition(position: Int, smooth: Boolean): Unit

Sets the selected row position.

setShowOrHideControlsOverlayOnUserInteraction

open fun setShowOrHideControlsOverlayOnUserInteraction(showOrHideControlsOverlayOnUserInteraction: Boolean): Unit

Enables or disables showing and auto-hiding controls when user interacts. Enabled by default. Auto-hide timer length is defined by R.attr#playbackControlsAutoHideTickleTimeout.

showControlsOverlay

open fun showControlsOverlay(runAnimation: Boolean): Unit

Show controls overlay.

Parameters
runAnimation Boolean: True to run animation, false otherwise.

tickle

open fun tickle(): Unit

Tickles the playback controls. Fades in the view if it was faded out. tickle() will kill and re-create a timer if R.attr#playbackControlsAutoHideTickleTimeout is positive.

In most cases app does not need call tickle() as it's automatically called on user interactions.

Protected methods

onBufferingStateChanged

protected open fun onBufferingStateChanged(start: Boolean): Unit

Called when media has start or stop buffering. App may override. The default initial state is not buffering.

Parameters
start Boolean: True for buffering start, false otherwise.

onError

protected open fun onError(errorCode: Int, errorMessage: CharSequence!): Unit

Called when media has error. App may override.

Parameters
errorCode Int: Optional error code for specific implementation.
errorMessage Int: Optional error message for specific implementation.

onVideoSizeChanged

protected open fun onVideoSizeChanged(videoWidth: Int, videoHeight: Int): Unit

Called when size of the video changes. App may override.

Parameters
videoWidth Int: Intrinsic width of video
videoHeight Int: Intrinsic height of video