Class StubPlayer

    • Constructor Detail

      • StubPlayer

        public StubPlayer()
    • Method Detail

      • getApplicationLooper

        public Looper getApplicationLooper()
        Description copied from interface: Player
        Returns the Looper associated with the application thread that's used to access the player and on which player events are received.
      • addListener

        public void addListener​(Player.Listener listener)
        Description copied from interface: Player
        Registers a listener to receive all events from the player.

        The listener's methods will be called on the thread associated with Player.getApplicationLooper().

        Parameters:
        listener - The listener to register.
      • removeListener

        public void removeListener​(Player.Listener listener)
        Description copied from interface: Player
        Unregister a listener registered through Player.addListener(Listener). The listener will no longer receive events.
        Parameters:
        listener - The listener to unregister.
      • prepare

        public void prepare()
        Description copied from interface: Player
        Prepares the player.

        This will move the player out of idle state and the player will start loading media and acquire resources needed for playback.

      • setMediaItems

        public void setMediaItems​(List<MediaItem> mediaItems,
                                  int startIndex,
                                  long startPositionMs)
        Description copied from interface: Player
        Clears the playlist and adds the specified MediaItems.
        Parameters:
        mediaItems - The new MediaItems.
        startIndex - The MediaItem index to start playback from. If C.INDEX_UNSET is passed, the current position is not reset.
        startPositionMs - The position in milliseconds to start playback from. If C.TIME_UNSET is passed, the default position of the given MediaItem is used. In any case, if startIndex is set to C.INDEX_UNSET, this parameter is ignored and the position is not reset at all.
      • addMediaItems

        public void addMediaItems​(int index,
                                  List<MediaItem> mediaItems)
        Description copied from interface: Player
        Adds a list of media items at the given index of the playlist.
        Parameters:
        index - The index at which to add the media items. If the index is larger than the size of the playlist, the media items are added to the end of the playlist.
        mediaItems - The MediaItems to add.
      • moveMediaItems

        public void moveMediaItems​(int fromIndex,
                                   int toIndex,
                                   int newIndex)
        Description copied from interface: Player
        Moves the media item range to the new index.
        Parameters:
        fromIndex - The start of the range to move.
        toIndex - The first item not to be included in the range (exclusive).
        newIndex - The new index of the first media item of the range. If the new index is larger than the size of the remaining playlist after removing the range, the range is moved to the end of the playlist.
      • removeMediaItems

        public void removeMediaItems​(int fromIndex,
                                     int toIndex)
        Description copied from interface: Player
        Removes a range of media items from the playlist.
        Parameters:
        fromIndex - The index at which to start removing media items.
        toIndex - The index of the first item to be kept (exclusive). If the index is larger than the size of the playlist, media items to the end of the playlist are removed.
      • setPlayWhenReady

        public void setPlayWhenReady​(boolean playWhenReady)
        Description copied from interface: Player
        Sets whether playback should proceed when Player.getPlaybackState() == Player.STATE_READY.

        If the player is already in the ready state then this method pauses and resumes playback.

        Parameters:
        playWhenReady - Whether playback should proceed when ready.
      • setRepeatMode

        public void setRepeatMode​(@RepeatMode
                                  @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
        Description copied from interface: Player
        Sets the Player.RepeatMode to be used for playback.
        Parameters:
        repeatMode - The repeat mode.
      • setShuffleModeEnabled

        public void setShuffleModeEnabled​(boolean shuffleModeEnabled)
        Description copied from interface: Player
        Sets whether shuffling of media items is enabled.
        Parameters:
        shuffleModeEnabled - Whether shuffling is enabled.
      • isLoading

        public boolean isLoading()
        Description copied from interface: Player
        Whether the player is currently loading the source.
        Returns:
        Whether the player is currently loading the source.
        See Also:
        Player.Listener.onIsLoadingChanged(boolean)
      • seekTo

        public void seekTo​(int mediaItemIndex,
                           long positionMs)
        Description copied from interface: Player
        Seeks to a position specified in milliseconds in the specified MediaItem.
        Parameters:
        mediaItemIndex - The index of the MediaItem.
        positionMs - The seek position in the specified MediaItem, or C.TIME_UNSET to seek to the media item's default position.
      • stop

        public void stop()
        Description copied from interface: Player
        Stops playback without resetting the playlist. 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 and the player will release the loaded media and resources required for playback. The player instance can still be used by calling Player.prepare() again, 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.

      • stop

        @Deprecated
        public void stop​(boolean reset)
        Deprecated.
      • release

        public void release()
        Description copied from interface: Player
        Releases the player. This method must be called when the player is no longer required. The player must not be used after calling this method.
      • getCurrentTrackSelections

        public TrackSelectionArray getCurrentTrackSelections()
        Description copied from interface: Player
        Returns the current track selections.

        A concrete implementation may include null elements if it has a fixed number of renderer components, wishes to report a TrackSelection for each of them, and has one or more renderer components that is not assigned any selected tracks.

        See Also:
        Player.Listener.onTracksChanged(TrackGroupArray, TrackSelectionArray)
      • getTrackSelectionParameters

        public TrackSelectionParameters getTrackSelectionParameters()
        Description copied from interface: Player
        Returns the parameters constraining the track selection.
        See Also:
        }
      • setTrackSelectionParameters

        public void setTrackSelectionParameters​(TrackSelectionParameters parameters)
        Description copied from interface: Player
        Sets the parameters constraining the track selection.

        Unsupported parameters will be silently ignored.

        Use Player.getTrackSelectionParameters() to retrieve the current parameters. For example, the following snippet restricts video to SD whilst keep other track selection parameters unchanged:

        
         player.setTrackSelectionParameters(
           player.getTrackSelectionParameters()
                 .buildUpon()
                 .setMaxVideoSizeSd()
                 .build())
         
      • setPlaylistMetadata

        public void setPlaylistMetadata​(MediaMetadata mediaMetadata)
        Description copied from interface: Player
        Sets the playlist MediaMetadata.
      • getCurrentPeriodIndex

        public int getCurrentPeriodIndex()
        Description copied from interface: Player
        Returns the index of the period currently being played.
      • getCurrentMediaItemIndex

        public int getCurrentMediaItemIndex()
        Description copied from interface: Player
        Returns the index of the current MediaItem in the timeline, or the prospective index if the current timeline is empty.
      • getDuration

        public long getDuration()
        Description copied from interface: Player
        Returns the duration of the current content or ad in milliseconds, or C.TIME_UNSET if the duration is not known.
      • getCurrentPosition

        public long getCurrentPosition()
        Description copied from interface: Player
        Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if the current timeline is empty.
      • getBufferedPosition

        public long getBufferedPosition()
        Description copied from interface: Player
        Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.
      • getTotalBufferedDuration

        public long getTotalBufferedDuration()
        Description copied from interface: Player
        Returns an estimate of the total buffered duration from the current position, in milliseconds. This includes pre-buffered data for subsequent ads and media items.
      • isPlayingAd

        public boolean isPlayingAd()
        Description copied from interface: Player
        Returns whether the player is currently playing an ad.
      • getCurrentAdGroupIndex

        public int getCurrentAdGroupIndex()
        Description copied from interface: Player
        If Player.isPlayingAd() returns true, returns the index of the ad group in the period currently being played. Returns C.INDEX_UNSET otherwise.
      • getCurrentAdIndexInAdGroup

        public int getCurrentAdIndexInAdGroup()
        Description copied from interface: Player
        If Player.isPlayingAd() returns true, returns the index of the ad in its ad group. Returns C.INDEX_UNSET otherwise.
      • getContentPosition

        public long getContentPosition()
        Description copied from interface: Player
        If Player.isPlayingAd() returns true, returns the content position that will be played once all ads in the ad group have finished playing, in milliseconds. If there is no ad playing, the returned position is the same as that returned by Player.getCurrentPosition().
      • getContentBufferedPosition

        public long getContentBufferedPosition()
        Description copied from interface: Player
        If Player.isPlayingAd() returns true, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds. If there is no ad playing, the returned position is the same as that returned by Player.getBufferedPosition().
      • getAudioAttributes

        public AudioAttributes getAudioAttributes()
        Description copied from interface: Player
        Returns the attributes for audio playback.
      • setVolume

        public void setVolume​(float volume)
        Description copied from interface: Player
        Sets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive.
        Parameters:
        volume - Linear output gain to apply to all audio channels.
      • getVolume

        public float getVolume()
        Description copied from interface: Player
        Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
        Returns:
        The linear gain applied to all audio channels.
      • clearVideoSurface

        public void clearVideoSurface​(@Nullable
                                      Surface surface)
        Description copied from interface: Player
        Clears the Surface onto which video is being rendered if it matches the one passed. Else does nothing.
        Parameters:
        surface - The surface to clear.
      • setVideoSurfaceHolder

        public void setVideoSurfaceHolder​(@Nullable
                                          SurfaceHolder surfaceHolder)
        Description copied from interface: Player
        Sets the SurfaceHolder that holds the Surface onto which video will be rendered. The player will track the lifecycle of the surface automatically.

        The thread that calls the SurfaceHolder.Callback methods must be the thread associated with Player.getApplicationLooper().

        Parameters:
        surfaceHolder - The surface holder.
      • clearVideoSurfaceHolder

        public void clearVideoSurfaceHolder​(@Nullable
                                            SurfaceHolder surfaceHolder)
        Description copied from interface: Player
        Clears the SurfaceHolder that holds the Surface onto which video is being rendered if it matches the one passed. Else does nothing.
        Parameters:
        surfaceHolder - The surface holder to clear.
      • setVideoSurfaceView

        public void setVideoSurfaceView​(@Nullable
                                        SurfaceView surfaceView)
        Description copied from interface: Player
        Sets the SurfaceView onto which video will be rendered. The player will track the lifecycle of the surface automatically.

        The thread that calls the SurfaceHolder.Callback methods must be the thread associated with Player.getApplicationLooper().

        Parameters:
        surfaceView - The surface view.
      • clearVideoSurfaceView

        public void clearVideoSurfaceView​(@Nullable
                                          SurfaceView surfaceView)
        Description copied from interface: Player
        Clears the SurfaceView onto which video is being rendered if it matches the one passed. Else does nothing.
        Parameters:
        surfaceView - The texture view to clear.
      • clearVideoTextureView

        public void clearVideoTextureView​(@Nullable
                                          TextureView textureView)
        Description copied from interface: Player
        Clears the TextureView onto which video is being rendered if it matches the one passed. Else does nothing.
        Parameters:
        textureView - The texture view to clear.
      • getCurrentCues

        public List<Cue> getCurrentCues()
        Description copied from interface: Player
        Returns the current Cues. This list may be empty.
      • getDeviceInfo

        public DeviceInfo getDeviceInfo()
        Description copied from interface: Player
        Gets the device information.
      • isDeviceMuted

        public boolean isDeviceMuted()
        Description copied from interface: Player
        Gets whether the device is muted or not.
      • setDeviceVolume

        public void setDeviceVolume​(int volume)
        Description copied from interface: Player
        Sets the volume of the device.
        Parameters:
        volume - The volume to set.
      • increaseDeviceVolume

        public void increaseDeviceVolume()
        Description copied from interface: Player
        Increases the volume of the device.
      • decreaseDeviceVolume

        public void decreaseDeviceVolume()
        Description copied from interface: Player
        Decreases the volume of the device.
      • setDeviceMuted

        public void setDeviceMuted​(boolean muted)
        Description copied from interface: Player
        Sets the mute state of the device.