This feature is available exclusively in Pro Player. To access this functionality, please contact us.
DRM Downloading
The Offline Video SDK supports downloading and playing DRM-protected content offline, including support for persistent licenses.
Prerequisites
Your DRM provider must support persistent/offline licenses. Not all DRM providers support this feature. Contact your DRM provider to confirm offline license support before implementing.
To download DRM-protected content, you need:
- Encrypted media: Video content encrypted with DRM (Widevine, FairPlay, PlayReady)
- License server: A license server that supports persistent/offline licenses
- Short-lived token: Authentication token for license acquisition (if required)
High-level Flow
- Content Preparation: Media is encrypted and packaged with DRM
- License Server Configuration: License server is configured to issue persistent licenses
- Download with DRM Config: Call
downloadStreamwith DRM configuration - License Acquisition: SDK automatically acquires and stores persistent license
- Offline Playback: Downloaded content can be played offline using the stored license
Configuration
The drm property in downloadStream accepts a DRMConfig with the following properties:
licenseServer: string- URL of the license servercertificateUrl?: string- Certificate URL (required for FairPlay on iOS)headers?: Record<string, string>- HTTP headers for license requestsgetLicense?: (spcData: ArrayBuffer) => Promise<ArrayBuffer>- Custom license acquisition function (iOS only, FairPlay)
See DRMConfig in API Reference for complete type definition.
Basic DRM Configuration
import { downloadStream } from "@TheWidlarzGroup/react-native-video-stream-downloader";
await downloadStream(videoUrl, {
drm: {
licenseServer: "https://license.example.com/acquire",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
},
},
});
FairPlay (iOS)
For FairPlay on iOS, you also need to provide the certificate URL:
await downloadStream(videoUrl, {
drm: {
licenseServer: "https://license.example.com/acquire",
certificateUrl: "https://license.example.com/certificate.cer",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
},
},
});
Custom License Acquisition (iOS only)
On iOS, you can provide a custom license acquisition function:
await downloadStream(videoUrl, {
drm: {
licenseServer: "https://license.example.com/acquire",
certificateUrl: "https://license.example.com/certificate.cer",
getLicense: async (spcData: ArrayBuffer) => {
// Custom license acquisition logic
const response = await fetch("https://license.example.com/acquire", {
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"Authorization": "Bearer YOUR_TOKEN",
},
body: spcData,
});
return await response.arrayBuffer();
},
},
});
Platform-Specific Notes
Android
- Supports Widevine and PlayReady
- License acquisition is handled automatically by the SDK
- Ensure your license server supports persistent licenses
iOS
- Supports FairPlay
- Requires
certificateUrlfor FairPlay - Custom license acquisition via
getLicenseis optional but available - FairPlay configuration should match your
react-native-videoDRM setup
Testing
Always test DRM downloading on a real device. Simulators/emulators may not properly handle DRM operations.
When testing:
- Ensure your test content is properly encrypted
- Verify your license server supports persistent licenses
- Test on both iOS and Android devices
- Verify offline playback works after download completes
- Test license expiration scenarios
FairPlay Notes
The FairPlay configuration for offline downloading should match your react-native-video DRM configuration exactly. Use the same:
licenseServerURLcertificateUrlheaders(if applicable)getLicensefunction (if using custom acquisition)
This ensures consistency between online and offline playback.