Skip to main content
Version: v7 Alpha

Class: VideoPlayer

Defined in: VideoPlayer.ts:20

Extends

  • VideoPlayerEvents

Implements

  • VideoPlayerBase

Constructors

Constructor

new VideoPlayer(source): VideoPlayer;

Defined in: VideoPlayer.ts:23

Parameters

ParameterType
source| VideoSource | VideoConfig | VideoPlayerSource

Returns

VideoPlayer

Overrides

VideoPlayerEvents.constructor

Accessors

currentTime

Get Signature

get currentTime(): number;

Defined in: VideoPlayer.ts:106

The duration of the video in seconds (1.0 = 1 sec). Returns NaN if the duration is not available.

Returns

number

Set Signature

set currentTime(value): void;

Defined in: VideoPlayer.ts:110

The duration of the video in seconds (1.0 = 1 sec). Returns NaN if the duration is not available.

Parameters
ParameterType
valuenumber
Returns

void

Implementation of

VideoPlayerBase.currentTime

duration

Get Signature

get duration(): number;

Defined in: VideoPlayer.ts:92

The current time of the video in seconds (1.0 = 1 sec). Returns NaN if the current time is not available.

Returns

number

Implementation of

VideoPlayerBase.duration

ignoreSilentSwitchMode

Get Signature

get ignoreSilentSwitchMode(): IgnoreSilentSwitchMode;

Defined in: VideoPlayer.ts:151

Controls the silent switch mode of the player.

Note

This is only supported on iOS.

  • auto - uses default behavior for player.
  • ignore - ignore the silent switch.
  • obey - obey the silent switch.
Returns

IgnoreSilentSwitchMode

Set Signature

set ignoreSilentSwitchMode(value): void;

Defined in: VideoPlayer.ts:155

Controls the silent switch mode of the player.

Note

This is only supported on iOS.

  • auto - uses default behavior for player.
  • ignore - ignore the silent switch.
  • obey - obey the silent switch.
Parameters
ParameterType
valueIgnoreSilentSwitchMode
Returns

void

Implementation of

VideoPlayerBase.ignoreSilentSwitchMode

isPlaying

Get Signature

get isPlaying(): boolean;

Defined in: VideoPlayer.ts:184

Whether the player is playing.

Note

This is a read-only property.

Note

To pause/resume the player, you need to use play and pause methods.

Returns

boolean

Implementation of

VideoPlayerBase.isPlaying

loop

Get Signature

get loop(): boolean;

Defined in: VideoPlayer.ts:124

Whether the player is looped.

Returns

boolean

Set Signature

set loop(value): void;

Defined in: VideoPlayer.ts:128

Whether the player is looped.

Parameters
ParameterType
valueboolean
Returns

void

Implementation of

VideoPlayerBase.loop

mixAudioMode

Get Signature

get mixAudioMode(): MixAudioMode;

Defined in: VideoPlayer.ts:142

Controls the audio mixing mode of the player.

  • mixWithOthers - Mix with other players.
  • doNotMix - Do not mix with other players.
  • duckOthers - Duck other players.
  • auto - uses default behavior for player.

default is auto.

Returns

MixAudioMode

Set Signature

set mixAudioMode(value): void;

Defined in: VideoPlayer.ts:146

Controls the audio mixing mode of the player.

  • mixWithOthers - Mix with other players.
  • doNotMix - Do not mix with other players.
  • duckOthers - Duck other players.
  • auto - uses default behavior for player.

default is auto.

Parameters
ParameterType
valueMixAudioMode
Returns

void

Implementation of

VideoPlayerBase.mixAudioMode

muted

Get Signature

get muted(): boolean;

Defined in: VideoPlayer.ts:115

Whether the player is muted.

Returns

boolean

Set Signature

set muted(value): void;

Defined in: VideoPlayer.ts:119

Whether the player is muted.

Parameters
ParameterType
valueboolean
Returns

void

Implementation of

VideoPlayerBase.muted

playInBackground

Get Signature

get playInBackground(): boolean;

Defined in: VideoPlayer.ts:166

Whether the player should play in background.

  • true - play in background.
  • false - pause in background (default).
Note

this can override playWhenInactive.

Returns

boolean

Set Signature

set playInBackground(value): void;

Defined in: VideoPlayer.ts:170

Whether the player should play in background.

  • true - play in background.
  • false - pause in background (default).
Note

this can override playWhenInactive.

Parameters
ParameterType
valueboolean
Returns

void

Implementation of

VideoPlayerBase.playInBackground

playWhenInactive

Get Signature

get playWhenInactive(): boolean;

Defined in: VideoPlayer.ts:175

Whether the player should play when the app is inactive (user opened control center).

  • true - play when the app is inactive.
  • false - pause when the app is inactive (default).
Note

this can be overridden by playInBackground.

Note

This is only supported on iOS.

Returns

boolean

Set Signature

set playWhenInactive(value): void;

Defined in: VideoPlayer.ts:179

Whether the player should play when the app is inactive (user opened control center).

  • true - play when the app is inactive.
  • false - pause when the app is inactive (default).
Note

this can be overridden by playInBackground.

Note

This is only supported on iOS.

Parameters
ParameterType
valueboolean
Returns

void

Implementation of

VideoPlayerBase.playWhenInactive

rate

Get Signature

get rate(): number;

Defined in: VideoPlayer.ts:133

Controls the speed at which the player should play.

Note

if rate is = 0, it will pause video.

Returns

number

Set Signature

set rate(value): void;

Defined in: VideoPlayer.ts:137

Controls the speed at which the player should play.

Note

if rate is = 0, it will pause video.

Parameters
ParameterType
valuenumber
Returns

void

Implementation of

VideoPlayerBase.rate

selectedTrack

Get Signature

