Skip to main content
Version: v7 Beta

Class: VideoPlayer

Defined in: VideoPlayer.ts:24

Extends​

  • VideoPlayerEvents

Implements​

  • VideoPlayerBase

Constructors​

Constructor​

new VideoPlayer(source): VideoPlayer;

Defined in: VideoPlayer.ts:45

Parameters​

ParameterType
source| VideoSource | VideoConfig | VideoPlayerSource

Returns​

VideoPlayer

Overrides​

VideoPlayerEvents.constructor

Accessors​

currentTime​

Get Signature​

get currentTime(): number;

Defined in: VideoPlayer.ts:184

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:188

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

disableAudioSessionManagement​

Get Signature​

get disableAudioSessionManagement(): boolean;

Defined in: VideoPlayer.ts:262

Disables the internal audio session management for this player. When disabled, react-native-video will not configure or activate the AVAudioSession, allowing other libraries (like audio recording libraries) to manage it.

Default​
false
Platform​

iOS

Returns​

boolean

Set Signature​

set disableAudioSessionManagement(value): void;

Defined in: VideoPlayer.ts:266

Disables the internal audio session management for this player. When disabled, react-native-video will not configure or activate the AVAudioSession, allowing other libraries (like audio recording libraries) to manage it.

Default​
false
Platform​

iOS

Parameters​
ParameterType
valueboolean
Returns​

void

Implementation of​

VideoPlayerBase.disableAudioSessionManagement

duration​

Get Signature​

get duration(): number;

Defined in: VideoPlayer.ts:170

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:229

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:233

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:277

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:202

Whether the player is looped.

Returns​

boolean

Set Signature​

set loop(value): void;

Defined in: VideoPlayer.ts:206

Whether the player is looped.

Parameters​
ParameterType
valueboolean
Returns​

void

Implementation of​

VideoPlayerBase.loop

mixAudioMode​

Get Signature​

get mixAudioMode(): MixAudioMode;

Defined in: VideoPlayer.ts:220

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:224

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:193

Whether the player is muted.

Returns​

boolean

Set Signature​

set muted(value): void;

Defined in: VideoPlayer.ts:197

Whether the player is muted.

Parameters​
ParameterType
valueboolean
Returns​

void

Implementation of​

VideoPlayerBase.muted

playInBackground​

Get Signature​

get playInBackground(): boolean;

Defined in: VideoPlayer.ts:244

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:248

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:253

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:257

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:211

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:215

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(): TextTrack | undefined;

Defined in: VideoPlayer.ts:376

Get the currently selected text track.

Returns​

TextTrack | undefined

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:281

Whether to show notification controls (lock screen / control center).

Returns​

boolean

Set Signature​

set showNotificationControls(value): void;

Defined in: VideoPlayer.ts:285

Whether to show notification controls (lock screen / control center).

Parameters​
ParameterType
valueboolean
Returns​

void

Implementation of​

VideoPlayerBase.showNotificationControls

source​

Get Signature​

get source(): VideoPlayerSource;

Defined in: VideoPlayer.ts:160

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:165

The status of the player.

Returns​

VideoPlayerStatus

Implementation of​

VideoPlayerBase.status

volume​

Get Signature​

get volume(): number;

Defined in: VideoPlayer.ts:175

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:179

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): ListenerSubscription;

Defined in: events/VideoPlayerEvents.native.ts:18

Type Parameters​

Type Parameter
Event extends keyof VideoPlayerEvents | "onError"

Parameters​

ParameterType
eventEvent
callbackAllPlayerEvents[Event]

Returns​

ListenerSubscription

Implementation of​

VideoPlayerBase.addEventListener

Inherited from​

VideoPlayerEvents.addEventListener

clearAllEvents()​

clearAllEvents(): void;

Defined in: events/VideoPlayerEvents.native.ts:139

Returns​

void

Inherited from​

VideoPlayerEvents.clearAllEvents

getAvailableTextTracks()​

getAvailableTextTracks(): TextTrack[];

Defined in: VideoPlayer.ts:358

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:289

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:319

Pause playback of player.

Returns​

void

Implementation of​

VideoPlayerBase.pause

play()​

play(): void;

Defined in: VideoPlayer.ts:311

Start playback of player.

Returns​

void

Implementation of​

VideoPlayerBase.play

preload()​

preload(): Promise<void>;

Defined in: VideoPlayer.ts:295

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:307

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

Implementation of​

VideoPlayerBase.release

replaceSourceAsync()​

replaceSourceAsync(source): Promise<void>;

Defined in: VideoPlayer.ts:343

Replace the current source of the player.

Parameters​

ParameterTypeDescription
source| VideoSource | VideoConfig | nullThe 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:327

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:335

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:367

Select a text track to display.

Parameters​

ParameterTypeDescription
textTrackTextTrack | nullText track to select, or null to unselect current track

Returns​

void

Implementation of​

VideoPlayerBase.selectTextTrack