Skip to main content

CLDownloader

Example​

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

Constructors​

new CLDownloader()​

new CLDownloader(): CLDownloader

Properties​

instanceId​

instanceId: null | string = null;

Methods​

delete()​

delete(): void

Deletes the selected download.


getLocalManifestUrl()​

getLocalManifestUrl(): Promise<string>

Returns the local manifest file path. It could be used for offline playing.

Returns​

The local file path of the manifest.


getProgress()​

getProgress(): Promise<DownloadProgress>

Returns the progress of the selected download.

Returns​

The progress of the selected download.


getState()​

getState(): Promise<DownloadState>

Returns the selected download state.

Returns​

The state of the download.


getTracks()​

getTracks(): Promise<TrackSet>

Returns the available tracks to download.

Returns​

The available tracks.


onComplete()​

onComplete(callback): void

Binds an event handler to the download completed event.

Parameters​

ParameterTypeDescription
callbackGenericCallbackA function to execute each time the event is triggered.

onError()​

onError(callback): void

Binds an event handler to the download error event.

Parameters​

ParameterTypeDescription
callbackDownloadErrorCallbackA function to execute each time the event is triggered.

onProgress()​

onProgress(callback): void

Binds an event handler to the download progress event.

Parameters​

ParameterTypeDescription
callbackDownloadProgressCallbackA function to execute each time the event is triggered.

onStart()​

onStart(callback): void

Binds an event handler to the download started event.

Parameters​

ParameterTypeDescription
callbackGenericCallbackA function to execute each time the event is triggered.

onStop()​

onStop(callback): void

Binds an event handler to the download stopped event.

Parameters​

ParameterTypeDescription
callbackGenericCallbackA function to execute each time the event is triggered.

pause()​

pause(): void

Pauses the selected download.


prepare()​

prepare(config): Promise<TrackSet>

Creates a new download instance and selects it.

Parameters​

ParameterTypeDescription
configDownloadConfigThe download configuration

Returns​

The available tracks for download.


prepareById()​

prepareById(id): Promise<DownloadProgress>

Selects the download instance by ID. A promise is rejected if the download doesn't exist.

Parameters​

ParameterTypeDescription
idstringThe ID of the existing download.

Returns​

The download progress.

See​

prepare


resume()​

resume(): void

Resumes the selected download.


start()​

start(trackSelection): void

Starts downloading selected tracks.

Parameters​

ParameterTypeDescription
trackSelectionTrackSelectionThe selected tracks.