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>
Experimental
sets global configuration for plugin
see Config
getConfig(): Promise<Config>
In Progress
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 | null>
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 | null>
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
deleteQueuedItem(id: string): Promise<void>
In Progress
deletes a specific asset from queue
deleteAllQueuedItems(): Promise<void>
In Progress
deletes all queued items
expireDownloadedAssetAt(id: string, timestamp: number): Promise<void>
manually sets an expiration timestamp for an asset
Types
Config
interface Config {
// How often to update the download progress (in milliseconds)
// @default 1000
updateFrequencyMS?: number;
// How many files to download in parallel
// @default 1
maxParallelDownloads?: number;
}
DownloadOptions
interface DownloadOptions {
// Whether to check storage space before starting download
// @default false
checkStorageBeforeDownload?: boolean;
// Date when the download will expire. Once download is expired, it will be deleted from the device.
expiresAt?: Date;
// Whether to download all available tracks (audio, video, subtitles)
// @default false
includeAllTracks?: boolean;
// DRM configuration for protected content
drm?: DRMConfig;
// Custom metadata to store with the download
metadata?: Metadata;
}
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"
| "removed";
// Error message if the download failed
error?: string;
// Metadata associated with the download
metadata?: Metadata;
}
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
// Android: URL pointing to cached video file
// iOS: Actual file path to the downloaded video file
pathToFile: string;
// Title of the stream or video
title: string;
// Duration of the stream or video in milliseconds
duration: number;
// Date when the asset was downloaded
downloadDate: Date;
// Date when the downloaded asset will expire. Once downloaded asset is expired, it will be deleted from the device.
expiresAt?: Date;
// Custom metadata stored with the download
metadata?: Metadata;
}
Metadata
interface Metadata {
/**
* Title of the downloaded asset.
* Used by plugin for file naming.
*/
title?: string;
[key: string]: unknown;
}