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.
streamChanged
static streamChanged?: StreamChangedCallback;
Triggered on stream changed.
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
getCurrentStreamIndex()
static getCurrentStreamIndex(): Promise<number>
Returns the index of the current stream.
Returns
the current stream index
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(
streams,
options?,
transportBarActions?,
infoTabActions?,
contextualActions?,
loopStreams?,
onError?,
onSuccess?): void
Opens the player.
In non-live channels, channel flipping is not supported, and users cannot change the channel using the TV remote control. However, the player automatically moves to the next item when playback reaches the end.
When loopStream
is false
, the player ignores next or previous channel
requests when the current stream is the last or first item in the list.
The player still displays the channel interstitial view,
but it does not change the stream.
Parameters
Parameter | Type | Description |
---|---|---|
streams | 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 |
loopStreams ? | Boolean | loops through the streams list. Default is true . |
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 |
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 |