PlaybackFragment

Added in 1.1.0
Deprecated in 1.1.0

class PlaybackFragment : Fragment

Known direct subclasses
VideoFragment

This class is deprecated.

use VideoSupportFragment


A fragment for displaying playback controls and related content.

A PlaybackFragment 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 to set playback row for the first element of adapter. App can call setPlaybackRowPresenter to set presenter for it. setPlaybackRow and setPlaybackRowPresenter are optional, app can pass playback row and PlaybackRowPresenter in the adapter using setAdapter.

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

Summary

Constants

const Int

A dark translucent background.

const Int

A light translucent background.

const Int

No background.

Public constructors

Public functions

Unit

This function is deprecated.

Call hideControlsOverlay

ObjectAdapter!
Int

Returns the background type.

ProgressBarManager!

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

Unit

Hide controls overlay.

Boolean

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

Boolean

Returns true if controls overlay is visible, false otherwise.

Boolean

This function is deprecated.

Uses isControlsOverlayAutoHideEnabled

Boolean

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

Unit

Updates the ui when the row data changes.

Unit
onCreate(savedInstanceState: Bundle!)

This function is deprecated.

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

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
onViewCreated(view: View, savedInstanceState: Bundle?)

This function is deprecated.

Unit

Sets the list of rows for the fragment.

Unit

Sets the background type.

Unit

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

Unit

This function is deprecated.

Uses setControlsOverlayAutoHideEnabled

Unit

Sets the PlaybackGlueHost.HostCallback.

Unit

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

Unit

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

Unit

Sets the input event handler.

Unit

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

Unit

Sets the playback row for the playback controls.

Unit

Sets the presenter for rendering the playback row set by setPlaybackRow.

Unit

Interface to be implemented by UI widget to support PlaybackSeekUi.

Unit

Sets the selected row position with smooth animation.

Unit
setSelectedPosition(position: Int, smooth: Boolean)

Sets the selected row position.

Unit
setShowOrHideControlsOverlayOnUserInteraction(
    showOrHideControlsOverlayOnUserInteraction: Boolean
)

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

Unit

Show controls overlay.

Unit

Tickles the playback controls.

Protected functions

Unit

Called when media has start or stop buffering.

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

Called when media has error.

Unit
onVideoSizeChanged(videoWidth: Int, videoHeight: Int)

Called when size of the video changes.

Inherited functions

From android.app.Fragment
Unit
dump(
    prefix: String!,
    fd: FileDescriptor!,
    writer: PrintWriter!,
    args: Array<String!>!
)

This function is deprecated.

Boolean
equals(o: Any!)

This function is deprecated.

Activity!

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Bundle!

This function is deprecated.

FragmentManager!

This function is deprecated.

Context!

This function is deprecated.

Transition!

This function is deprecated.

Transition!

This function is deprecated.

FragmentManager!

This function is deprecated.

Any!

This function is deprecated.

Int

This function is deprecated.

LayoutInflater!

This function is deprecated.

LoaderManager!

This function is deprecated.

Fragment!

This function is deprecated.

Transition!

This function is deprecated.

Resources!

This function is deprecated.

Boolean

This function is deprecated.

Transition!

This function is deprecated.

Transition!

This function is deprecated.

Transition!

This function is deprecated.

String!
getString(resId: Int)

This function is deprecated.

String!

This function is deprecated.

Fragment!

This function is deprecated.

Int

This function is deprecated.

CharSequence!
getText(resId: Int)

This function is deprecated.

Boolean

This function is deprecated.

View!

This function is deprecated.

Int

This function is deprecated.

java-static Fragment!
instantiate(context: Context!, fname: String!)

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Unit
onActivityCreated(savedInstanceState: Bundle!)

This function is deprecated.

Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent!)

This function is deprecated.

Unit
onAttach(context: Context!)

This function is deprecated.

Unit
onAttachFragment(childFragment: Fragment!)

This function is deprecated.

Unit

This function is deprecated.

Boolean

This function is deprecated.

Animator!
onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int)

This function is deprecated.

Unit
onCreateContextMenu(
    menu: ContextMenu!,
    v: View!,
    menuInfo: ContextMenu.ContextMenuInfo!
)

