Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.leanback:leanback:1.0.0-rc01

PlaybackGlueHost

public abstract class PlaybackGlueHost
extends Object

java.lang.Object
   ↳ androidx.leanback.media.PlaybackGlueHost


This class represents the UI (e.g. Fragment/Activity) hosting playback controls and defines the interaction between PlaybackGlue and the host. PlaybackGlueHost provides the following functions:

  • Render UI of PlaybackGlue: setPlaybackRow(Row), setPlaybackRowPresenter(PlaybackRowPresenter).
  • Client for fragment/activity onStart/onStop: setHostCallback(HostCallback).
  • Auto fade out controls after a short period: setFadingEnabled(boolean).
  • Key listener and ActionListener. setOnKeyInterceptListener(View.OnKeyListener), setOnActionClickedListener(OnActionClickedListener).
  • Subclass of PlaybackGlueHost may implement optional interfaces:
  • SurfaceHolderGlueHost to provide SurfaceView for video playback.
  • PlaybackSeekUi to provide seek UI to glue
  • These optional interfaces should be accessed by glue in PlaybackGlue.onAttachedToHost(PlaybackGlueHost).

    Summary

    Nested classes

    class PlaybackGlueHost.HostCallback

    Callbacks triggered by the host(e.g. 

    class PlaybackGlueHost.PlayerCallback

    Optional Client that implemented by PlaybackGlueHost to respond to player event. 

    Public constructors

    PlaybackGlueHost()

    Public methods

    void fadeOut()

    This method was deprecated in API level 1.0.0. Call hideControlsOverlay(boolean)

    PlaybackGlueHost.PlayerCallback getPlayerCallback()

    Implemented by PlaybackGlueHost for responding to player events.

    void hideControlsOverlay(boolean runAnimation)

    Hide controls overlay.

    boolean isControlsOverlayAutoHideEnabled()

    Returns true if auto hides controls overlay.

    boolean isControlsOverlayVisible()

    Returns true if controls overlay is visible, false otherwise.

    void notifyPlaybackRowChanged()

    Notifies host about a change so it can update the view.

    void setControlsOverlayAutoHideEnabled(boolean enabled)

    Enables or disables controls overlay auto hidden.

    void setFadingEnabled(boolean enable)

    This method was deprecated in API level 1.0.0. Use setControlsOverlayAutoHideEnabled(boolean)

    void setHostCallback(PlaybackGlueHost.HostCallback callback)

    Sets the host PlaybackGlueHost.HostCallback callback on the host.

    void setOnActionClickedListener(OnActionClickedListener listener)

    Sets the View.OnClickListener on this fragment.

    void setOnKeyInterceptListener(View.OnKeyListener onKeyListener)

    Sets the View.OnKeyListener on the host.

    void setPlaybackRow(Row row)

    Sets the Row that represents the information on control items that needs to be rendered.

    void setPlaybackRowPresenter(PlaybackRowPresenter presenter)

    Sets PlaybackRowPresenter for rendering the playback controls.

    void showControlsOverlay(boolean runAnimation)

    Show controls overlay.

    Inherited methods

    Public constructors

    PlaybackGlueHost

    added in version 1.0.0
    public PlaybackGlueHost ()

    Public methods

    fadeOut

    added in version 1.0.0
    public void fadeOut ()

    This method was deprecated in API level 1.0.0.
    Call hideControlsOverlay(boolean)

    Fades out the playback overlay immediately.

    getPlayerCallback

    added in version 1.0.0
    public PlaybackGlueHost.PlayerCallback getPlayerCallback ()

    Implemented by PlaybackGlueHost for responding to player events. Such as showing a spinning wheel progress bar when PlaybackGlueHost.PlayerCallback.onBufferingStateChanged(boolean).

    Returns
    PlaybackGlueHost.PlayerCallback PlayerEventCallback that Host supports, null if not supported.

    hideControlsOverlay

    added in version 1.0.0
    public void hideControlsOverlay (boolean runAnimation)

    Hide controls overlay.

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

    isControlsOverlayAutoHideEnabled

    added in version 1.0.0
    public boolean isControlsOverlayAutoHideEnabled ()

    Returns true if auto hides controls overlay.

    Returns
    boolean True if auto hiding controls overlay.

    isControlsOverlayVisible

    added in version 1.0.0
    public boolean isControlsOverlayVisible ()

    Returns true if controls overlay is visible, false otherwise.

    Returns
    boolean True if controls overlay is visible, false otherwise.

    notifyPlaybackRowChanged

    added in version 1.0.0
    public void notifyPlaybackRowChanged ()

    Notifies host about a change so it can update the view.

    setControlsOverlayAutoHideEnabled

    added in version 1.0.0
    public void setControlsOverlayAutoHideEnabled (boolean enabled)

    Enables or disables controls overlay auto hidden. If enabled, the view will be faded out after a time period.

    Parameters
    enabled boolean: True to enable auto hidden of controls overlay.

    setFadingEnabled

    added in version 1.0.0
    public void setFadingEnabled (boolean enable)

    This method was deprecated in API level 1.0.0.
    Use setControlsOverlayAutoHideEnabled(boolean)

    Enables or disables view fading. If enabled, the view will be faded in when the fragment starts and will fade out after a time period.

    Parameters
    enable boolean

    setHostCallback

    added in version 1.0.0
    public void setHostCallback (PlaybackGlueHost.HostCallback callback)

    Sets the host PlaybackGlueHost.HostCallback callback on the host. This method should only be called by PlaybackGlue. App should not directly call this method, app should override PlaybackGlue.onHostStart() etc.

    Parameters
    callback PlaybackGlueHost.HostCallback

    setOnActionClickedListener

    added in version 1.0.0
    public void setOnActionClickedListener (OnActionClickedListener listener)

    Sets the View.OnClickListener on this fragment.

    Parameters
    listener OnActionClickedListener

    setOnKeyInterceptListener

    added in version 1.0.0
    public void setOnKeyInterceptListener (View.OnKeyListener onKeyListener)

    Sets the View.OnKeyListener on the host. This would trigger the listener when a KeyEvent is unhandled by the host.

    Parameters
    onKeyListener View.OnKeyListener

    setPlaybackRow

    added in version 1.0.0
    public void setPlaybackRow (Row row)

    Sets the Row that represents the information on control items that needs to be rendered.

    Parameters
    row Row

    setPlaybackRowPresenter

    added in version 1.0.0
    public void setPlaybackRowPresenter (PlaybackRowPresenter presenter)

    Sets PlaybackRowPresenter for rendering the playback controls.

    Parameters
    presenter PlaybackRowPresenter

    showControlsOverlay

    added in version 1.0.0
    public void showControlsOverlay (boolean runAnimation)

    Show controls overlay.

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