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
Parameter | Type | Description |
---|---|---|
listener | (event ) => void | The 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
Parameter | Type | Description |
---|---|---|
stream | TVStream | Stream configuration, metadata, and the next channel information. |
options ? | PlayerOptions | Options 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 ) => void | Error callback |
onSuccess ? | () => void | Success callback |
pause()
static pause(): void
Pauses playback
play()
static play(): void
Begins playback
removeActionListener()
static removeActionListener(subscription): void
Remove action event subscription.
Parameters
Parameter | Type | Description |
---|---|---|
subscription | EmitterSubscription | Action event subscription |
replaceStream()
static replaceStream(
stream,
onError?,
onSuccess?): void
Change the playback stream.
Parameters
Parameter | Type | Description |
---|---|---|
stream | TVStream | Stream configuration, metadata, and the next channel information. |
onError ? | (error ) => void | Error callback |
onSuccess ? | () => void | Success callback |
replaceStreamAndActions()
static replaceStreamAndActions(
stream,
options?,
transportBarActions?,
infoTabActions?,
contextualActions?,
onError?,
onSuccess?): void
Change the playback stream, options, and actions.
Parameters
Parameter | Type | Description |
---|---|---|
stream | TVStream | Stream configuration, metadata, and the next channel information. |
options ? | PlayerOptions | Options 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 ) => void | Error callback |
onSuccess ? | () => void | Success callback |
seekToSecond()
static seekToSecond(second): void
Move playback position.
Parameters
Parameter | Type | Description |
---|---|---|
second | number | Time to move in seconds |
setActionStateAndUi()
static setActionStateAndUi(
id,
state,
uiProp): void
Change action state and UI appearance.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Action idenfitier |
state | boolean | Action state, true or false |
uiProp | ActionUiProperty | Action title and image resource name in Xcode project |
setContextualActions()
static setContextualActions(contextualActions): void
Set contextual action controls.
Parameters
Parameter | Type | Description |
---|---|---|
contextualActions | Action [] | Array of Action values |
setInfoTabActions()
static setInfoTabActions(infoTabActions): void
Set info tab action controls.
Parameters
Parameter | Type | Description |
---|---|---|
infoTabActions | Action [] | Array of Action values |
setMetadata()
static setMetadata(metadata): void
Set the metadata to be displayed in the title view and info tab.
Parameters
Parameter | Type | Description |
---|---|---|
metadata | string | JSON string which contains the mainTitle , subTitle , artworkImage , and description |
setOptions()
static setOptions(options): void
Set player options.
Parameters
Parameter | Type | Description |
---|---|---|
options | PlayerOptions | PlayerOptions value |
setRate()
static setRate(rate): void
Set playback rate.
Parameters
Parameter | Type | Description |
---|---|---|
rate | number | Playback rate |
setTransportBarActions()
static setTransportBarActions(transportBarActions): void
Set transport bar action controls.
Parameters
Parameter | Type | Description |
---|---|---|
transportBarActions | any [] | Array of Action or PopupMenu values. |