Interface Player

  • All Implemented Interfaces:
    com.theoplayer.android.api.event.EventDispatcher

    
    public interface Player
     implements EventDispatcher<E>
                        

    The player API

    • Constructor Detail

    • Method Detail

      • getAbr

        @MainThread()@NonNull() abstract Abr getAbr()

        The adaptive bitrate configuration.

        Returns:

        The adaptive bitrate configuration. (NonNull)

      • getDuration

        @MainThread() abstract double getDuration()

        The duration of the media, in seconds.

        Returns:

        The duration of the media, in seconds.

      • isAutoplay

        @MainThread() abstract boolean isAutoplay()

        Returns whether the player should immediately start playback after source change.

        • To autoplay without sound, setMuted must be configured with 'true'.
      • setAutoplay

        @MainThread() abstract void setAutoplay(boolean autoplay)

        Sets whether the player should immediately start playback after source change.

        Parameters:
        autoplay - Indicates whether the player should automatically play.
      • getVolume

        @MainThread() abstract double getVolume()

        The volume of the audio.

        • This volume is completely separated from the Android device volume.
        • The volume heard will be a combination of the player volume and the Android device volume.
        Returns:

        The player volume, represented by a rational number between 0 and 1.

      • setVolume

        @MainThread() abstract void setVolume(double volume)

        Sets the volume of the audio.

        • This volume is completely separated from the Android device volume.
        • The volume heard will be a combination of the player volume and the Android device volume.
        Parameters:
        volume - The new volume of the audio, represented by a rational number between 0 and 1.
      • isMuted

        @MainThread() abstract boolean isMuted()

        Returns whether the audio is muted.

      • setMuted

        @MainThread() abstract void setMuted(boolean muted)

        Sets whether the audio is muted.

        Parameters:
        muted - Whether the audio is muted.
      • getSrc

        @MainThread()@Nullable() abstract String getSrc()

        The current URL of the media.

        • Prefer getSource instead, as it contains a more detailed description regarding ads, metadata etc.
        Returns:

        The current URL of the media. (Nullable)

      • isPaused

        @MainThread() abstract boolean isPaused()

        Returns whether the player is paused.

      • isEnded

        @MainThread() abstract boolean isEnded()

        Returns whether playback of the media has ended.

        • Playback had ended when the current playback position is at the end of the media.
      • play

        @MainThread() abstract void play()

        Starts or resumes playback.

        • When the player is not paused this method has no effect.
      • getCurrentTime

        @MainThread() abstract double getCurrentTime()

        Returns the current playback position of the media, in seconds.

        Returns:

        The playback position in seconds.

      • setCurrentTime

        @MainThread() abstract void setCurrentTime(double currentTime)

        Sets the playback position of the media.

        Parameters:
        currentTime - The new playback position, in seconds.
      • getError

        @MainThread()@Nullable() abstract String getError()

        The last error that occurred for the current source, if any.

        Returns:

        The last error that occurred. (Nullable)

      • getPlaybackRate

        @MainThread() abstract double getPlaybackRate()

        The playback rate of the media.

        Returns:

        The playback rate of the media.

      • setPlaybackRate

        @MainThread() abstract void setPlaybackRate(double playbackRate)

        Sets the playback rate of the media.

        • Playback rate is represented by a number where `1` is default playback speed.
        • It is recommended that you limit the range to between 0.5 and 4.

        Example:

        • `playbackRate = 0.70` will slow down the playback rate of the media by 30%.
        • `playbackRate = 1.25` will speed up the playback rate of the media by 25%.
        Parameters:
        playbackRate - The new playback rate, represented by a number where `1` is default playback speed.
      • setCurrentProgramDateTime

        @MainThread() abstract void setCurrentProgramDateTime(Date currentProgramDateTime)

        Sets the current program date time.

        • When the program date time information is not embedded in the manifest, the current program date time will not be set.
        Parameters:
        currentProgramDateTime - The new current program date time.
      • getVideoHeight

        @MainThread() abstract int getVideoHeight()

        Returns the height of the active video rendition, in pixels.

        Returns:

        The video height in pixels.

      • getVideoWidth

        @MainThread() abstract int getVideoWidth()

        Returns the width of the active video rendition, in pixels.

        Returns:

        The video width in pixels.

      • getHespApi

        @MainThread()@ApiStatus.Experimental()@Nullable() abstract HespApi getHespApi()

        The HESP API.

        • Note: This API is in an experimental stage and may be subject to breaking changes.
        Returns:

        The HESP API. (Nullable)

      • setCustomSurface

        @MainThread()@ApiStatus.Experimental() abstract void setCustomSurface(@Nullable() Surface surface, int width, int height)

        Sets a custom Surface for the player to draw into.

        • Note: This is an experimental API.
        • Note: The Surface should be valid - `Surface.isValid()` should return true by the time it is passed to the player.
        • Note: It is up to the user to handle adding the Surface into the view hierarchy.
        • Note: It is up to the user to handle the AspectRatio of the video.
        • Note: It is up to the user to handle Fullscreen entering/exiting.
        • Note: It is up to the user to handle Picture in Picture entering/exiting.
        Parameters:
        surface - the Surface to be used by the player.
        width - the width of the Surface that is being passed.
        height - the height of the Surface that is being passed.
      • setPoster

        @MainThread() abstract void setPoster(@Nullable() String poster)

        Sets the poster image URL for the player. This poster will be shown for any source which doesn't specify the poster URL in the SourceDescription.

        Parameters:
        poster - The poster URL.