This function is deprecated.

Unit
onCreateOptionsMenu(menu: Menu!, inflater: MenuInflater!)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

LayoutInflater!
onGetLayoutInflater(savedInstanceState: Bundle!)

This function is deprecated.

Unit

This function is deprecated.

Unit
onInflate(attrs: AttributeSet!, savedInstanceState: Bundle!)

This function is deprecated.

Unit

This function is deprecated.

Unit
onMultiWindowModeChanged(
    isInMultiWindowMode: Boolean,
    newConfig: Configuration!
)

This function is deprecated.

Boolean

This function is deprecated.

Unit

This function is deprecated.

Unit
onPictureInPictureModeChanged(
    isInPictureInPictureMode: Boolean,
    newConfig: Configuration!
)

This function is deprecated.

Unit

This function is deprecated.

Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>!,
    grantResults: IntArray!
)

This function is deprecated.

Unit

This function is deprecated.

Unit
onTrimMemory(level: Int)

This function is deprecated.

Unit
onViewStateRestored(savedInstanceState: Bundle!)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
requestPermissions(permissions: Array<String!>!, requestCode: Int)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
setMenuVisibility(menuVisible: Boolean)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
setTargetFragment(fragment: Fragment!, requestCode: Int)

This function is deprecated.

Unit
setUserVisibleHint(isVisibleToUser: Boolean)

This function is deprecated.

Boolean

This function is deprecated.

Unit

This function is deprecated.

Unit
startActivityForResult(intent: Intent!, requestCode: Int)

This function is deprecated.

Unit
startIntentSenderForResult(
    intent: IntentSender!,
    requestCode: Int,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle!
)

This function is deprecated.

Unit

This function is deprecated.

String!

This function is deprecated.

Unit

This function is deprecated.

Constants

BG_DARK

Added in 1.1.0
Deprecated in 1.1.0
const val BG_DARK = 1: Int

A dark translucent background.

BG_LIGHT

Added in 1.1.0
Deprecated in 1.1.0
const val BG_LIGHT = 2: Int

A light translucent background.

BG_NONE

Added in 1.1.0
Deprecated in 1.1.0
const val BG_NONE = 0: Int

No background.

Public constructors

PlaybackFragment

Added in 1.1.0
Deprecated in 1.1.0
PlaybackFragment()

Public functions

fadeOut

Added in 1.1.0
Deprecated in 1.1.0
fun fadeOut(): Unit

Fades out the playback overlay immediately.

getAdapter

Added in 1.1.0
Deprecated in 1.1.0
fun getAdapter(): ObjectAdapter!

getBackgroundType

Added in 1.1.0
Deprecated in 1.1.0
fun getBackgroundType(): Int

Returns the background type.

getProgressBarManager

Added in 1.1.0
Deprecated in 1.1.0
fun getProgressBarManager(): ProgressBarManager!

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

Returns
ProgressBarManager!

The ProgressBarManager that will show or hide progress bar in onBufferingStateChanged.

hideControlsOverlay

Added in 1.1.0
Deprecated in 1.1.0
fun hideControlsOverlay(runAnimation: Boolean): Unit

Hide controls overlay.

Parameters
runAnimation: Boolean

True to run animation, false otherwise.

isControlsOverlayAutoHideEnabled

Added in 1.1.0
Deprecated in 1.1.0
fun isControlsOverlayAutoHideEnabled(): Boolean

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

isControlsOverlayVisible

Added in 1.1.0
Deprecated in 1.1.0
fun isControlsOverlayVisible(): Boolean

Returns true if controls overlay is visible, false otherwise.

Returns
Boolean

True if controls overlay is visible, false otherwise.

isFadingEnabled

Added in 1.1.0
Deprecated in 1.1.0
fun isFadingEnabled(): Boolean

isShowOrHideControlsOverlayOnUserInteraction

Added in 1.1.0
Deprecated in 1.1.0
fun isShowOrHideControlsOverlayOnUserInteraction(): Boolean

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

notifyPlaybackRowChanged

