Package com.google.android.exoplayer2.ext.leanback

## Class LeanbackPlayerAdapter

- java.lang.Object
- - androidx.leanback.media.PlayerAdapter
  - - com.google.android.exoplayer2.ext.leanback.LeanbackPlayerAdapter

- All Implemented Interfaces:
    `Runnable`

      public final class LeanbackPlayerAdapter
      extends androidx.leanback.media.PlayerAdapter
      implements Runnable

  Leanback `PlayerAdapter` implementation for `Player`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class androidx.leanback.media.PlayerAdapter

      `androidx.leanback.media.PlayerAdapter.Callback`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `LeanbackPlayerAdapter​(Context context, Player player, int updatePeriodMs)` | Builds an instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `long` | `getBufferedPosition()` |
    `long` | `getCurrentPosition()` |
    `long` | `getDuration()` |
    `boolean` | `isPlaying()` |
    `boolean` | `isPrepared()` |
    `void` | `onAttachedToHost​(androidx.leanback.media.PlaybackGlueHost host)` |
    `void` | `onDetachedFromHost()` |
    `void` | `pause()` |
    `void` | `play()` |
    `void` | `run()` |
    `void` | `seekTo​(long positionInMs)` |
    `void` | `setErrorMessageProvider​(ErrorMessageProvider<? super PlaybackException> errorMessageProvider)` | Sets the optional `ErrorMessageProvider`.
    `void` | `setProgressUpdatingEnabled​(boolean enable)` |

    - ### Methods inherited from class androidx.leanback.media.PlayerAdapter

      `fastForward, getCallback, getSupportedActions, next, previous, rewind, setCallback, setRepeatAction, setShuffleAction`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LeanbackPlayerAdapter

          public LeanbackPlayerAdapter​(Context context,
                                       Player player,
                                       int updatePeriodMs)

      Builds an instance. Note that the `PlayerAdapter` does not manage the lifecycle of the `Player` instance. The caller remains responsible for releasing the player when it's no longer required.
      Parameters:
        `context` - The current `Context` (activity).
        `player` - The `Player` being used.
        `updatePeriodMs` - The delay between player control updates, in milliseconds.

  - ### Method Detail

    - #### setErrorMessageProvider

          public void setErrorMessageProvider​(@Nullable
                                              ErrorMessageProvider<? super PlaybackException> errorMessageProvider)

      Sets the optional `ErrorMessageProvider`.
      Parameters:
        `errorMessageProvider` - The `ErrorMessageProvider`.

    - #### onAttachedToHost

          public void onAttachedToHost​(androidx.leanback.media.PlaybackGlueHost host)

      Overrides:
        `onAttachedToHost` in class `androidx.leanback.media.PlayerAdapter`

    - #### onDetachedFromHost

          public void onDetachedFromHost()

      Overrides:
        `onDetachedFromHost` in class `androidx.leanback.media.PlayerAdapter`

    - #### setProgressUpdatingEnabled

          public void setProgressUpdatingEnabled​(boolean enable)

      Overrides:
        `setProgressUpdatingEnabled` in class `androidx.leanback.media.PlayerAdapter`

    - #### isPlaying

          public boolean isPlaying()

      Overrides:
        `isPlaying` in class `androidx.leanback.media.PlayerAdapter`

    - #### getDuration

          public long getDuration()

      Overrides:
        `getDuration` in class `androidx.leanback.media.PlayerAdapter`

    - #### getCurrentPosition

          public long getCurrentPosition()

      Overrides:
        `getCurrentPosition` in class `androidx.leanback.media.PlayerAdapter`

    - #### play

          public void play()

      Specified by:
        `play` in class `androidx.leanback.media.PlayerAdapter`

    - #### pause

          public void pause()

      Specified by:
        `pause` in class `androidx.leanback.media.PlayerAdapter`

    - #### seekTo

          public void seekTo​(long positionInMs)

      Overrides:
        `seekTo` in class `androidx.leanback.media.PlayerAdapter`

    - #### getBufferedPosition

          public long getBufferedPosition()

      Overrides:
        `getBufferedPosition` in class `androidx.leanback.media.PlayerAdapter`

    - #### isPrepared

          public boolean isPrepared()

      Overrides:
        `isPrepared` in class `androidx.leanback.media.PlayerAdapter`

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`