Interface Player
-
- All Implemented Interfaces:
-
com.theoplayer.android.api.event.EventDispatcher
public interface Player implements EventDispatcher<E>
The player API
-
-
Method Summary
Modifier and Type Method Description abstract void
addIntegration(Integration integration)
Adds an Integration. abstract void
removeIntegration(Integration integration)
Removes an Integration. abstract TheoLive
getTheoLive()
The TheoLive API. abstract Ads
getAds()
The ads API. abstract Abr
getAbr()
The adaptive bitrate configuration. abstract MediaTrackList<VideoQuality>
getVideoTracks()
List of video tracks of the current source. abstract MediaTrackList<AudioQuality>
getAudioTracks()
List of audio tracks of the current source. abstract TextTrackList
getTextTracks()
List of text tracks of the current source. abstract double
getDuration()
The duration of the media, in seconds. abstract boolean
isAutoplay()
Returns whether the player should immediately start playback after source change. abstract void
setAutoplay(boolean autoplay)
Sets whether the player should immediately start playback after source change. abstract double
getVolume()
The volume of the audio. abstract void
setVolume(double volume)
Sets the volume of the audio. abstract PreloadType
getPreload()
The PreloadType of the player. abstract void
setPreload(@NonNull() PreloadType preload)
Sets the PreloadType of the player. abstract boolean
isMuted()
Returns whether the audio is muted. abstract void
setMuted(boolean muted)
Sets whether the audio is muted. abstract boolean
isSeeking()
Returns whether the player is seeking. abstract SourceDescription
getSource()
The current source which describes the desired playback of a media. abstract void
setSource(@Nullable() SourceDescription source)
Sets a new SourceDescription. abstract String
getSrc()
The current URL of the media. abstract void
setSrc(@Nullable() String src)
Sets a new media source URL. abstract boolean
isPaused()
Returns whether the player is paused. abstract boolean
isEnded()
Returns whether playback of the media has ended. abstract void
play()
Starts or resumes playback. abstract void
pause()
Pauses playback. abstract void
stop()
Stops playback. abstract ReadyState
getReadyState()
The ReadyState of the player. abstract TimeRanges
getBuffered()
Returns the ranges of the media that the player has buffered. abstract double
getCurrentTime()
Returns the current playback position of the media, in seconds. abstract void
setCurrentTime(double currentTime)
Sets the playback position of the media. abstract Metrics
getMetrics()
Get the current Metrics of the player. abstract String
getError()
The last error that occurred for the current source, if any. abstract double
getPlaybackRate()
The playback rate of the media. abstract void
setPlaybackRate(double playbackRate)
Sets the playback rate of the media. abstract TimeRanges
getPlayed()
Returns the ranges of the media that the player has played. abstract TimeRanges
getSeekable()
Returns the ranges of the media that are seekable by the player. abstract Date
getCurrentProgramDateTime()
The current playback position of the media, as a timestamp. abstract void
setCurrentProgramDateTime(Date currentProgramDateTime)
Sets the current program date time. abstract int
getVideoHeight()
Returns the height of the active video rendition, in pixels. abstract int
getVideoWidth()
Returns the width of the active video rendition, in pixels. abstract HespApi
getHespApi()
The HESP API. abstract void
setAspectRatio(AspectRatio aspectRatio)
Sets the aspect ratio of the player. abstract void
setRenderingTarget(RenderingTarget renderingTarget)
Sets the player rendering target where the player is displaying the video. abstract void
setCustomSurface(@Nullable() Surface surface, int width, int height)
Sets a custom Surface for the player to draw into. abstract TextTrackStyle
getTextTrackStyle()
The Text Track Style API. abstract Network
getNetwork()
The Network API that manages the current player. abstract LatencyManager
getLatencyManager()
The Latency Manager API used to control low-latency live playback. -
-
Method Detail
-
addIntegration
abstract void addIntegration(Integration integration)
Adds an Integration.
- Parameters:
integration
- The Integration to be added on the player.
-
removeIntegration
abstract void removeIntegration(Integration integration)
Removes an Integration.
- Parameters:
integration
- The Integration to be removed from the player.
-
getTheoLive
@NonNull() abstract TheoLive getTheoLive()
The TheoLive API.
- Returns:
The theo Live API. (NonNull)
-
getAbr
@NonNull() abstract Abr getAbr()
The adaptive bitrate configuration.
- Returns:
The adaptive bitrate configuration. (NonNull)
-
getVideoTracks
@NonNull() abstract MediaTrackList<VideoQuality> getVideoTracks()
List of video tracks of the current source.
- Returns:
List of video tracks of the current source. (NonNull)
-
getAudioTracks
@NonNull() abstract MediaTrackList<AudioQuality> getAudioTracks()
List of audio tracks of the current source.
- Returns:
List of audio tracks of the current source. (NonNull)
-
getTextTracks
@NonNull() abstract TextTrackList getTextTracks()
List of text tracks of the current source.
- Returns:
List of text tracks of the current source. (NonNull)
-
getDuration
abstract double getDuration()
The duration of the media, in seconds.
- On source change, duration becomes available after the getReadyState becomes HAVE_METADATA.
- Returns:
The duration of the media, in seconds.
-
isAutoplay
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
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
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
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.
-
getPreload
@NonNull() abstract PreloadType getPreload()
The PreloadType of the player. (NonNull)
-
setPreload
abstract void setPreload(@NonNull() PreloadType preload)
Sets the PreloadType of the player.
- Parameters:
preload
- The new preload type.
-
isMuted
abstract boolean isMuted()
Returns whether the audio is muted.
-
setMuted
abstract void setMuted(boolean muted)
Sets whether the audio is muted.
- Parameters:
muted
- Whether the audio is muted.
-
isSeeking
abstract boolean isSeeking()
Returns whether the player is seeking.
-
getSource
@Nullable() abstract SourceDescription getSource()
The current source which describes the desired playback of a media.
- Returns:
The current SourceDescription. (Nullable)
-
setSource
abstract void setSource(@Nullable() SourceDescription source)
Sets a new SourceDescription.
- Changing the source will stop the previous source.
- Changing the source might cause to start preloading the new source depending on the getPreload
- Changing the source might cause to start playing the new source depending on the isAutoplay.
- Parameters:
source
- The new SourceDescription.
-
getSrc
@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)
-
setSrc
abstract void setSrc(@Nullable() String src)
Sets a new media source URL.
- Parameters:
src
- The new media source URL.
-
isPaused
abstract boolean isPaused()
Returns whether the player is paused.
-
isEnded
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
abstract void play()
Starts or resumes playback.
- When the player is not paused this method has no effect.
-
pause
abstract void pause()
Pauses playback.
-
stop
abstract void stop()
Stops playback.
-
getReadyState
@NonNull() abstract ReadyState getReadyState()
The ReadyState of the player.
- See the HTML Media Specification
- Returns:
The ReadyState. (NonNull)
-
getBuffered
@NonNull() abstract TimeRanges getBuffered()
Returns the ranges of the media that the player has buffered.
- Returns:
The buffered TimeRanges. (NonNull)
-
getCurrentTime
abstract double getCurrentTime()
Returns the current playback position of the media, in seconds.
- Returns:
The playback position in seconds.
-
setCurrentTime
abstract void setCurrentTime(double currentTime)
Sets the playback position of the media.
- Parameters:
currentTime
- The new playback position, in seconds.
-
getMetrics
@Nullable() abstract Metrics getMetrics()
Get the current Metrics of the player.
- The values will be updated periodically.
- If the metrics are not yet known, it returns null.
- Returns:
The current player Metrics.
-
getError
@Nullable() abstract String getError()
The last error that occurred for the current source, if any.
- Returns:
The last error that occurred. (Nullable)
-
getPlaybackRate
abstract double getPlaybackRate()
The playback rate of the media.
- Returns:
The playback rate of the media.
-
setPlaybackRate
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.
-
getPlayed
@NonNull() abstract TimeRanges getPlayed()
Returns the ranges of the media that the player has played.
- Returns:
The played TimeRanges. (NonNull)
-
getSeekable
@NonNull() abstract TimeRanges getSeekable()
Returns the ranges of the media that are seekable by the player.
- Returns:
The seekable TimeRanges. (NonNull)
-
getCurrentProgramDateTime
@Nullable() abstract Date getCurrentProgramDateTime()
The current playback position of the media, as a timestamp.
- The result of the execution can be null when the manifest doesn't specify the currentProgramDateTime.
- The relation between getCurrentProgramDateTime and getCurrentTime is determined by the manifest.
- Returns:
The playback position. (Nullable)
-
setCurrentProgramDateTime
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
abstract int getVideoHeight()
Returns the height of the active video rendition, in pixels.
- Returns:
The video height in pixels.
-
getVideoWidth
abstract int getVideoWidth()
Returns the width of the active video rendition, in pixels.
- Returns:
The video width in pixels.
-
getHespApi
@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)
-
setAspectRatio
abstract void setAspectRatio(AspectRatio aspectRatio)
Sets the aspect ratio of the player.
- Parameters:
aspectRatio
- the AspectRatio to set on the player.
-
setRenderingTarget
abstract void setRenderingTarget(RenderingTarget renderingTarget)
Sets the player rendering target where the player is displaying the video. Can be set during playback. Default target is: SURFACE_VIEW
- Refer to: SurfaceView
- Refer to: TextureView
- Setting CUSTOM has no effect. Instead use setCustomSurface.
- Parameters:
renderingTarget
- the RenderingTarget to set on the player.
-
setCustomSurface
@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.
-
getTextTrackStyle
abstract TextTrackStyle getTextTrackStyle()
The Text Track Style API.
- Returns:
The TextTrackStyle API. (Nullable)
-
getNetwork
@NonNull() abstract Network getNetwork()
The Network API that manages the current player.
- Returns:
The Network API. (NonNull)
-
getLatencyManager
@NonNull() abstract LatencyManager getLatencyManager()
The Latency Manager API used to control low-latency live playback.
- Returns:
The Latency Manager API.
-
-
-
-