Class BasePlayer

    • Constructor Detail

      • BasePlayer

        protected BasePlayer()
    • Method Detail

      • setMediaItem

        public final void setMediaItem​(MediaItem mediaItem)
        Description copied from interface: Player
        Clears the playlist, adds the specified MediaItem and resets the position to the default position.
        Specified by:
        setMediaItem in interface Player
        Parameters:
        mediaItem - The new MediaItem.
      • setMediaItem

        public final void setMediaItem​(MediaItem mediaItem,
                                       long startPositionMs)
        Description copied from interface: Player
        Clears the playlist and adds the specified MediaItem.
        Specified by:
        setMediaItem in interface Player
        Parameters:
        mediaItem - The new MediaItem.
        startPositionMs - The position in milliseconds to start playback from.
      • setMediaItems

        public final void setMediaItems​(List<MediaItem> mediaItems)
        Description copied from interface: Player
        Clears the playlist, adds the specified MediaItems and resets the position to the default position.
        Specified by:
        setMediaItems in interface Player
        Parameters:
        mediaItems - The new MediaItems.
      • addMediaItem

        public final void addMediaItem​(int index,
                                       MediaItem mediaItem)
        Description copied from interface: Player
        Adds a media item at the given index of the playlist.
        Specified by:
        addMediaItem in interface Player
        Parameters:
        index - The index at which to add the media item. If the index is larger than the size of the playlist, the media item is added to the end of the playlist.
        mediaItem - The MediaItem to add.
      • addMediaItem

        public final void addMediaItem​(MediaItem mediaItem)
        Description copied from interface: Player
        Adds a media item to the end of the playlist.
        Specified by:
        addMediaItem in interface Player
        Parameters:
        mediaItem - The MediaItem to add.
      • addMediaItems

        public final void addMediaItems​(List<MediaItem> mediaItems)
        Description copied from interface: Player
        Adds a list of media items to the end of the playlist.
        Specified by:
        addMediaItems in interface Player
        Parameters:
        mediaItems - The MediaItems to add.
      • moveMediaItem

        public final void moveMediaItem​(int currentIndex,
                                        int newIndex)
        Description copied from interface: Player
        Moves the media item at the current index to the new index.
        Specified by:
        moveMediaItem in interface Player
        Parameters:
        currentIndex - The current index of the media item to move.
        newIndex - The new index of the media item. If the new index is larger than the size of the playlist the item is moved to the end of the playlist.
      • removeMediaItem

        public final void removeMediaItem​(int index)
        Description copied from interface: Player
        Removes the media item at the given index of the playlist.
        Specified by:
        removeMediaItem in interface Player
        Parameters:
        index - The index at which to remove the media item.
      • clearMediaItems

        public final void clearMediaItems()
        Description copied from interface: Player
        Clears the playlist.
        Specified by:
        clearMediaItems in interface Player
      • pause

        public final void pause()
        Description copied from interface: Player
        Pauses playback. Equivalent to setPlayWhenReady(false).
        Specified by:
        pause in interface Player
      • seekToDefaultPosition

        public final void seekToDefaultPosition()
        Description copied from interface: Player
        Seeks to the default position associated with the current window. The position can depend on the type of media being played. For live streams it will typically be the live edge of the window. For other streams it will typically be the start of the window.
        Specified by:
        seekToDefaultPosition in interface Player
      • seekToDefaultPosition

        public final void seekToDefaultPosition​(int windowIndex)
        Description copied from interface: Player
        Seeks to the default position associated with the specified window. The position can depend on the type of media being played. For live streams it will typically be the live edge of the window. For other streams it will typically be the start of the window.
        Specified by:
        seekToDefaultPosition in interface Player
        Parameters:
        windowIndex - The index of the window whose associated default position should be seeked to.
      • seekTo

        public final void seekTo​(long positionMs)
        Description copied from interface: Player
        Seeks to a position specified in milliseconds in the current window.
        Specified by:
        seekTo in interface Player
        Parameters:
        positionMs - The seek position in the current window, or C.TIME_UNSET to seek to the window's default position.
      • seekToNext

        public final void seekToNext()
        Description copied from interface: Player
        Seeks to a later position in the current or next window (if available). More precisely:
        • If the timeline is empty or seeking is not possible, does nothing.
        • Otherwise, if a next window exists, seeks to the default position of the next window.
        • Otherwise, if the current window is live and has not ended, seeks to the live edge of the current window.
        • Otherwise, does nothing.
        Specified by:
        seekToNext in interface Player
      • setPlaybackSpeed

        public final void setPlaybackSpeed​(float speed)
        Description copied from interface: Player
        Changes the rate at which playback occurs. The pitch is not changed.

        This is equivalent to setPlaybackParameters(getPlaybackParameters().withSpeed(speed)).

        Specified by:
        setPlaybackSpeed in interface Player
        Parameters:
        speed - The linear factor by which playback will be sped up. Must be higher than 0. 1 is normal speed, 2 is twice as fast, 0.5 is half normal speed...
      • stop

        public final void stop()
        Description copied from interface: Player
        Stops playback without resetting the player. Use Player.pause() rather than this method if the intention is to pause playback.

        Calling this method will cause the playback state to transition to Player.STATE_IDLE. The player instance can still be used, and Player.release() must still be called on the player if it's no longer required.

        Calling this method does not clear the playlist, reset the playback position or the playback error.

        Specified by:
        stop in interface Player
      • getMediaItemCount

        public final int getMediaItemCount()
        Description copied from interface: Player
        Returns the number of media items in the playlist.
        Specified by:
        getMediaItemCount in interface Player
      • getCurrentManifest

        @Nullable
        public final Object getCurrentManifest()
        Description copied from interface: Player
        Returns the current manifest. The type depends on the type of media being played. May be null.
        Specified by:
        getCurrentManifest in interface Player
      • getBufferedPercentage

        public final int getBufferedPercentage()
        Description copied from interface: Player
        Returns an estimate of the percentage in the current content window or ad up to which data is buffered, or 0 if no estimate is available.
        Specified by:
        getBufferedPercentage in interface Player
      • getCurrentLiveOffset

        public final long getCurrentLiveOffset()
        Description copied from interface: Player
        Returns the offset of the current playback position from the live edge in milliseconds, or C.TIME_UNSET if the current window isn't live or the offset is unknown.

        The offset is calculated as currentTime - playbackPosition, so should usually be positive.

        Note that this offset may rely on an accurate local time, so this method may return an incorrect value if the difference between system clock and server clock is unknown.

        Specified by:
        getCurrentLiveOffset in interface Player
      • getContentDuration

        public final long getContentDuration()
        Description copied from interface: Player
        If Player.isPlayingAd() returns true, returns the duration of the current content window in milliseconds, or C.TIME_UNSET if the duration is not known. If there is no ad playing, the returned duration is the same as that returned by Player.getDuration().
        Specified by:
        getContentDuration in interface Player
      • getAvailableCommands

        protected Player.Commands getAvailableCommands​(Player.Commands permanentAvailableCommands)
        Returns the Player.Commands available in the player.
        Parameters:
        permanentAvailableCommands - The commands permanently available in the player.
        Returns:
        The available Player.Commands.