PlaybackFragment

Added in 1.1.0
Deprecated in 1.1.0

public class PlaybackFragment extends 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

static final int

A dark translucent background.

static final int

A light translucent background.

static final int

No background.

Public constructors

Public methods

void

This method is deprecated.

Call hideControlsOverlay

ObjectAdapter
int

Returns the background type.

ProgressBarManager

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

void
hideControlsOverlay(boolean runAnimation)

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 method is deprecated.

Uses isControlsOverlayAutoHideEnabled

boolean

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

void

Updates the ui when the row data changes.

void
onCreate(Bundle savedInstanceState)

This method is deprecated.

@Nullable View
onCreateView(
    LayoutInflater inflater,
    @Nullable ViewGroup container,
    Bundle savedInstanceState
)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)

This method is deprecated.

void

Sets the list of rows for the fragment.

void

Sets the background type.

void

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

void
setFadingEnabled(boolean enabled)

This method is deprecated.

Uses setControlsOverlayAutoHideEnabled

void

Sets the PlaybackGlueHost.HostCallback.

void

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

void

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

final void

Sets the input event handler.

void

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

void

Sets the playback row for the playback controls.

void

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

void

Interface to be implemented by UI widget to support PlaybackSeekUi.

void
setSelectedPosition(int position)

Sets the selected row position with smooth animation.

void
setSelectedPosition(int position, boolean smooth)

Sets the selected row position.

void
setShowOrHideControlsOverlayOnUserInteraction(
    boolean showOrHideControlsOverlayOnUserInteraction
)

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

void
showControlsOverlay(boolean runAnimation)

Show controls overlay.

void

Tickles the playback controls.

Protected methods

void
onBufferingStateChanged(boolean start)

Called when media has start or stop buffering.

void
onError(int errorCode, CharSequence errorMessage)

Called when media has error.

void
onVideoSizeChanged(int videoWidth, int videoHeight)

Called when size of the video changes.

Inherited Constants

From android.content.ComponentCallbacks2
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Inherited methods

From android.app.Fragment
void
dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

This method is deprecated.

final boolean

This method is deprecated.

final Activity

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

final Bundle

This method is deprecated.

final FragmentManager

This method is deprecated.

Context

This method is deprecated.

Transition

This method is deprecated.

Transition

This method is deprecated.

final FragmentManager

This method is deprecated.

final Object

This method is deprecated.

final int

This method is deprecated.

final LayoutInflater

This method is deprecated.

LoaderManager

This method is deprecated.

final Fragment

This method is deprecated.

Transition

This method is deprecated.

final Resources

This method is deprecated.

final boolean

This method is deprecated.

Transition

This method is deprecated.

Transition

This method is deprecated.

Transition

This method is deprecated.

final String
getString(int resId)

This method is deprecated.

final String

This method is deprecated.

final Fragment

This method is deprecated.

final int

This method is deprecated.

final CharSequence
getText(int resId)

This method is deprecated.

boolean

This method is deprecated.

View

This method is deprecated.

final int

This method is deprecated.

static Fragment
instantiate(Context context, String fname)

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

void
onActivityCreated(Bundle savedInstanceState)

This method is deprecated.

void
onActivityResult(int requestCode, int resultCode, Intent data)

This method is deprecated.

void
onAttach(Context context)

This method is deprecated.

void
onAttachFragment(Fragment childFragment)

This method is deprecated.

void

This method is deprecated.

boolean

This method is deprecated.

Animator
onCreateAnimator(int transit, boolean enter, int nextAnim)

This method is deprecated.

void
onCreateContextMenu(
    ContextMenu menu,
    View v,
    ContextMenu.ContextMenuInfo menuInfo
)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

LayoutInflater
onGetLayoutInflater(Bundle savedInstanceState)

This method is deprecated.

void
onHiddenChanged(boolean hidden)

This method is deprecated.

void
onInflate(AttributeSet attrs, Bundle savedInstanceState)

This method is deprecated.

void

This method is deprecated.

void
onMultiWindowModeChanged(
    boolean isInMultiWindowMode,
    Configuration newConfig
)

This method is deprecated.

boolean

This method is deprecated.

void

This method is deprecated.

void
onPictureInPictureModeChanged(
    boolean isInPictureInPictureMode,
    Configuration newConfig
)

This method is deprecated.

void

This method is deprecated.

void
onRequestPermissionsResult(
    int requestCode,
    String[] permissions,
    int[] grantResults
)

This method is deprecated.

void

This method is deprecated.

void
onTrimMemory(int level)

This method is deprecated.

void
onViewStateRestored(Bundle savedInstanceState)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

final void
requestPermissions(String[] permissions, int requestCode)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
setHasOptionsMenu(boolean hasMenu)

This method is deprecated.

void

This method is deprecated.

void
setMenuVisibility(boolean menuVisible)

This method is deprecated.

void

This method is deprecated.

void
setRetainInstance(boolean retain)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
setTargetFragment(Fragment fragment, int requestCode)

This method is deprecated.

void
setUserVisibleHint(boolean isVisibleToUser)

This method is deprecated.

boolean

This method is deprecated.

void

This method is deprecated.

void
startActivityForResult(Intent intent, int requestCode)

This method is deprecated.

void
startIntentSenderForResult(
    IntentSender intent,
    int requestCode,
    Intent fillInIntent,
    int flagsMask,
    int flagsValues,
    int extraFlags,
    Bundle options
)

This method is deprecated.

void

This method is deprecated.

String

This method is deprecated.

void

This method is deprecated.

Constants

BG_DARK

Added in 1.1.0
Deprecated in 1.1.0
public static final int BG_DARK = 1

A dark translucent background.

BG_LIGHT

