THEOplayer > ChromelessPlayer
The player API.
Signature:
export declare class ChromelessPlayer implements EventDispatcher<PlayerEventMap>
Constructor |
Description |
---|---|
constructor(element: |
Constructs a new instance of the |
Property |
Type |
Description |
---|---|---|
The adaptive bitrate configuration. |
||
The ads API. |
||
The analytics API. |
||
The web audio API. |
||
List of audio tracks of the current source. |
||
|
Whether the player should immediately start playback after source change. |
|
Returns a TimeRanges object that represents the ranges of the media resource that the player has buffered. |
||
The canvas of the player. |
||
The cast API. |
||
The clip API. |
||
|
The current playback position of the media, as a timestamp. |
|
|
The current playback position of the media, in seconds. |
|
|
The duration of the media, in seconds. |
|
|
The HTML element containing the player. |
|
|
Whether playback of the media is ended. |
|
MediaError |
The last error that occurred for the current source, if any. |
|
THEOplayerError |
The last error that occurred for the current source, if any. |
|
The HESP API. |
||
The Imagine API. |
||
The latency manager for low latency live playback. |
||
|
Whether playback of the media is looped. |
|
The metrics API. |
||
|
Whether audio is muted. |
|
The network API. |
||
|
Whether the player is paused. |
|
|
The playback rate of the media. |
|
Returns a TimeRanges object that represents the ranges of the media resource that the player has played. |
||
|
The poster of the current source. |
|
The preload setting of the player. |
||
The presentation API. |
||
|
The ready state of the player, represented by a value from the following list: |
|
The related content API. |
||
Returns a TimeRanges object that represents the ranges of the media resource that are seekable by the player. |
||
|
Whether the player is seeking. |
|
SourceDescription |
The current source which describes desired playback of a media resource. |
|
|
The current URL of the media resource. |
|
List of text tracks of the current source. |
||
The text track style API. |
||
|
Unique ID of the player. |
|
The Verizon Media API. |
||
|
The height of the active video rendition, in pixels. |
|
List of video tracks of the current source. |
||
|
The width of the active video rendition, in pixels. |
|
The visibility API. |
||
|
The volume of the audio. |
|
The VR API. |
||
The Yospace API. |
Method |
Description |
---|---|
addEventListener(type: |
Add the given listener for the given event type(s). |
destroy(): |
Destroy the player. |
pause(): |
Pause playback. |
play(): |
Start or resume playback. |
prepareWithUserAction(): |
Prepare the player to ChromelessPlayer.autoplay on platforms where autoplay is restricted without user action. |
removeEventListener(type: |
Remove the given listener for the given event type(s). |
setSource(sourceDescription: SourceDescription |
Set current source which describes desired playback of a media resource. |
stop(): |
Stop playback. |
Constructs a new instance of the ChromelessPlayer
class
Signature:
constructor(element: HTMLElement, configuration?: PlayerConfiguration);
Parameter |
Type |
Description |
---|---|---|
element |
|
|
configuration |
The adaptive bitrate configuration.
Signature:
readonly abr: ABRConfiguration;
The ads API.
Signature:
readonly ads?: Ads;
- Only available with the feature 'ads'
.
The analytics API.
Signature:
readonly analytics?: Analytics;
The web audio API.
Signature:
readonly audio?: WebAudio;
- Only available with the feature 'webaudio'
.
List of audio tracks of the current source.
Signature:
audioTracks: MediaTrackList;
Whether the player should immediately start playback after source change.
Signature:
autoplay: boolean;
- To autoplay with sound on certain platforms, ChromelessPlayer.prepareWithUserAction() must be called at least once.
- To autoplay without sound, PlayerConfiguration.mutedAutoplay must be configured.
Returns a TimeRanges object that represents the ranges of the media resource that the player has buffered.
Signature:
readonly buffered: TimeRanges;
The canvas of the player.
Signature:
readonly canvas: Canvas;
The cast API.
Signature:
readonly cast?: Cast;
- Only available with the feature 'airplay'
or 'chromecast'
.
The clip API.
Signature:
readonly clip: Clip;
The current playback position of the media, as a timestamp.
Signature:
currentProgramDateTime: Date | null;
- The relation between ChromelessPlayer.currentProgramDateTime and ChromelessPlayer.currentTime is determined by the manifest.
The current playback position of the media, in seconds.
Signature:
currentTime: number;
The duration of the media, in seconds.
Signature:
duration: number;
- On source change, duration becomes available after ChromelessPlayer.readyState is at least 1
(HAVE_METADATA).
The HTML element containing the player.
Signature:
element: HTMLElement;
Whether playback of the media is ended.
Signature:
ended: boolean;
- Playback is ended when the current playback position is at the end of the media, and the player does not ChromelessPlayer.loop.
Warning: This API is deprecated.
use ChromelessPlayer.errorObject instead
The last error that occurred for the current source, if any.
Signature:
error: MediaError | undefined;
The last error that occurred for the current source, if any.
Signature:
errorObject: THEOplayerError | undefined;
- This will equal the property from the last .
The HESP API.
Signature:
readonly hesp?: HespApi;
- Note: This API is in an experimental stage and may be subject to breaking changes.
- Only available with the feature 'hesp'
.
The Imagine API.
Signature:
imagine?: Imagine;
- Only available with the feature 'imagine'
.
The latency manager for low latency live playback.
Signature:
latency: LatencyManager;
- Can currently only be used with HESP sources.
Whether playback of the media is looped.
Signature:
loop: boolean;
- When playback is looped, upon reaching the end of the media, playback immediately continues at the start of the media.
- Looped media is never ChromelessPlayer.ended.
The metrics API.
Signature:
readonly metrics: Metrics;
Whether audio is muted.
Signature:
muted: boolean;
- This affects capabilities of ChromelessPlayer.autoplay.
The network API.
Signature:
readonly network: Network;
Whether the player is paused.
Signature:
paused: boolean;
The playback rate of the media.
Signature:
playbackRate: number;
- Playback rate is represented by a number where 1
is default playback speed.
- Playback rate must be a positive number.
- It is recommended that you limit the range to between 0.5 and 4.
- 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%.
Returns a TimeRanges object that represents the ranges of the media resource that the player has played.
Signature:
played: TimeRanges;
The poster of the current source.
Signature:
poster: string;
- An empty string (''
) clears the current poster.
- The SourceConfiguration.poster has priority over this poster.
The preload setting of the player.
Signature:
preload: PreloadType;
The presentation API.
Signature:
readonly presentation: Presentation;
The ready state of the player, represented by a value from the following list:
- 0
(HAVE_NOTHING): The player has no information about the duration of its source.
- 1
(HAVE_METADATA): The player has information about the duration of its source.
- 2
(HAVE_CURRENT_DATA): The player has its current frame in its buffer.
- 3
(HAVE_FUTURE_DATA): The player has enough data for immediate playback.
- 4
(HAVE_ENOUGH_DATA): The player has enough data for continuous playback.
Signature:
readyState: number;
- See the HTML Media Specification
The related content API.
Signature:
readonly related?: RelatedContent;
- Only available with the feature 'relatedcontent'
.
Returns a TimeRanges object that represents the ranges of the media resource that are seekable by the player.
Signature:
seekable: TimeRanges;
- On source change, seekable becomes available after ChromelessPlayer.readyState is at least 1
.
Whether the player is seeking.
Signature:
seeking: boolean;
The current source which describes desired playback of a media resource.
Signature:
source: SourceDescription | undefined;
- Changing source might ChromelessPlayer.preload and ChromelessPlayer.autoplay.
- Changing source will ChromelessPlayer.stop() the previous source.
The current URL of the media resource.
Signature:
src: string | undefined;
- Prefer ChromelessPlayer.source instead.
List of text tracks of the current source.
Signature:
textTracks: TextTracksList;
The text track style API.
Signature:
readonly textTrackStyle: TextTrackStyle;
Unique ID of the player.
Signature:
uid: number;
The Verizon Media API.
Signature:
readonly verizonMedia?: VerizonMedia;
- Only available with the feature 'verizonmedia'
.
The height of the active video rendition, in pixels.
Signature:
videoHeight: number;
List of video tracks of the current source.
Signature:
videoTracks: MediaTrackList;
The width of the active video rendition, in pixels.
Signature:
videoWidth: number;
The visibility API.
Signature:
readonly visibility?: Visibility;
- Only available with the feature 'visibility'
.
The volume of the audio.
Signature:
volume: number;
- Volume is represented by a floating point number between 0.0
and 1.0
.
- volume = 0.7
will reduce the audio volume of the media by 30%.
The VR API.
Signature:
readonly vr?: VR;
- Only available with the feature 'vr'
.
The Yospace API.
Signature:
readonly yospace?: Yospace;
- Only available with the feature 'yospace'
.
Add the given listener for the given event type(s).
Signature:
addEventListener<TType extends StringKeyOf<PlayerEventMap>>(type: TType | readonly TType[], listener: EventListener<PlayerEventMap[TType]>): void;
Parameter |
Type |
Description |
---|---|---|
type |
|
The type of the event. |
listener |
EventListener |
The callback which is executed when the event occurs. |
Destroy the player.
Signature:
destroy(): void;
- Available since v2.26.
- All resources associated with the current source are released.
- All resources associated with the player are released.
- The player can no longer be used.
Pause playback.
Signature:
pause(): void;
Start or resume playback.
Signature:
play(): void;
Prepare the player to ChromelessPlayer.autoplay on platforms where autoplay is restricted without user action.
Signature:
prepareWithUserAction(): void;
- Any invocation must happen on user action.
- Affected platforms include all mobile platforms and Safari 11+.
Remove the given listener for the given event type(s).
Signature:
removeEventListener<TType extends StringKeyOf<PlayerEventMap>>(type: TType | readonly TType[], listener: EventListener<PlayerEventMap[TType]>): void;
Parameter |
Type |
Description |
---|---|---|
type |
|
The type of the event. |
listener |
EventListener |
The callback which will be removed. |
Warning: This API is deprecated.
Superseded by ChromelessPlayer.source.
Set current source which describes desired playback of a media resource.
Signature:
setSource(sourceDescription: SourceDescription | undefined): void;
Parameter |
Type |
Description |
---|---|---|
sourceDescription |
SourceDescription |
Stop playback.
Signature:
stop(): void;
- All resources associated with the current source are released.
- The player can be reused by setting a new ChromelessPlayer.source.