PlaybackFragment
public class PlaybackFragment extends Fragment
VideoFragment |
This class is deprecated. |
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.
- App may manually call
showControlsOverlayorhideControlsOverlayto 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
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
playbackControlsAutoHideTickleTimeout. To disable the fade in and fade out behavior, callsetShowOrHideControlsOverlayOnUserInteractionwith false.
Summary
Constants |
|
|---|---|
static final int |
BG_DARK = 1A dark translucent background. |
static final int |
BG_LIGHT = 2A light translucent background. |
static final int |
BG_NONE = 0No background. |
Public constructors |
|---|
Public methods |
|
|---|---|
void |
This method is deprecated. Call |
ObjectAdapter |
|
int |
Returns the background type. |
ProgressBarManager |
Returns the ProgressBarManager that will show or hide progress bar in |
void |
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. |
boolean |
Returns true if showing and auto-hiding controls when user interacts; false otherwise. |
void |
Updates the ui when the row data changes. |
void |
This method is deprecated. |
@Nullable View |
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 |
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 |
This method is deprecated. |
void |
Sets the |
void |
This listener is called every time there is a click in |
void |
This listener is called every time there is a selection in |
final void |
Sets the input event handler. |
void |
Sets the |
void |
Sets the playback row for the playback controls. |
void |
Sets the presenter for rendering the playback row set by |
void |
Interface to be implemented by UI widget to support PlaybackSeekUi. |
void |
Sets the selected row position with smooth animation. |
void |
Sets the selected row position. |
void |
Enables or disables showing and auto-hiding controls when user interacts. |
void |
Show controls overlay. |
void |
Tickles the playback controls. |
Protected methods |
|
|---|---|
void |
Called when media has start or stop buffering. |
void |
Called when media has error. |
void |
Called when size of the video changes. |
Inherited Constants |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Constants
Public constructors
Public methods
public ProgressBarManagergetProgressBarManager()
Returns the ProgressBarManager that will show or hide progress bar in onBufferingStateChanged.
| Returns | |
|---|---|
ProgressBarManager |
The ProgressBarManager that will show or hide progress bar in |
public void hideControlsOverlay(boolean runAnimation)Hide controls overlay.
| Parameters | |
|---|---|
boolean runAnimation |
True to run animation, false otherwise. |
public boolean isControlsOverlayAutoHideEnabled()Returns true if controls will be auto hidden after a delay when fragment is resumed.
public boolean isControlsOverlayVisible()Returns true if controls overlay is visible, false otherwise.
| Returns | |
|---|---|
boolean |
True if controls overlay is visible, false otherwise. |
| See also | |
|---|---|
showControlsOverlay |
|
hideControlsOverlay |
public boolean isShowOrHideControlsOverlayOnUserInteraction()Returns true if showing and auto-hiding controls when user interacts; false otherwise.
public @Nullable ViewonCreateView(
LayoutInflater inflater,
@Nullable ViewGroup container,
Bundle savedInstanceState
)
public voidsetAdapter(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. |
public void setBackgroundType(int type)Sets the background type.
| Parameters | |
|---|---|
int type |
One of BG_LIGHT, BG_DARK, or BG_NONE. |
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.
public voidsetHostCallback(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.
public voidsetOnItemViewClickedListener(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.
public voidsetOnItemViewSelectedListener(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.
public final voidsetOnKeyInterceptListener(View.OnKeyListener handler)
Sets the input event handler.
public voidsetOnPlaybackItemViewClickedListener(
BaseOnItemViewClickedListener listener
)
Sets the BaseOnItemViewClickedListener that would be invoked for clicks only on androidx.leanback.widget.PlaybackRowPresenter.ViewHolder.
public voidsetPlaybackRow(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. |
public voidsetPlaybackRowPresenter(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 |
public voidsetPlaybackSeekUiClient(PlaybackSeekUi.Client client)
Interface to be implemented by UI widget to support PlaybackSeekUi.
public voidsetShowOrHideControlsOverlayOnUserInteraction(
boolean showOrHideControlsOverlayOnUserInteraction
)
Enables or disables showing and auto-hiding controls when user interacts. Enabled by default. Auto-hide timer length is defined by playbackControlsAutoHideTickleTimeout.
public void showControlsOverlay(boolean runAnimation)Show controls overlay.
| Parameters | |
|---|---|
boolean runAnimation |
True to run animation, false otherwise. |
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
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. |
protected voidonError(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. |
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 |