CLVideo
Example
import {CLVideo} from '@castlabs/react-native-prestoplay';
Extends
Component
<CLVideoProps
,States
>
Constructors
new CLVideo(props)
new CLVideo(props): CLVideo
Parameters
Parameter | Type |
---|---|
props | CLVideoProps |
Overrides
Component<CLVideoProps, States>.constructor
Properties
instanceId
instanceId: number = C.UNSET;
isAuthenticated
static isAuthenticated: boolean = false;
Methods
getAudioTrack()
getAudioTrack(): Promise<AudioTrack>
Returns the current audio track.
Returns
The current audio track.
getAudioTracks()
getAudioTracks(): Promise<AudioTrack[]>
Returns all audio tracks.
Returns
All audio tracks.
getBufferedPercentage()
getBufferedPercentage(): Promise<number>
Returns the buffering progress.
Returns
The buffering progress as percentage.
getDuration()
getDuration(): Promise<number>
Returns the total duration of content.
Returns
The total content duration in seconds
getLiveStartTime()
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.
getPlayerState()
getPlayerState(): Promise<PlayerState>
Returns the current player state.
Returns
The current player state
getPosition()
getPosition(): Promise<number>
Returns the current position.
Returns
The current position in seconds.
getProgressPercentage()
getProgressPercentage(): Promise<number>
Returns the playback progress.
Returns
The playback progress as percentage.
getSubtitleTrack()
getSubtitleTrack(): Promise<SubtitleTrack>
Returns the current text track.
Returns
The current text track.
getSubtitleTracks()
getSubtitleTracks(): Promise<SubtitleTrack[]>
Returns all text tracks.
Returns
All text tracks.
getThumbnailData()
getThumbnailData(position): void
This method doesn't return anything but will trigger CLVideoProps.onThumbnailLoaded event if the thumbnail is loaded. It also sets the bitmap of the thumbnail component if the component is set to this video component.
Parameters
Parameter | Type | Description |
---|---|---|
position | number | Position in seconds |
getVideoQualities()
getVideoQualities(): Promise<VideoQuality[]>
Returns all video qualities.
Returns
All video qualities.
getVideoQuality()
getVideoQuality(): Promise<VideoQuality>
Returns the current video quality.
Returns
The current video quality.
getVideoQualityMode()
getVideoQualityMode(): Promise<string>
Returns the current video quality mode.
Returns
C.VIDEO_QUALITY_ADAPTIVE or [C.VIDEO_QUALITY_MANUAL](Property VIDEO_QUALITY_MANUAL:string)
getVolume()
getVolume(): Promise<number>
Returns the current volume.
Returns
The current volume, a value between 0 and 1.
isAirplayPossible()
isAirplayPossible(): Promise<boolean>
Checks whether the AirPlay is available or not.
Returns
true
if AirPlay is available; Otherwise false
.
isPictureInPicturePossible()
isPictureInPicturePossible(): Promise<boolean>
Checks whether the picture-in-picture mode is available or not.
Returns
true
if picture-in-picture mode is available; Otherwise false
.
isPlayWhenReady()
isPlayWhenReady(): boolean
Returns true if the player will transition into playing state when enough data is loaded. If false the player will transition into paused state. Note that the player can have intermediate states until it reaches the playing state.
Returns
True if the video will play when enough data, false otherwise.
pause()
pause(): Promise<void>
Pauses the video.
play()
play(): Promise<void>
Plays the video.
render()
render(): Element
Overrides
Component.render
setAudioTrack()
setAudioTrack(index): void
Sets the current audio track.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the audio track in the () array. |
setCastButton()
setCastButton(castButton): void
Registers the CLCastButton component.
Parameters
Parameter | Type | Description |
---|---|---|
castButton | CLCastButton | The CLCastButton component. |
setPlayerConfig()
setPlayerConfig(playerConfig): void
Sets the player configuration.
Parameters
Parameter | Type | Description |
---|---|---|
playerConfig | PlayerConfiguration | The configuration of the player. |
Returns
Example
video.setPlayerConfig({
version: '1',
contentUrl: 'http://demo.cf.castlabs.com/media/TOS/DASH/DEMO.mpd',
drmType: DrmType.DRMTODAY,
drmSystem: DrmSystem.WIDEVINE,
drmConfiguration: {
environment: DRMEnvironment.STAGING,
userId: 'purchase',
sessionId: 'sessionId',
merchant: 'six',
assetId: 'dasheverywhere_demo',
}
});
setPosition()
setPosition(newPosition): void
Sets the new position.
Parameters
Parameter | Type | Description |
---|---|---|
newPosition | number | The new position in seconds. |
setSubtitleStyle()
setSubtitleStyle(style): void
Sets the style of the text track.
Parameters
Parameter | Type | Description |
---|---|---|
style | SubtitleStyle | The style of the text track. |
setSubtitleTrack()
setSubtitleTrack(index): void
Sets the current text track
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the text track in the () array. |
setThumbnail()
setThumbnail(thumbnail): void
Registers the CLThumbnail component.
Parameters
Parameter | Type | Description |
---|---|---|
thumbnail | CLThumbnail | The CLThumbnail component. |
setVideoQuality()
setVideoQuality(index): void
Sets the current video quality.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the video quality in the getVideoQualities array |
setVolume()
setVolume(newVolume): void
Sets the new volume.
Parameters
Parameter | Type | Description |
---|---|---|
newVolume | number | The new volume, a value between 0 and 1. |
togglePictureInPicture()
togglePictureInPicture(): void
Activates or deactivates the picture-in-picture mode.
getDerivedStateFromProps()
static getDerivedStateFromProps(props, state): null | object
Parameters
Parameter | Type |
---|---|
props | any |
state | any |
initialize()
static initialize(sdkConfig): Promise<void>
Initializes the CLVideo component.
This method should be called once before using the CLVideo component. Licence keys are associated with your application ID. Please contact support for more information on how to obtain licence keys.
Parameters
Parameter | Type | Description |
---|---|---|
sdkConfig | SDKConfiguration | The configuration of the PRESTOplay SDK. |
Returns
If the promise is resolved, the CLVideo component is fully initialized and ready to use.
Example
CLVideo.initialize({
licenseKey: {
android: 'my-android-key',
iOS: 'my-ios-key',
tvOS: 'my-ios-key',
}
});