Skip to main content

API Reference

Functions

Authorization

registerPlugin(apiKey: string): Promise<boolean>

enables plugin for current app instance

disablePlugin(): Promise<boolean>

disables plugin for current app instance

isRegistered(): boolean

checks if plugin is enabled for current app instance

Configuration

setConfig(config: Config): Promise<void>

sets global configuration for plugin

see Config

getConfig(): Promise<Config>

gets global configuration for plugin

see Config

Download Stream

downloadStream(url: string, options?: DownloadOptions): Promise<DownloadStatus>

downloads stream or video from the internet

see DownloadOptions

cancelDownload(id: string): Promise<void>

cancels download of a stream or video

cancelAllDownloads(): Promise<void>

cancels all downloads

pauseDownload(id: string): Promise<void>

pauses download of a stream or video

resumeDownload(id: string): Promise<void>

resumes download of a stream or video

getDownloadStatus(id: string): Promise<DownloadStatus>

gets status of a stream or video download

see DownloadStatus

getDownloadsStatus(): Promise<Array<DownloadStatus>>

gets status of all downloads

see DownloadStatus

Asset

getDownloadedAssets(): Promise<Array<DownloadedAsset>>

gets all downloaded assets

see DownloadedAsset

getDownloadedAsset(id: string): Promise<DownloadedAsset>

gets a downloaded asset by id

see DownloadedAsset

deleteDownloadedAsset(id: string): Promise<void>

deletes a downloaded asset by id

deleteAllDownloadedAssets(): Promise<void>

deletes all downloaded assets

Types

Config

interface Config {
// How often to update the download progress
updateFrequencyMS: number;
// How many files to download in parallel
maxParallelDownloads: number;
}

DownloadOptions

interface DownloadOptions {
// Include all (audio and text) tracks from stream in the download
includeAllTracks?: boolean;
// Date when the download will expire. Once download is expired, it will be deleted from the device.
expiresAt?: number;
}

DownloadStatus

interface DownloadStatus {
// Unique identifier for the download
id: string;
// URL of the stream or video
url: string;
// Number of bytes received
receivedBytes?: number;
// Total number of bytes to download
totalBytes?: number;
// Progress of the download (0-1)
progress: number; // 0-1 eg. 0.55
// Status of the download
status: 'pending' | 'downloading' | 'paused' | 'completed' | 'failed';
// Error message if the download failed
error?: string;
}

DownloadedAsset

interface DownloadedAsset {
// Unique identifier for the downloaded asset
id: string;
// URL of the stream or video
url: string;
// Path to the file on the device
pathToFile: string;
// Title of the stream or video
title: string;
// Duration of the stream or video
duration: number;
// Date when the downloaded asset will expire. Once downloaded asset is expired, it will be deleted from the device.
expiresAt?: number;
}