Configuration setConfig(config: DownloadConfig): void Sets global configuration for downloads.
Parameters:
config: Configuration with the following properties: updateFrequencyMS?: number - How often to update download progress (in milliseconds) maxParallelDownloads?: number - Maximum number of simultaneous downloads import { setConfig } from "@TheWidlarzGroup/react-native-video-stream-downloader";
setConfig({ updateFrequencyMS: 1000, maxParallelDownloads: 3, });
Download Management downloadStream(url: string, options?: DownloadOptions): Promise Downloads a video stream for offline playback.
Parameters:
url: The URL of the video stream to download options: Optional download configuration with the following properties: includeAllTracks?: boolean - Whether to download all available tracks (default: false) tracks?: Track[] - Array of specific tracks to download. Each track has: id: string - Track identifier type: 'video' | 'audio' | 'text' - Track type language?: string - Language code (for audio/text tracks) expiresAt?: number - Unix timestamp when the download should expire drm?: DRMConfig - DRM configuration (see DRM Downloading for details) metadata?: Record<string, string> - Custom metadata to store with the download Returns: Promise - Status immediately after adding to queue (not after completion) DownloadStatus properties:
id: string - Unique download identifier url: string - Source URL status: 'queued' | 'downloading' | 'paused' | 'completed' | 'failed' | 'cancelled' - Current status progress: number - Download progress (0-1) bytesDownloaded: number - Number of bytes downloaded totalBytes: number - Total bytes to download (may be undefined until known) import { downloadStream } from "@TheWidlarzGroup/react-native-video-stream-downloader";
const status = await downloadStream("https://example.com/video.m3u8", { tracks: [ { id: "video-1", type: "video" }, { id: "audio-en", type: "audio", language: "en" }, ], });
Track Inspection getAvailableTracks(url: string): Promise Retrieves information about available audio, video, and subtitle tracks in a stream.
Parameters:
url: The URL of the video stream to inspect Returns: Promise with the following structure:
video: VideoTrack[] - Available video tracks, each with: id: string - Track identifier width: number - Video width in pixels height: number - Video height in pixels bitrate: number - Bitrate in bits per second audio: AudioTrack[] - Available audio tracks, each with: id: string - Track identifier language: string - Language code (e.g., "en", "es") bitrate: number - Bitrate in bits per second text: TextTrack[] - Available subtitle tracks, each with: id: string - Track identifier language: string - Language code type: string - Subtitle format (e.g., "text/vtt") import { getAvailableTracks } from "@TheWidlarzGroup/react-native-video-stream-downloader";
const tracks = await getAvailableTracks("https://example.com/video.m3u8");
// Use tracks.video, tracks.audio, tracks.text to let user select // Then pass selected tracks to downloadStream