Adds an event listener to the player. PlayerEventMap is a computed type which maps event names to their payloads.
Remove listeners with Player.removeEventListener.
The name of the event. Available events include PlayerState events and PlayerEventType events.
The handler function.
Attaches a video element (tag) to be used for playback. This replaces any video element in use. This is optional; if it is not called, the Player creates and uses a video element.
The video element to attach.
Removes the player instance and stops playback. After deletion, the player no longer emits events or responds to API calls.
Gets the buffer length ahead of the current playback position.
The duration, in seconds, from the playhead to the end of the buffer.
Gets the currently buffered range.
The buffered range which the playhead is within.
Gets the clientHeight
of the underyling HTMLMediaElement.
The clientHeight
property of the active video element.
Gets the clientWidth
of the underyling HTMLMediaElement.
The clientWidth
property of the active video element.
Gets the duration of the currently loaded media stream.
The duration of the stream in seconds for video on demand content, and Infinity for live streams.
Gets the video element in use.
The video element in use.
For a live stream, returns the latency from the server to the player. Note: For non-live streams, this value is not meaningful.
This API is not supported on iOS mobile (iPhone) browsers.
the latency in seconds.
Gets the playback rate.
The playback of the rate of the player.
Gets the playback position.
The current position of the player, in seconds. When the player is rendering via MediaSourceExtensions, the starting position is 0. Otherwise, the starting position is relative to the current duration of the stream.
Set of available Quality objects from the loaded source or empty if none are currently available. The qualities will be available after the PlayerState.READY state has been entered. This set contains the qualities that can be used with Player.setQuality. Note that this set will contain only qualities capable of being played on the current device and not all those present in the source stream. On iOS mobile (iPhone) browsers, this API will return an empty array. The reason is that underlying Safari browser manages the playback entirely and does not provide any way to access the available qualities.
Gets the quality that the player is using. On iOS mobile (iPhone) browsers, this API will return an empty Quality object. The reason is that underlying Safari browser manages the playback entirely and does not provide any way to access the available qualities.
The current quality of the source.
Gets the ID of the playback session.
A unique identifier ID of the current play session, or undefined if the session is not yet known. The ID is known after the player enters the PlayerState.READY state. This session identifier can be shared with support or displayed in an user interface to help troubleshoot or diagnose playback issues with the currently playing stream.
Gets the state of the player.
The current state of the player.
Gets the version of the player.
The semantic version of the player.
Gets the player's volume level.
The volume level of the player, between 0.0f and 1.0f.
Gets whether the Adaptive Bitrate (ABR) streaming algorithm is enabled. The maximum quality is controlled by Player.setAutoMaxQuality.
True if ABR is enabled, false otherwise.
Gets whether autoplay is enabled. Defaults to false.
True if autoplay is enabled, false otherwise.
Gets whether low-latency live streaming is enabled.
This API is not supported on iOS mobile (iPhone) browsers.
True if low-latency streaming is enabled on both the server and the client, false otherwise.
Gets whether the player is muted.
True if the player is muted, false otherwise.
Gets whether the player is paused.
True if the player is paused, otherwise false. This flag reflects pauses initiated by the user, autoplay failure, and error handling.
Loads the specified stream and prepares the player for playback. On success, the player state changes to PlayerState.READY. On failure, this invokes the PlayerEventType.ERROR listener.
The URL of the stream to load.
Media type of the content if known; for example, 'video/mp4' or 'application/x-mpegURL'. If not provided, the type is inferred from the path.
Pauses playback of the current stream or fails if no stream is loaded. On failure invokes the onError listener method.
If you resume the stream with play, the position may be different than where it paused, depending on the type of media being played.
Starts or resumes playback of the stream, if no stream is loaded indicates intent to play and the player will automatically play on a subsequent load call. On success, depending on the type of stream, the player state changes to PlayerState.BUFFERING and then PlayerState.PLAYING, or just PlayerState.PLAYING. On failure, this invokes the PlayerEventType.ERROR listener. This does not need to be called if autoplay is enabled.
Removes an event listener from the player. PlayerEventMap is a computed type which maps event names to their payloads.
The name of the event. Available events include PlayerState events and PlayerEventType events.
The handler function.
Seeks to a specified time in the stream and begins playing at that position if play() was called. If no stream is loaded the seek will be be deferred until load is called. On success, depending on the type of stream, the player state changes to PlayerState.BUFFERING and then PlayerState.PLAYING, or just PlayerState.PLAYING. On failure, this invokes the PlayerEventType.ERROR listener.
The position to seek to, in seconds.
Sets the maximum quality the player is allowed to auto-switch up to (if ABR is enabled) using the input quality's bitrate value. This allows you to control resource usage. The Quality you provide here is applied to the current stream. If you load a new stream, call this again after PlayerState.READY.
This API is not supported on iOS mobile (iPhone) browsers.
The maximum quality to use for ABR.
Sets the maximum video display size of the player. This prevents the player from auto-switching to qualities above the specified resolution when ABR is enabled.
This API is not supported on iOS mobile (iPhone) browsers.
The display width.
The display height.
Enables or disables the Adaptive Bitrate (ABR) streaming algorithm. Note the maximum quality is controlled by Player.setAutoMaxQuality. The player chooses the quality to play based on current network and device conditions. By default, the player starts in this mode. This mode is implicitly disabled by a call to Player.setQuality.
This API is not supported on iOS mobile (iPhone) browsers.
True to enable ABR, false to disable.
Enables or disables playback autoplay. Defaults to false.
True to enable autoplay, false otherwise.
Sets the initial (minimum) buffer duration required to start playback. If a value outside the allowable range is used, the current value is maintained. Defaults to 1s in low latency mode, 2s otherwise. Lowering this value may increase rebuffering.
This API is not supported on iOS mobile (iPhone) browsers.
Buffer duration in seconds. The allowable range is 0.1 to 5
Enables low-latency playback for live streams configured to support it. Changing this value during playback restarts the stream.
This API is not supported on iOS mobile (iPhone) browsers.
True to enable, false to disable. Default: true.
Sets the log level for the player.
The log level to set. Default: LogLevel.ERROR.
Mutes or unmutes the player.
True to mute the player, false to unmute.
Sets the stream playback rate.
Playback rate to set. Valid values: in the range [0.25, 2.0].
Sets the quality the player should use for playback. On success, this
invokes the PlayerEventType.QUALITY_CHANGED listener. This
call disables adaptive bitrate (ABR) streaming. This call has
no effect when the HTMLVideoElement's controls
attribute is present.
A valid quality entry from Player.getQualities.
True for an adaptive quality change; that is, to change quality smoothly at the end of the current buffer. False to change quality immediately.
This API is not supported on iOS mobile (iPhone) browsers.
Enables skipping to the live edge on a rebuffer. Note this can cause video content and content associated with it such as timed metadata to be skipped.
This API is not supported on iOS mobile (iPhone) browsers.
True to enable, false otherwise.
Sets the Request.credentials property used when the player makes HTTP requests. Possible values are "include" | "omit" | "same-origin" from the JavaScript fetch API. The default value used is "same-origin". This can be used for credentialed playback of IVS recordings (e.g. via CloudFront if configured) but not for IVS live streams.
"include" | "omit" | "same-origin"
This API is not supported on iOS mobile (iPhone) browsers.
Sets the playback volume of the audio track, for the current stream or the next stream that is loaded.
The volume to be set. Valid values: in the range 0.0f to 1.0f.
Generated using TypeDoc
An interface describing the API of the media player.
Create a player instance with the create function. The player's APIs are generally asynchronous when setting and synchronous when getting. Listen to events via Player.addEventListener for state updates.