Added in 1.1.0
Deprecated in 1.1.0
fun notifyPlaybackRowChanged(): Unit

Updates the ui when the row data changes.

onCreate

Added in 1.1.0
Deprecated in 1.1.0
fun onCreate(savedInstanceState: Bundle!): Unit

onCreateView

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateView(
    inflater: LayoutInflater!,
    container: ViewGroup?,
    savedInstanceState: Bundle!
): View?

onDestroy

Added in 1.1.0
Deprecated in 1.1.0
fun onDestroy(): Unit

onDestroyView

Added in 1.1.0
Deprecated in 1.1.0
fun onDestroyView(): Unit

onPause

Added in 1.1.0
Deprecated in 1.1.0
fun onPause(): Unit

onResume

Added in 1.1.0
Deprecated in 1.1.0
fun onResume(): Unit

onStart

Added in 1.1.0
Deprecated in 1.1.0
fun onStart(): Unit

onStop

Added in 1.1.0
Deprecated in 1.1.0
fun onStop(): Unit

onViewCreated

Added in 1.1.0
Deprecated in 1.1.0
fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit

setAdapter

Added in 1.1.0
Deprecated in 1.1.0
fun setAdapter(adapter: ObjectAdapter!): Unit

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

Parameters
adapter: ObjectAdapter!

The adapter that contains related rows and optional playback row.

setBackgroundType

Added in 1.1.0
Deprecated in 1.1.0
fun setBackgroundType(type: Int): Unit

Sets the background type.

Parameters
type: Int

One of BG_LIGHT, BG_DARK, or BG_NONE.

setControlsOverlayAutoHideEnabled

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
Deprecated in 1.1.0
fun setFadingEnabled(enabled: Boolean): Unit

setHostCallback

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
Deprecated in 1.1.0
fun setOnItemViewClickedListener(listener: BaseOnItemViewClickedListener!): Unit

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

setOnItemViewSelectedListener

Added in 1.1.0
Deprecated in 1.1.0
fun setOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener!): Unit

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

setOnKeyInterceptListener

Added in 1.1.0
Deprecated in 1.1.0
fun setOnKeyInterceptListener(handler: View.OnKeyListener!): Unit

Sets the input event handler.

setOnPlaybackItemViewClickedListener

Added in 1.1.0
Deprecated in 1.1.0
fun setOnPlaybackItemViewClickedListener(
    listener: BaseOnItemViewClickedListener!
): Unit

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

setPlaybackRow

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
Deprecated in 1.1.0
fun setPlaybackRowPresenter(presenter: PlaybackRowPresenter!): Unit

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

Parameters
presenter: PlaybackRowPresenter!

Presenter used to render setPlaybackRow.

setPlaybackSeekUiClient

Added in 1.1.0
Deprecated in 1.1.0
fun setPlaybackSeekUiClient(client: PlaybackSeekUi.Client!): Unit

Interface to be implemented by UI widget to support PlaybackSeekUi.

setSelectedPosition

Added in 1.1.0
Deprecated in 1.1.0
fun setSelectedPosition(position: Int): Unit

Sets the selected row position with smooth animation.

setSelectedPosition

Added in 1.1.0
Deprecated in 1.1.0
fun setSelectedPosition(position: Int, smooth: Boolean): Unit

Sets the selected row position.

setShowOrHideControlsOverlayOnUserInteraction

Added in 1.1.0
Deprecated in 1.1.0
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 playbackControlsAutoHideTickleTimeout.

showControlsOverlay

Added in 1.1.0
Deprecated in 1.1.0
fun showControlsOverlay(runAnimation: Boolean): Unit

Show controls overlay.

Parameters
runAnimation: Boolean

True to run animation, false otherwise.

tickle

Added in 1.1.0
Deprecated in 1.1.0
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 playbackControlsAutoHideTickleTimeout is positive.

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

Protected functions

onBufferingStateChanged

Added in 1.1.0
Deprecated in 1.1.0
protected 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

Added in 1.1.0
Deprecated in 1.1.0
protected 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: CharSequence!

Optional error message for specific implementation.

onVideoSizeChanged

Added in 1.1.0
Deprecated in 1.1.0
protected 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