Class LeanbackPlayerAdapter

  • All Implemented Interfaces:
    Runnable

    public final class LeanbackPlayerAdapter
    extends androidx.leanback.media.PlayerAdapter
    implements Runnable
    Leanback PlayerAdapter implementation for Player.
    • 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 - Instance of your exoplayer that needs to be configured.
        updatePeriodMs - The delay between player control updates, in milliseconds.
    • Method Detail

      • setControlDispatcher

        @Deprecated
        public void setControlDispatcher​(@Nullable
                                         ControlDispatcher controlDispatcher)
        Deprecated.
        Use a ForwardingPlayer and pass it to the constructor instead. You can also customize some operations when configuring the player (for example by using SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)).
      • 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 enabled)
        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 positionMs)
        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