-
- All Implemented Interfaces:
-
com.theoplayer.android.api.event.EventDispatcher
public interface Player implements EventDispatcher<PlayerEvent>
The player API
-
-
Method Summary
Modifier and Type Method Description abstract voidaddIntegration(Integration integration)Adds an Integration. abstract voidremoveIntegration(Integration integration)Removes an Integration. abstract AdsgetAds()The ads API. abstract AbrgetAbr()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 TextTrackListgetTextTracks()List of text tracks of the current source. abstract doublegetDuration()The duration of the media, in seconds. abstract booleanisAutoplay()Returns whether the player should immediately start playback after source change. abstract voidsetAutoplay(boolean autoplay)Sets whether the player should immediately start playback after source change. abstract voidsetAutoplay(boolean autoplay, @Nullable() DoneCallback callback)Sets whether the player should immediately start playback after source change. abstract doublegetVolume()The volume of the audio. abstract voidsetVolume(double volume)Sets the volume of the audio. abstract voidsetVolume(double volume, @Nullable() DoneCallback callback)Sets the volume of the audio. abstract PreloadTypegetPreload()The PreloadType of the player. abstract voidsetPreload(@NonNull() PreloadType preload)Sets the PreloadType of the player. abstract voidsetPreload(PreloadType preload, @Nullable() DoneCallback callback)Sets the PreloadType of the player. abstract booleanisMuted()Returns whether the audio is muted. abstract voidsetMuted(boolean muted)Sets whether the audio is muted. abstract voidsetMuted(boolean muted, DoneCallback callback)Sets whether the audio is muted. abstract booleanisSeeking()Returns whether the player is seeking. abstract SourceDescriptiongetSource()The current source which describes the desired playback of a media. abstract voidsetSource(@Nullable() SourceDescription source)Sets a new SourceDescription. abstract voidsetSource(@Nullable() SourceDescription source, @Nullable() DoneCallback callback)Sets a new SourceDescription. abstract StringgetSrc()The current URL of the media. abstract voidsetSrc(@Nullable() String src)Sets a new media source URL. abstract voidsetSrc(@Nullable() String src, @Nullable() DoneCallback callback)Sets a new media source URL. abstract booleanisPaused()Returns whether the player is paused. abstract booleanisEnded()Returns whether playback of the media has ended. abstract voidplay()Starts or resumes playback. abstract voidplay(@Nullable() DoneCallback callback)Starts or resumes playback. abstract voidpause()Pauses playback. abstract voidpause(@Nullable() DoneCallback callback)Pauses playback. abstract voidstop()Stops playback. abstract voidstop(@Nullable() DoneCallback callback)Stops playback. abstract ReadyStategetReadyState()The ReadyState of the player. abstract voidrequestBuffered(@Nullable() RequestCallback<TimeRanges> callback)Requests the ranges of the media that the player has buffered. abstract TimeRangesgetBuffered()Returns the ranges of the media that the player has buffered. abstract voidrequestCurrentTime(@Nullable() RequestCallback<Double> callback)Requests the current playback position of the media, in seconds. abstract doublegetCurrentTime()Returns the current playback position of the media, in seconds. abstract MetricsgetMetrics()Get the current Metrics of the player. abstract StringgetError()The last error that occurred for the current source, if any. abstract doublegetPlaybackRate()The playback rate of the media. abstract voidsetPlaybackRate(double playbackRate)Sets the playback rate of the media. abstract voidsetPlaybackRate(double playbackRate, @Nullable() DoneCallback callback)Sets the playback rate of the media. abstract voidrequestPlayed(@Nullable() RequestCallback<TimeRanges> callback)Requests the ranges of the media that the player has played. abstract TimeRangesgetPlayed()Returns the ranges of the media that the player has played. abstract voidrequestSeekable(@Nullable() RequestCallback<TimeRanges> callback)Requests the ranges of the media that are seekable by the player. abstract TimeRangesgetSeekable()Returns the ranges of the media that are seekable by the player. abstract voidrequestCurrentProgramDateTime(@Nullable() RequestCallback<Date> callback)The current playback position of the media, as a timestamp. abstract DategetCurrentProgramDateTime()The current playback position of the media, as a timestamp. abstract voidsetCurrentProgramDateTime(Date currentProgramDateTime)Sets the current program date time. abstract voidsetCurrentProgramDateTime(Date currentProgramDateTime, @Nullable() DoneCallback callback)Sets the current program date time. abstract voidrequestVideoHeight(@Nullable() RequestCallback<Integer> callback)Requests the height of the active video rendition, in pixels. abstract intgetVideoHeight()Returns the height of the active video rendition, in pixels. abstract voidrequestVideoWidth(@Nullable() RequestCallback<Integer> callback)Requests the width of the active video rendition, in pixels. abstract intgetVideoWidth()Returns the width of the active video rendition, in pixels. abstract voidsetCurrentTime(double currentTime)Sets the playback position of the media. abstract voidsetCurrentTime(double currentTime, @Nullable() DoneCallback callback)Sets the playback position of the media. abstract VRgetVR()The VR API which can be used to inspect and control the display of 360° virtual reality videos. abstract YospacegetYospace()The Yospace API which can be used to inspect the Yospace Session object. abstract VerizonMediagetVerizonMedia()The Verizon Media API which can be used for Verizon Media assets. abstract HespApigetHespApi()The HESP API. abstract voidsetAspectRatio(AspectRatio aspectRatio)Sets the aspect ratio of the player. abstract voidsetRenderingTarget(RenderingTarget renderingTarget)Sets the player rendering target SURFACE_VIEW or TEXTURE_VIEW. -
-
Method Detail
-
addIntegration
abstract void addIntegration(Integration integration)
Adds an Integration.
- Only available with the 'Unified Android' SDK.
- Parameters:
integration- The Integration to be added on the player.
-
removeIntegration
abstract void removeIntegration(Integration integration)
Removes an Integration.
- Only available with the 'Unified Android' SDK.
- Parameters:
integration- The Integration to be removed from the player.
-
getVideoTracks
@NonNull() abstract MediaTrackList<VideoQuality> getVideoTracks()
List of video tracks of the current source.
-
getAudioTracks
@NonNull() abstract MediaTrackList<AudioQuality> getAudioTracks()
List of audio tracks of the current source.
-
getTextTracks
@NonNull() abstract TextTrackList getTextTracks()
List of text tracks of the current source.
-
getDuration
abstract double getDuration()
The duration of the media, in seconds.
- On source change, duration becomes available after the getReadyState becomes HAVE_METADATA.
-
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.
- The execution of the method will be done asynchronously.
- Parameters:
autoplay- Indicates whether the player should automatically play.
-
setAutoplay
abstract void setAutoplay(boolean autoplay, @Nullable() DoneCallback callback)
Sets whether the player should immediately start playback after source change.
- The execution of the method will be done asynchronously.
- Parameters:
autoplay- Indicates whether the player should automatically play.callback- The DoneCallback which will be called when the execution is completed.
-
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.
-
setVolume
abstract void setVolume(double volume)
Sets the volume of the audio.
- The execution of the method will be done asynchronously.
- 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.
-
setVolume
abstract void setVolume(double volume, @Nullable() DoneCallback callback)
Sets the volume of the audio.
- The execution of the method will be done asynchronously.
- 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.callback- The DoneCallback which will be called when the execution is completed.
-
getPreload
@NonNull() abstract PreloadType getPreload()
The PreloadType of the player. (NonNull)
-
setPreload
abstract void setPreload(@NonNull() PreloadType preload)
Sets the PreloadType of the player.
- The execution of the method will be done asynchronously.
- Parameters:
preload- The new preload type.
-
setPreload
abstract void setPreload(PreloadType preload, @Nullable() DoneCallback callback)
Sets the PreloadType of the player.
- The execution of the method will be done asynchronously.
- Parameters:
preload- The new preload type.callback- The DoneCallback which will be called when the execution is completed.
-
isMuted
abstract boolean isMuted()
Returns whether the audio is muted.
-
setMuted
abstract void setMuted(boolean muted)
Sets whether the audio is muted.
- This affects capabilities of isAutoplay.
- The execution of the method will be done asynchronously.
- Parameters:
muted- Whether the audio is muted.
-
setMuted
abstract void setMuted(boolean muted, DoneCallback callback)
Sets whether the audio is muted.
- This affects the capabilities of isAutoplay.
- The execution of the method will be done asynchronously.
- Parameters:
muted- Whether the audio is muted.callback- The DoneCallback which will be called when the execution is completed.
-
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.
- Changing the source might cause getPreload and isAutoplay.
- Changing the source will stop the previous source.
-
setSource
abstract void setSource(@Nullable() SourceDescription source)
Sets a new SourceDescription.
- The execution of the method will be done asynchronously.
- Changing the source might cause getPreload and isAutoplay.
- Changing the source will stop the previous source.
- Parameters:
source- The new SourceDescription.
-
setSource
abstract void setSource(@Nullable() SourceDescription source, @Nullable() DoneCallback callback)
Sets a new SourceDescription.
- The execution of the method will be done asynchronously.
- Changing the source might cause getPreload and isAutoplay.
- Changing the source will stop the previous source.
- Parameters:
source- The new SourceDescription.callback- The DoneCallback which will be called when the execution is completed.
-
getSrc
@Nullable() abstract String getSrc()
The current URL of the media.
- Prefer getSource instead, as it contains a more detailed description regarding ads, analytics etc.
-
setSrc
abstract void setSrc(@Nullable() String src)
Sets a new media source URL.
- The execution of the method will be done asynchronously.
- Parameters:
src- The new media source URL.
-
setSrc
abstract void setSrc(@Nullable() String src, @Nullable() DoneCallback callback)
Sets a new media source URL.
- The execution of the method will be done asynchronously.
- Parameters:
src- The new media source URL.callback- The DoneCallback which will be called when the execution is completed.
-
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 and the player does not loop.
-
play
abstract void play()
Starts or resumes playback.
- The execution of the method will be done asynchronously.
- When the player is not paused this method has no effect.
-
play
abstract void play(@Nullable() DoneCallback callback)
Starts or resumes playback.
- The execution of the method will be done asynchronously.
- When the player is not paused this method has no effect.
- Parameters:
callback- The DoneCallback which will be called when the execution is completed.
-
pause
abstract void pause()
Pauses playback.
- The execution of the method will be done asynchronously.
-
pause
abstract void pause(@Nullable() DoneCallback callback)
Pauses playback.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The DoneCallback which will be called when the execution is completed.
-
stop
abstract void stop()
Stops playback.
- The execution of the method will be done asynchronously.
-
stop
abstract void stop(@Nullable() DoneCallback callback)
Stops playback.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The DoneCallback which will be called when the execution is completed.
-
getReadyState
@NonNull() abstract ReadyState getReadyState()
The ReadyState of the player.
- See the HTML Media Specification
-
requestBuffered
@Deprecated() abstract void requestBuffered(@Nullable() RequestCallback<TimeRanges> callback)
Requests the ranges of the media that the player has buffered.
Deprecated: Superseded by getBuffered, since v3.4.0.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The RequestCallback with the TimeRanges result, which will be called when the execution is completed.
-
getBuffered
@NonNull() abstract TimeRanges getBuffered()
Returns the ranges of the media that the player has buffered.
-
requestCurrentTime
@Deprecated() abstract void requestCurrentTime(@Nullable() RequestCallback<Double> callback)
Requests the current playback position of the media, in seconds.
Deprecated: Superseded by getCurrentTime, since v3.4.0.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The RequestCallback with the playback position in seconds, which will be called when the execution is completed.
-
getCurrentTime
abstract double getCurrentTime()
Returns the current playback position of the media, 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.
-
getError
@Nullable() abstract String getError()
The last error that occurred for the current source, if any.
-
getPlaybackRate
abstract double getPlaybackRate()
The playback rate of the media.
- For more information, see setPlaybackRate.
-
setPlaybackRate
abstract void setPlaybackRate(double playbackRate)
Sets the playback rate of the media.
- The execution of the method will be done asynchronously.
- 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.
-
setPlaybackRate
abstract void setPlaybackRate(double playbackRate, @Nullable() DoneCallback callback)
Sets the playback rate of the media.
- The execution of the method will be done asynchronously.
- 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.callback- The DoneCallback which will be called when the execution is completed.
-
requestPlayed
@Deprecated() abstract void requestPlayed(@Nullable() RequestCallback<TimeRanges> callback)
Requests the ranges of the media that the player has played.
Deprecated: Superseded by getPlayed, since v3.4.0.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The RequestCallback with the TimeRanges result, which will be called when the execution is completed.
-
getPlayed
@NonNull() abstract TimeRanges getPlayed()
Returns the ranges of the media that the player has played.
-
requestSeekable
@Deprecated() abstract void requestSeekable(@Nullable() RequestCallback<TimeRanges> callback)
Requests the ranges of the media that are seekable by the player.
Deprecated: Superseded by getSeekable, since v3.4.0.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The RequestCallback with the TimeRanges result, which will be called when the execution is completed.
-
getSeekable
@NonNull() abstract TimeRanges getSeekable()
Returns the ranges of the media that are seekable by the player.
-
requestCurrentProgramDateTime
@Deprecated() abstract void requestCurrentProgramDateTime(@Nullable() RequestCallback<Date> callback)
The current playback position of the media, as a timestamp.
Deprecated: Superseded by getCurrentProgramDateTime, since v3.4.0.
- The execution of the method will be done asynchronously.
- The result of the execution can be null when the manifest doesn't specify the currentProgramDateTime.
- The relation between requestCurrentProgramDateTime and requestCurrentTime is determined by the manifest.
- Parameters:
callback- The RequestCallback with the Date result, which will be called when the execution is completed.
-
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.
-
setCurrentProgramDateTime
abstract void setCurrentProgramDateTime(Date currentProgramDateTime)
Sets the current program date time.
- The execution of the method will be done asynchronously.
- 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.
-
setCurrentProgramDateTime
abstract void setCurrentProgramDateTime(Date currentProgramDateTime, @Nullable() DoneCallback callback)
Sets the current program date time.
- The execution of the method will be done asynchronously.
- 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.callback- The DoneCallback which will be called when the execution is completed.
-
requestVideoHeight
@Deprecated() abstract void requestVideoHeight(@Nullable() RequestCallback<Integer> callback)
Requests the height of the active video rendition, in pixels.
Deprecated: Superseded by getVideoHeight, since v3.4.0.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The RequestCallback with the video height in pixels, which will be called when the execution is completed.
-
getVideoHeight
abstract int getVideoHeight()
Returns the height of the active video rendition, in pixels.
-
requestVideoWidth
@Deprecated() abstract void requestVideoWidth(@Nullable() RequestCallback<Integer> callback)
Requests the width of the active video rendition, in pixels.
Deprecated: Superseded by getVideoWidth, since v3.4.0.
- The execution of the method will be done asynchronously.
- Parameters:
callback- The RequestCallback with the video width in pixels, which will be called when the execution is completed.
-
getVideoWidth
abstract int getVideoWidth()
Returns the width of the active video rendition, in pixels.
-
setCurrentTime
abstract void setCurrentTime(double currentTime)
Sets the playback position of the media.
- The execution of the method will be done asynchronously.
- Parameters:
currentTime- The new playback position, in seconds.
-
setCurrentTime
abstract void setCurrentTime(double currentTime, @Nullable() DoneCallback callback)
Sets the playback position of the media.
- The execution of the method will be done asynchronously.
- Parameters:
currentTime- The new playback position, in seconds.callback- The DoneCallback which will be called when the execution is completed.
-
getVR
@Nullable() abstract VR getVR()
The VR API which can be used to inspect and control the display of 360° virtual reality videos.
- Only available with the feature 'vr'.
-
getYospace
@Nullable() abstract Yospace getYospace()
The Yospace API which can be used to inspect the Yospace Session object.
- Only available with the feature 'yospace'.
-
getVerizonMedia
@Nullable() abstract VerizonMedia getVerizonMedia()
The Verizon Media API which can be used for Verizon Media assets.
- Only available with the feature 'verizonmedia'.
-
getHespApi
@Nullable() abstract HespApi getHespApi()
The HESP API.
- Note: This API is in an experimental stage and may be subject to breaking changes.
- Only available with the feature 'hesp'.
-
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 SURFACE_VIEW or TEXTURE_VIEW. Default target is: SURFACE_VIEW
- refer to: SurfaceView
- refer to: TextureView
- Parameters:
renderingTarget- the RenderingTarget to set on the player.
-
-
-
-