Skip to main content

CLVideo

Example

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

Extends

Constructors

new CLVideo(props)

new CLVideo(props): CLVideo

Parameters

ParameterType
propsCLVideoProps

Overrides

Component<CLVideoProps>.constructor

Accessors

instanceId

get instanceId(): undefined | number

isAuthenticated

get static isAuthenticated(): boolean

Checks if the component has been authenticated.

Returns

True if the component has been authenticated with given license keys.

Methods

componentDidUpdate()

componentDidUpdate(prevProps, prevState): void

Parameters

ParameterType
prevPropsReadonly<CLVideoProps>
prevStateReadonly<any>

Overrides

Component.componentDidUpdate


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.


getPlaybackRate()

getPlaybackRate(): Promise<number>

Returns speed of the playback.

Returns

The current speed of the playback, where 1 means "normal" speed.


getPlayerConfiguration()

getPlayerConfiguration(): undefined | PlayerConfiguration

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.


getStats()

getStats(): Promise<Stats>

Returns statistics and information about the current state of the player.

Returns

The statistics.


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

ParameterTypeDescription
positionnumberPosition 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


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.


isLive()

isLive(): Promise<boolean>

Returns true if the stream is live.

Returns

Weather the stream is live or not


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(): ReactNode

Overrides

Component.render


setAudioTrack()

setAudioTrack(index): void

Sets the current audio track.

Parameters

ParameterTypeDescription
indexnumberThe index of the audio track in the () array.

setPlaybackRate()

setPlaybackRate(newPlaybackRate): void

Sets speed of the playback, where 1 means "normal" speed.

On iOS and tvOS, the playback rate can only be increased if the current position is not near the live edge. This behaviour in AVPlayer is designed to prevent stalling.

Parameters

ParameterTypeDescription
newPlaybackRatenumberThe new playback rate, where 1 means "normal" speed.

setPosition()

setPosition(newPosition): void

Sets the new position.

Parameters

ParameterTypeDescription
newPositionnumberThe new position in seconds.

setSubtitleStyle()

setSubtitleStyle(style): void

Sets the style of the text track.

Parameters

ParameterTypeDescription
styleSubtitleStyleThe style of the text track.

setSubtitleTrack()

setSubtitleTrack(index): void

Sets the current text track

Parameters

ParameterTypeDescription
indexnumberThe index of the text track in the () array.

setThumbnail()

setThumbnail(thumbnail): void

Registers the CLThumbnail component.

Parameters

ParameterTypeDescription
thumbnailCLThumbnailThe CLThumbnail component.

setVideoQuality()

setVideoQuality(index): void

Sets the current video quality.

Parameters

ParameterTypeDescription
indexnumberThe index of the video quality in the getVideoQualities array

setVolume()

setVolume(newVolume): void

Sets the new volume.

Parameters

ParameterTypeDescription
newVolumenumberThe new volume, a value between 0 and 1.

shouldComponentUpdate()

shouldComponentUpdate(
nextProps,
nextState,
nextContext): boolean

Parameters

ParameterType
nextPropsReadonly<CLVideoProps>
nextStateReadonly<any>
nextContextany

Overrides

Component.shouldComponentUpdate


togglePictureInPicture()

togglePictureInPicture(): void

Activates or deactivates the picture-in-picture mode.


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

ParameterTypeDescription
sdkConfigSDKConfigurationThe 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',
}
});