Added in 1.1.0
Deprecated in 1.1.0
public static final int BG_LIGHT = 2

A light translucent background.

BG_NONE

Added in 1.1.0
Deprecated in 1.1.0
public static final int BG_NONE = 0

No background.

Public constructors

PlaybackFragment

Added in 1.1.0
Deprecated in 1.1.0
public PlaybackFragment()

Public methods

fadeOut

Added in 1.1.0
Deprecated in 1.1.0
public void fadeOut()

Fades out the playback overlay immediately.

getAdapter

Added in 1.1.0
Deprecated in 1.1.0
public ObjectAdapter getAdapter()

getBackgroundType

Added in 1.1.0
Deprecated in 1.1.0
public int getBackgroundType()

Returns the background type.

getProgressBarManager

Added in 1.1.0
Deprecated in 1.1.0
public ProgressBarManager getProgressBarManager()

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
public void hideControlsOverlay(boolean runAnimation)

Hide controls overlay.

Parameters
boolean runAnimation

True to run animation, false otherwise.

isControlsOverlayAutoHideEnabled

Added in 1.1.0
Deprecated in 1.1.0
public boolean isControlsOverlayAutoHideEnabled()

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
public boolean isControlsOverlayVisible()

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
public boolean isFadingEnabled()

isShowOrHideControlsOverlayOnUserInteraction

Added in 1.1.0
Deprecated in 1.1.0
public boolean isShowOrHideControlsOverlayOnUserInteraction()

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

notifyPlaybackRowChanged

Added in 1.1.0
Deprecated in 1.1.0
public void notifyPlaybackRowChanged()

Updates the ui when the row data changes.

onCreate

Added in 1.1.0
Deprecated in 1.1.0
public void onCreate(Bundle savedInstanceState)

onCreateView

Added in 1.1.0
Deprecated in 1.1.0
public @Nullable View onCreateView(
    LayoutInflater inflater,
    @Nullable ViewGroup container,
    Bundle savedInstanceState
)

onDestroy

Added in 1.1.0
Deprecated in 1.1.0
public void onDestroy()

onDestroyView

Added in 1.1.0
Deprecated in 1.1.0
public void onDestroyView()

onPause

Added in 1.1.0
Deprecated in 1.1.0
public void onPause()

onResume

Added in 1.1.0
Deprecated in 1.1.0
public void onResume()

onStart

Added in 1.1.0
Deprecated in 1.1.0
public void onStart()

onStop

Added in 1.1.0
Deprecated in 1.1.0
public void onStop()

onViewCreated

Added in 1.1.0
Deprecated in 1.1.0
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)

setAdapter

Added in 1.1.0
Deprecated in 1.1.0
public void setAdapter(ObjectAdapter adapter)

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
ObjectAdapter adapter

The adapter that contains related rows and optional playback row.

setBackgroundType

Added in 1.1.0
Deprecated in 1.1.0
public void setBackgroundType(int type)

Sets the background type.

Parameters
int type

One of BG_LIGHT, BG_DARK, or BG_NONE.

setControlsOverlayAutoHideEnabled

Added in 1.1.0
Deprecated in 1.1.0
public void setControlsOverlayAutoHideEnabled(boolean enabled)

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
public void setFadingEnabled(boolean enabled)

setHostCallback

Added in 1.1.0
Deprecated in 1.1.0
public void setHostCallback(PlaybackGlueHost.HostCallback hostCallback)

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
public void setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)

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
public void setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)

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
public final void setOnKeyInterceptListener(View.OnKeyListener handler)

Sets the input event handler.

setOnPlaybackItemViewClickedListener

Added in 1.1.0
Deprecated in 1.1.0
public void setOnPlaybackItemViewClickedListener(
    BaseOnItemViewClickedListener listener
)

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
public void setPlaybackRow(Row row)

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
public void setPlaybackRowPresenter(PlaybackRowPresenter presenter)

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
PlaybackRowPresenter presenter

Presenter used to render setPlaybackRow.

setPlaybackSeekUiClient

Added in 1.1.0
Deprecated in 1.1.0
public void setPlaybackSeekUiClient(PlaybackSeekUi.Client client)

Interface to be implemented by UI widget to support PlaybackSeekUi.

setSelectedPosition

Added in 1.1.0
Deprecated in 1.1.0
public void setSelectedPosition(int position)

Sets the selected row position with smooth animation.

setSelectedPosition

Added in 1.1.0
Deprecated in 1.1.0
public void setSelectedPosition(int position, boolean smooth)

Sets the selected row position.

setShowOrHideControlsOverlayOnUserInteraction

Added in 1.1.0
Deprecated in 1.1.0
public void setShowOrHideControlsOverlayOnUserInteraction(
    boolean showOrHideControlsOverlayOnUserInteraction
)

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
public void showControlsOverlay(boolean runAnimation)

Show controls overlay.

Parameters
boolean runAnimation

True to run animation, false otherwise.

tickle

Added in 1.1.0
Deprecated in 1.1.0
public void tickle()

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 methods

onBufferingStateChanged

Added in 1.1.0
Deprecated in 1.1.0
protected void onBufferingStateChanged(boolean start)

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

Parameters
boolean start

True for buffering start, false otherwise.

onError

Added in 1.1.0
Deprecated in 1.1.0
protected void onError(int errorCode, CharSequence errorMessage)

Called when media has error. App may override.

Parameters
int errorCode

Optional error code for specific implementation.

CharSequence errorMessage

Optional error message for specific implementation.

onVideoSizeChanged

Added in 1.1.0
Deprecated in 1.1.0
protected void onVideoSizeChanged(int videoWidth, int videoHeight)

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

Parameters
int videoWidth

Intrinsic width of video

int videoHeight

Intrinsic height of video