com.amazonaws.ivs.player.Player |
Interface defining a Player
. API users instantiate a Player
instance via
create(Context)
and issue api calls to it. The player communicates its
state and events back to the user via the Player.Listener
interface. The two primary
callbacks are for Player.State
changes via
onStateChanged(Player.State)
and for errors
onError(PlayerException)
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | Player.Factory | Static class used to instantiate Player instances. |
|||||||||
class | Player.Listener | Player listener interface. | |||||||||
enum | Player.LogLevel | Possible log level values that can be set on a player. | |||||||||
enum | Player.State | Represents the current state of a player instance. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void |
addListener(Player.Listener listener)
Adds a playback listener that receives information about this player instance.
| ||||||||||
abstract int | getAudioSessionId() | ||||||||||
abstract long | getAverageBitrate() | ||||||||||
abstract long | getBandwidthEstimate() | ||||||||||
abstract long | getBufferedPosition() | ||||||||||
abstract long | getDuration() | ||||||||||
abstract long | getLiveLatency() | ||||||||||
abstract float |
getPlaybackRate()
Gets the playback rate for the player.
| ||||||||||
abstract long | getPosition() | ||||||||||
abstract Set<Quality> | getQualities() | ||||||||||
abstract Quality | getQuality() | ||||||||||
abstract String | getSessionId() | ||||||||||
abstract Player.State | getState() | ||||||||||
abstract Statistics | getStatistics() | ||||||||||
abstract String | getVersion() | ||||||||||
abstract boolean | isAutoQualityMode() | ||||||||||
abstract boolean | isLiveLowLatency() | ||||||||||
abstract boolean | isMuted() | ||||||||||
abstract void |
load(Uri uri, String mediaType)
Loads the specified stream.
| ||||||||||
abstract void |
load(Uri uri)
Loads the specified stream.
| ||||||||||
abstract void |
pause()
Pauses playback of the stream.
| ||||||||||
abstract void |
play()
Starts or resumes playback of the stream.
| ||||||||||
abstract void |
release()
Releases the player instance.
| ||||||||||
abstract void |
removeListener(Player.Listener listener)
Removes a playback state listener.
| ||||||||||
abstract void |
seekTo(long position)
Seeks to a specified position in the stream, in milliseconds.
| ||||||||||
abstract void |
setAutoInitialBitrate(int bitrate)
Sets the initial starting bitrate when using auto quality mode.
| ||||||||||
abstract void |
setAutoMaxBitrate(int bitrate)
Sets the max bitrate when using auto quality mode.
| ||||||||||
abstract void |
setAutoMaxQuality(Quality quality)
Sets the max quality when using auto quality mode.
| ||||||||||
abstract void |
setAutoMaxVideoSize(int width, int height)
Sets the max video display size of the player.
| ||||||||||
abstract void |
setAutoQualityMode(boolean enable)
Enables automatic quality selection (ABR Adaptive bitrate).
| ||||||||||
abstract void |
setLiveLowLatencyEnabled(boolean enabled)
Enables low-latency playback for streams which support it.
| ||||||||||
abstract void |
setLogLevel(Player.LogLevel level)
Sets the log level for the player, defaults to
ERROR . | ||||||||||
abstract void |
setLooping(boolean loop)
Enables the player to loop the source video, for streams that support looping.
| ||||||||||
abstract void |
setMuted(boolean muted)
Mutes or unmutes the player audio.
| ||||||||||
abstract void |
setPlaybackRate(float rate)
Sets the playback rate for the player.
| ||||||||||
abstract void |
setQuality(Quality quality, boolean adaptive)
Sets the quality of the stream.
| ||||||||||
abstract void |
setQuality(Quality quality)
Sets the quality of the stream.
| ||||||||||
abstract void |
setSurface(Surface surface)
Sets the Surface to use for rendering video.
| ||||||||||
abstract void |
setVolume(float volume)
Sets the output gain value for the audio track.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.amazonaws.ivs.player.Releasable
|
Adds a playback listener that receives information about this player instance.
listener | to add |
---|
PLAYING
.
Gets the playback rate for the player.
PLAYING
state. Otherwise, this returns the last play position or -1 if not
started yet.
Loads the specified stream. On success, the player state changes to READY
.
On failure, this invokes onError(PlayerException)
.
uri | of the stream to load (e.g. a url or file) |
---|---|
mediaType | Media type of the content if known, e.g. "video/mp4" or "application/x-mpegURL" |
Loads the specified stream. On success, the player state changes to READY
.
On failure, this invokes onError(PlayerException)
.
uri | of the stream to load (e.g. a url or file) |
---|
Pauses playback of the stream. This fails if no stream is loaded. On failure, this invokes
onError(PlayerException)
.
Resuming the stream with play may result in the position being different depending on the type of source being played.
Releases the player instance. This method must be called when the Player
is no longer
being used, to free network and system resources. The player cannot be used after this
method is called.
Removes a playback state listener.
listener | to remove |
---|
Seeks to a specified position in the stream, in milliseconds.
Seeks to the given time in the stream and begins playing at that position if play() has been
called. On success, depending on the type of stream the player state will change to
BUFFERING
and then PLAYING
or remain in PLAYING
.
getPosition() will update to the seeked time. On failure, invokes the onError listener method.
position | to seek to in milliseconds |
---|
Sets the initial starting bitrate when using auto quality mode. This determines the initial quality for an adaptive stream, when no bandwidth estimate value has been determined.
bitrate | initial bitrate to use |
---|
Sets the max bitrate when using auto quality mode. Allows you to control resource usage in the case of multiple players.
bitrate | bitrate to use |
---|
Sets the max video display size of the player. This prevents switching to qualities above the specified resolution when autoSwitchQuality is true.
width | display width |
---|---|
height | display height |
Enables automatic quality selection (ABR Adaptive bitrate). The player will choose the
quality to play based on the current network and device conditions. The player by default
starts in this mode. This mode is implicitly disabled by a call to
setQuality(Quality)
.
enable | true to enable auto quality selection, false to disable. |
---|
Enables low-latency playback for streams which support it. Defaults to true. Changing this value during playback restarts the stream.
enabled | true to enable, false to disable |
---|
Sets the log level for the player, defaults to ERROR
.
level | to set |
---|
Enables the player to loop the source video, for streams that support looping.
loop | true to loop video playback, false otherwise |
---|
Mutes or unmutes the player audio.
muted | true to mute the player false to unmute the player |
---|
Sets the playback rate for the player.
rate | rate to set |
---|
Sets the quality of the stream. If auto quality mode is enabled, calling this method disables it.
quality | to set |
---|---|
adaptive | true for an adaptive quality change (quality changes at the end of the buffer, false otherwise buffer cleared immediately) |
Sets the quality of the stream. If auto quality mode is enabled, calling this method disables it.
quality | to set |
---|
Sets the Surface to use for rendering video. This method can be called at any time.
A valid surface must be set, to play video. When using a
android.view.SurfaceView or android.view.TextureView, the application must
listen for the corresponding lifecycle callbacks, for SurfaceView
surfaceCreated(SurfaceHolder)
and
surfaceDestroyed(SurfaceHolder)
for TextureView
onSurfaceTextureAvailable(SurfaceTexture, int, int)
and
onSurfaceTextureDestroyed(SurfaceTexture)
)}
in order to set the surface on the player and clear it, by setting it to null, when the
surface is being destroyed.
surface | surface to use for rendering. this value can be null to stop displaying video |
---|
Sets the output gain value for the audio track.
volume | volume for the audio track between 0.0f and 1.0f |
---|