Skip to main content

Player

Represents the native player and provides methods for its control.

Getter methods do not rely on the React Native bridge; they return cached values instead. Cached values are updated via the event pipeline. Setter methods use the React Native bridge to modify the native player.

Extends

  • default

Implements

  • default

Methods

getTrackManager()

getTrackManager(): TrackManager

Returns the track manager.

Returns

TrackManager


getFatalError()

getFatalError(): null | PrestoPlayError

Returns the last fatal error that occurred.

Returns

null | PrestoPlayError


getState()

getState(): PlayerState

Returns the current player state.

Returns

PlayerState


getPosition()

getPosition(): number

Returns the current playback position in milliseconds.

Returns

number


getPlayerConfiguration()

getPlayerConfiguration(): null | PlayerConfiguration

Returns the current player configuration, or null if it's unavailable.

Returns

null | PlayerConfiguration


setPosition()

setPosition(newPosition): Promise<void>

Seeks to a new position.

Parameters

ParameterTypeDescription
newPositionnumberNew position in milliseconds.

Returns

Promise<void>


isLive()

isLive(): boolean

Returns whether the player is playing a live stream.

Returns

boolean


getDuration()

getDuration(): number

Returns the duration of the current stream in milliseconds.

Returns

number


getVolume()

getVolume(): number

Returns

number


setVolume()

setVolume(newVolume): Promise<void>

Parameters

ParameterType
newVolumenumber

Returns

Promise<void>


getPlaybackRate()

getPlaybackRate(): number

Returns the current playback speed, where 1 represents 'normal' speed.

Returns

number


getPlaybackStats()

getPlaybackStats(): null | PlaybackStats

Returns the current playback session metrics if available. Otherwise, returns null. The values are reset each time a new stream is loaded.

Returns

null | PlaybackStats


getLiveStartTime()

getLiveStartTime(): null | number

Returns the live start time. A live HLS stream has to have the EXT-X-PROGRAM-DATE-TIME defined. NOTE: Not available on iOS for DASH.

Returns

null | number

The live start time since the epoch in milliseconds; null if it is unknown or not applicable.


getSeekableRange()

getSeekableRange(): null | { startTime: number; endTime: number; }

Returns the seekable range times in milliseconds

Returns

null | { startTime: number; endTime: number; }

The seekable range or null if unavailable


setPlaybackRate()

setPlaybackRate(newPlaybackRate): Promise<void>

Set the playback speed, where 1 represents 'normal' speed.

Note that setting speed for the online playback with high video quality may result in video stuttering/lagging, and it is advised to disable the ABR by setting one of the low video qualities before changing the playback speed.

Parameters

ParameterTypeDescription
newPlaybackRatenumberThe new speed at which the video is being played.

Returns

Promise<void>

Remarks

On Android, when the requested speed is different from 1, then the audio is disabled and otherwise is enabled automatically. On iOS, when the requested speed is higher than 2, then the audio is disabled.


isMuted()

isMuted(): boolean

Returns

boolean


setMuted()

setMuted(newMuted): Promise<void>

Parameters

ParameterType
newMutedboolean

Returns

Promise<void>


isPlayWhenReady()

isPlayWhenReady(): boolean

Returns

boolean


isPictureInPictureMode()

isPictureInPictureMode(): boolean

Returns

boolean


open()

open(playerConfiguration): Promise<void>

Parameters

ParameterType
playerConfigurationPlayerConfiguration

Returns

Promise<void>


play()

play(): Promise<void>

Returns

Promise<void>


replay()

replay(): Promise<void>

Returns

Promise<void>


pause()

pause(): Promise<void>

Returns

Promise<void>


stop()

stop(): Promise<void>

The current playback is stopped.

The player instance can still be used. For example, a new stream can be loaded using Player.open. Once stopped, the player is put into the PlayerState.Idle state.

Returns

Promise<void>


destroy()

destroy(): Promise<void>

Returns

Promise<void>


supportsPictureInPicture()

supportsPictureInPicture(): Promise<undefined | boolean>

Returns

Promise<undefined | boolean>


enterPictureInPictureMode()

enterPictureInPictureMode(): Promise<void>

Returns

Promise<void>


exitPictureInPictureMode()

exitPictureInPictureMode(): Promise<void>

Exits Picture-in-Picture (PiP) mode when supported by the platform.

Returns

Promise<void>

Platform

Android Android does not provide a programmatic API to exit PiP mode. As a result, this method is a no-op on Android and resolves immediately without performing any action.


getExtension()

getExtension<T>(extensionClass): T

Returns the extension of the specified type.

Throws the ErrorCode.PlayerExtensionNotFound error if the extension is not found.

Type Parameters

Type Parameter
T extends PlayerExtension<T>

Parameters

ParameterTypeDescription
extensionClassPlayerExtensionConstructor<T>The extension class.

Returns

T


addEventListener()

addEventListener(eventType, callback): void

Parameters

ParameterType
eventTypeEventType
callbackEventCallback

Returns

void

Inherited from

BaseEventEmitter.addEventListener


removeEventListener()

removeEventListener(eventType, callback): void

Parameters

ParameterType
eventTypeEventType
callbackEventCallback

Returns

void

Inherited from

BaseEventEmitter.removeEventListener