Skip to main content

CLAppleTVPlayer

Example​

import {CLAppleTVPlayer} from '@castlabs/react-native-prestoplay';

Constructors​

new CLAppleTVPlayer()​

new CLAppleTVPlayer(): CLAppleTVPlayer

Properties​

audioTrackChanged​

static audioTrackChanged?: PlayerEventHandler;

Audio track is changed.


didPlayToEnd​

static didPlayToEnd?: PlayerEventHandler;

Called when the playback ended. Close the player or change the stream here.


didSeek​

static didSeek?: PlayerEventHandler;

Called after the playback position is moved.


onError​

static onError?: PlayerEventHandler;

Triggered on player error.


playerIsClosed​

static playerIsClosed?: PlayerEventHandler;

Called when a player is closed.


skipToNextChannel​

static skipToNextChannel?: PlayerEventHandler;

Called when a user tries to skip to the next channel in a live stream.


skipToPreviousChannel​

static skipToPreviousChannel?: PlayerEventHandler;

Called when a user tries to skip to the previous channel in a live stream.


subtitleTrackChanged​

static subtitleTrackChanged?: PlayerEventHandler;

Subtitle track is changed.


timeControlStatus​

static timeControlStatus?: PlayerEventHandler;

Called when playback status is updated.


willSeek​

static willSeek?: PlayerEventHandler;

Called before the playback position is moved.

Methods​

addActionListener()​

static addActionListener(listener): EmitterSubscription

Add action event listener.

Parameters​

ParameterTypeDescription
listener(event) => voidThe listener function

Returns​

Action event subscription


closePlayer()​

static closePlayer(): void

Close a player


getAudioTrack()​

static getAudioTrack(): Promise<AudioTrack>

Returns the current audio track

Returns​


getLiveStartTime()​

static getLiveStartTime(): Promise<number>

Returns the live start time. A live HLS stream has to have the EXT-X-PROGRAM-DATE-TIME defined.

Returns​

The live start time since the epoch in seconds; -1 if it is unknown or not applicable.


getPosition()​

static getPosition(): Promise<number>

Get the current playback position.

Returns​

The current position in seconds


getSubtitleTrack()​

static getSubtitleTrack(): Promise<SubtitleTrack>

Returns the current subtitle track

Returns​


openPlayer()​

static openPlayer(
stream,
options?,
transportBarActions?,
infoTabActions?,
contextualActions?,
onError?,
onSuccess?): void

Open a player

Parameters​

ParameterTypeDescription
streamTVStreamStream configuration, metadata, and the next channel information.
options?PlayerOptionsOptions to control the player.
transportBarActions?any[]Array of transport bar actions
infoTabActions?Action[]Array of info tab actions
contextualActions?Action[]Array of contextual actions
onError?(error) => voidError callback
onSuccess?() => voidSuccess callback

pause()​

static pause(): void

Pauses playback


play()​

static play(): void

Begins playback


removeActionListener()​

static removeActionListener(subscription): void

Remove action event subscription.

Parameters​

ParameterTypeDescription
subscriptionEmitterSubscriptionAction event subscription

replaceStream()​

static replaceStream(
stream,
onError?,
onSuccess?): void

Change the playback stream.

Parameters​

ParameterTypeDescription
streamTVStreamStream configuration, metadata, and the next channel information.
onError?(error) => voidError callback
onSuccess?() => voidSuccess callback

replaceStreamAndActions()​

static replaceStreamAndActions(
stream,
options?,
transportBarActions?,
infoTabActions?,
contextualActions?,
onError?,
onSuccess?): void

Change the playback stream, options, and actions.

Parameters​

ParameterTypeDescription
streamTVStreamStream configuration, metadata, and the next channel information.
options?PlayerOptionsOptions to control the player.
transportBarActions?any[]Array of transport bar actions
infoTabActions?Action[]Array of info tab actions
contextualActions?Action[]Array of contextual actions
onError?(error) => voidError callback
onSuccess?() => voidSuccess callback

seekToSecond()​

static seekToSecond(second): void

Move playback position.

Parameters​

ParameterTypeDescription
secondnumberTime to move in seconds

setActionStateAndUi()​

static setActionStateAndUi(
id,
state,
uiProp): void

Change action state and UI appearance.

Parameters​

ParameterTypeDescription
idstringAction idenfitier
statebooleanAction state, true or false
uiPropActionUiPropertyAction title and image resource name in Xcode project

setContextualActions()​

static setContextualActions(contextualActions): void

Set contextual action controls.

Parameters​

ParameterTypeDescription
contextualActionsAction[]Array of Action values

setInfoTabActions()​

static setInfoTabActions(infoTabActions): void

Set info tab action controls.

Parameters​

ParameterTypeDescription
infoTabActionsAction[]Array of Action values

setMetadata()​

static setMetadata(metadata): void

Set the metadata to be displayed in the title view and info tab.

Parameters​

ParameterTypeDescription
metadatastringJSON string which contains the mainTitle, subTitle, artworkImage, and description

setOptions()​

static setOptions(options): void

Set player options.

Parameters​

ParameterTypeDescription
optionsPlayerOptionsPlayerOptions value

setRate()​

static setRate(rate): void

Set playback rate.

Parameters​

ParameterTypeDescription
ratenumberPlayback rate

setTransportBarActions()​

static setTransportBarActions(transportBarActions): void

Set transport bar action controls.

Parameters​

ParameterTypeDescription
transportBarActionsany[]Array of Action or PopupMenu values.