CLAppleTVPlayer
The AVPlayerViewController proxy, which provides playback capabilities using the default system UI.
Example
import {CLAppleTVPlayer} from '@castlabs/react-native-prestoplay';
Remarks
Not supported on Android.
Constructors
new CLAppleTVPlayer()
new CLAppleTVPlayer(): CLAppleTVPlayer
Properties
audioTrackChanged
static audioTrackChanged?: AudioTrackChangedCallback;
Triggered on audio track changed.
didPlayToEnd
static didPlayToEnd?: GenericEventCallback;
Triggered on playback ended. Close the player or change the stream here.
didSeek
static didSeek?: DidSeekCallback;
Triggered on seeking completed.
onError
static onError?: ErrorEventCallback;
Triggered on error thrown.
playerIsClosed
static playerIsClosed?: GenericEventCallback;
Triggered on player closed.
skipToNextChannel
static skipToNextChannel?: GenericEventCallback;
Triggered on the next channel skipped in a live stream.
Call replaceStream()
or replaceStreamAndActions()
with the next TVStream
value.
skipToPreviousChannel
static skipToPreviousChannel?: GenericEventCallback;
Triggered on the previous channel skipped in a live stream.
Call replaceStream()
or replaceStreamAndActions()
with the previous TVStream
value.
subtitleTrackChanged
static subtitleTrackChanged?: SubtitleTrackChangedCallback;
Triggered on subtitle track changed.
timeControlStatus
static timeControlStatus?: GenericEventCallback;
Triggered on playback status changed.
willSeek
static willSeek?: WillSeekCallback;
Triggered on seeking started.
Methods
addActionListener()
static addActionListener(listener): EmitterSubscription
Subscribes to the action event.
Parameters
Parameter | Type | Description |
---|---|---|
listener | (event ) => void | the listener |
Returns
the event subscription
Example
CLAppleTVPlayer.addActionListener((event: any) => {
switch (event.id) {
case ActionId.Speed:
CLAppleTVPlayer.setRate(Number(event.data));
break;
case ActionId.Skip00:
CLAppleTVPlayer.seekToSecond(15);
break;
}
});
closePlayer()
static closePlayer(): void
Closes the player.
getAudioTrack()
static getAudioTrack(): Promise<AudioTrack>
Returns the current audio track.
Returns
the current audio track
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>
Returns the current playhead.
Returns
the current position in seconds
getSubtitleTrack()
static getSubtitleTrack(): Promise<SubtitleTrack>
Returns the current subtitle track.
Returns
the current subtitle track
openPlayer()
static openPlayer(
stream,
options?,
transportBarActions?,
infoTabActions?,
contextualActions?,
onError?,
onSuccess?): void
Opens the player.
Parameters
Parameter | Type | Description |
---|---|---|
stream | TVStream | the stream configuration |
options ? | PlayerOptions | the player options |
transportBarActions ? | (Action | PopupMenu )[] | the transport bar actions |
infoTabActions ? | Action [] | the info tab actions |
contextualActions ? | Action [] | the contextual actions |
onError ? | (error ) => void | the error callback |
onSuccess ? | () => void | the success callback |
pause()
static pause(): void
Pauses playback.
play()
static play(): void
Starts playback.
removeActionListener()
static removeActionListener(subscription): void
Unsubscribes from the action event.
Parameters
Parameter | Type | Description |
---|---|---|
subscription | EmitterSubscription | the event subscription |
replaceStream()
static replaceStream(
stream,
onError?,
onSuccess?): void
Changes the playback stream.
Parameters
Parameter | Type | Description |
---|---|---|
stream | TVStream | the stream configuration |
onError ? | (error ) => void | the error callback |
onSuccess ? | () => void | the success callback |
replaceStreamAndActions()
static replaceStreamAndActions(
stream,
options?,
transportBarActions?,
infoTabActions?,
contextualActions?,
onError?,
onSuccess?): void
Changes the playback stream, options, and actions.
Parameters
Parameter | Type | Description |
---|---|---|
stream | TVStream | the stream configuration |
options ? | PlayerOptions | the player options |
transportBarActions ? | (Action | PopupMenu )[] | the transport bar actions |
infoTabActions ? | Action [] | the info tab actions |
contextualActions ? | Action [] | the contextual actions |
onError ? | (error ) => void | the error callback |
onSuccess ? | () => void | the success callback |
seekToSecond()
static seekToSecond(second): void
Moves playhead to the given position.
Parameters
Parameter | Type | Description |
---|---|---|
second | number | the new position in seconds |
setActionStateAndUi()
static setActionStateAndUi(
id,
state,
uiProp): void
Changes the state of the action and UI appearance.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | the action identifier |
state | boolean | the action state |
uiProp | ActionUiProperty | the action title and image resource name in Xcode project |
setContextualActions()
static setContextualActions(contextualActions): void
Sets contextual actions.
Parameters
Parameter | Type | Description |
---|---|---|
contextualActions | Action [] | the contextual actions |
setInfoTabActions()
static setInfoTabActions(infoTabActions): void
Sets info tab actions.
Parameters
Parameter | Type | Description |
---|---|---|
infoTabActions | Action [] | the info tab actions |
setMetadata()
static setMetadata(metadata): void
Sets the metadata to be displayed in the title view and info tab.
Parameters
Parameter | Type | Description |
---|---|---|
metadata | ChannelMetadata | the channel metadata |
setOptions()
static setOptions(options): void
Sets player options.
Parameters
Parameter | Type | Description |
---|---|---|
options | PlayerOptions | the player options |
setRate()
static setRate(rate): void
Sets the new playback rate.
Parameters
Parameter | Type | Description |
---|---|---|
rate | number | the playback rate |
setTransportBarActions()
static setTransportBarActions(transportBarActions): void
Sets transport bar actions.
Parameters
Parameter | Type | Description |
---|---|---|
transportBarActions | (Action | PopupMenu )[] | the transport bar actions |