get selectedTrack(): undefined | TextTrack;

Defined in: VideoPlayer.ts:281

Get the currently selected text track.

Returns

undefined | TextTrack

The currently selected text track, or undefined if none is selected

Implementation of

VideoPlayerBase.selectedTrack

showNotificationControls

Get Signature

get showNotificationControls(): boolean;

Defined in: VideoPlayer.ts:188

Returns

boolean

Set Signature

set showNotificationControls(value): void;

Defined in: VideoPlayer.ts:192

Parameters
ParameterType
valueboolean
Returns

void


source

Get Signature

get source(): VideoPlayerSource;

Defined in: VideoPlayer.ts:82

The source of the video. Source is immutable. To change the source, you need to call replaceSourceAsync method. see VideoPlayerSourceBase

Returns

VideoPlayerSource

Implementation of

VideoPlayerBase.source

status

Get Signature

get status(): VideoPlayerStatus;

Defined in: VideoPlayer.ts:87

The status of the player.

Returns

VideoPlayerStatus

Implementation of

VideoPlayerBase.status

volume

Get Signature

get volume(): number;

Defined in: VideoPlayer.ts:97

The volume of the video (0.0 = 0%, 1.0 = 100%).

Note

If the player is muted, the volume will be 0.0.

Returns

number

Set Signature

set volume(value): void;

Defined in: VideoPlayer.ts:101

The volume of the video (0.0 = 0%, 1.0 = 100%).

Note

If the player is muted, the volume will be 0.0.

Parameters
ParameterType
valuenumber
Returns

void

Implementation of

VideoPlayerBase.volume

Methods

addEventListener()

addEventListener<Event>(event, callback): void;

Defined in: VideoPlayerEvents.ts:35

Type Parameters

Type Parameter
Event extends keyof AllPlayerEvents

Parameters

ParameterType
eventEvent
callbackAllPlayerEvents[Event]

Returns

void

Inherited from

VideoPlayerEvents.addEventListener

clearAllEvents()

clearAllEvents(): void;

Defined in: VideoPlayerEvents.ts:53

Clears all events from the event emitter.

Returns

void

Inherited from

VideoPlayerEvents.clearAllEvents

clearEvent()

clearEvent(event): void;

Defined in: VideoPlayerEvents.ts:63

Clears a specific event from the event emitter.

Parameters

ParameterTypeDescription
eventkeyof AllPlayerEventsThe name of the event to clear.

Returns

void

Inherited from

VideoPlayerEvents.clearEvent

getAvailableTextTracks()

getAvailableTextTracks(): TextTrack[];

Defined in: VideoPlayer.ts:263

Get all available text tracks for the current source.

Returns

TextTrack[]

Array of available text tracks

Implementation of

VideoPlayerBase.getAvailableTextTracks

initialize()

initialize(): Promise<void>;

Defined in: VideoPlayer.ts:196

Manually initialize the player. You don't need to call this method manually, unless you set initializeOnCreation to false in VideoConfig

Returns

Promise<void>

Implementation of

VideoPlayerBase.initialize

pause()

pause(): void;

Defined in: VideoPlayer.ts:226

Pause playback of player.

Returns

void

Implementation of

VideoPlayerBase.pause

play()

play(): void;

Defined in: VideoPlayer.ts:218

Start playback of player.

Returns

void

Implementation of

VideoPlayerBase.play

preload()

preload(): Promise<void>;

Defined in: VideoPlayer.ts:202

Preload the video. This is useful to avoid delay when the user plays the video. Preloading too many videos can lead to memory issues or performance issues.

Returns

Promise<void>

Implementation of

VideoPlayerBase.preload

release()

release(): void;

Defined in: VideoPlayer.ts:214

Releases the player's native resources and releases native state. After calling this method, the player is no longer usable. Accessing any properties or methods of the player after calling this method will throw an error. If you want to clean player resource use replaceSourceAsync with null instead.

Returns

void


removeEventListener()

removeEventListener<Event>(event, callback): void;

Defined in: VideoPlayerEvents.ts:43

Type Parameters

Type Parameter
Event extends keyof AllPlayerEvents

Parameters

ParameterType
eventEvent
callbackAllPlayerEvents[Event]

Returns

void

Inherited from

VideoPlayerEvents.removeEventListener

replaceSourceAsync()

replaceSourceAsync(source): Promise<void>;

Defined in: VideoPlayer.ts:250

Replace the current source of the player.

Parameters

ParameterTypeDescription
source| null | VideoSource | VideoConfigThe new source of the video.

Returns

Promise<void>

Note

If you want to clear the source, you can pass null. see VideoPlayerSourceBase

Implementation of

VideoPlayerBase.replaceSourceAsync

seekBy()

seekBy(time): void;

Defined in: VideoPlayer.ts:234

Seek by given time. If the time is negative, it will seek backward. time will be clamped if it is out of range (0 ~ duration).

Parameters

ParameterTypeDescription
timenumberThe time to seek from current time in seconds.

Returns

void

Implementation of

VideoPlayerBase.seekBy

seekTo()

seekTo(time): void;

Defined in: VideoPlayer.ts:242

Seek to a specific time in the video.

Parameters

ParameterTypeDescription
timenumberThe time to seek to in seconds.

Returns

void

Note

This have same effect as currentTime setter.

Note

time will be clamped if it is out of range (0 ~ duration).

Implementation of

VideoPlayerBase.seekTo

selectTextTrack()

selectTextTrack(textTrack): void;

Defined in: VideoPlayer.ts:272

Select a text track to display.

Parameters

ParameterTypeDescription
textTracknull | TextTrackText track to select, or null to unselect current track

Returns

void

Implementation of

VideoPlayerBase.selectTextTrack
We are TheWidlarzGroupPremium support →