Skip to main content

DrmParams

Configuration for Digital Rights Management (DRM) when playing protected video content.
interface DrmParams {
  licenseUrl?: string;
  certificateUrl?: string;
  contentId?: string;
  type?: DRMType;
  licenseHeaders?: Record<string, string>;
  multiSession?: boolean;
  getLicense?: (payload: OnGetLicensePayload) => Promise<string>;
}

Properties

licenseUrl
string
The URL for the DRM license server.Platforms: Android, iOS, visionOS
licenseUrl: 'https://drm.example.com/license'
certificateUrl
string
The URL for the DRM certificate (FairPlay only).Platforms: iOS, visionOS
certificateUrl: 'https://drm.example.com/certificate'
contentId
string
Unique identifier for the protected content (FairPlay only).Platforms: iOS, visionOS
contentId: 'content-id-123'
type
DRMType
The DRM system to use.Platforms: Android, iOS, visionOSPossible values:
  • 'widevine' - Widevine DRM (Android)
  • 'fairplay' - FairPlay DRM (iOS/visionOS)
  • Custom string for other DRM systems
type: 'widevine' // Android
type: 'fairplay' // iOS
licenseHeaders
Record<string, string>
Custom HTTP headers to send with the license request.Platforms: Android, iOS, visionOS
licenseHeaders: {
  'Authorization': 'Bearer token123',
  'X-Custom-Header': 'value'
}
multiSession
boolean
Whether to allow multiple DRM sessions simultaneously.Platforms: Android only
multiSession: true
getLicense
(payload: OnGetLicensePayload) => Promise<string>
Custom function to retrieve the license. Useful for implementing custom license acquisition logic.Platforms: iOS onlyThe function receives an OnGetLicensePayload object and must return a Promise that resolves to the license string.
getLicense: async (payload) => {
  const response = await fetch(payload.licenseUrl, {
    method: 'POST',
    body: payload.spc,
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  });
  return await response.text();
}

OnGetLicensePayload

Payload object passed to the getLicense function:
interface OnGetLicensePayload {
  contentId: string;
  licenseUrl: string;
  keyUrl: string;
  spc: string;
}
contentId
string
The content ID for the DRM license request. Unique identifier for the content being played.
licenseUrl
string
The license URL for the DRM license request.
keyUrl
string
The key URL for the DRM license request. Typically starts with skd:// or clearkey://.
spc
string
The Secure Playback Context (SPC) for the DRM license request. Base64-encoded string containing information about the playback environment.

DRMType

type DRMType = 'widevine' | 'fairplay' | (string & {});
Supported DRM types:
  • 'widevine' - Google Widevine (Android)
  • 'fairplay' - Apple FairPlay (iOS/visionOS)
  • Custom string for other DRM systems

Examples

Widevine DRM (Android)

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/protected-video.mpd',
  drm: {
    type: 'widevine',
    licenseUrl: 'https://drm.example.com/widevine/license',
    licenseHeaders: {
      'Authorization': 'Bearer token123'
    }
  }
};

FairPlay DRM (iOS)

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/protected-video.m3u8',
  drm: {
    type: 'fairplay',
    licenseUrl: 'https://drm.example.com/fairplay/license',
    certificateUrl: 'https://drm.example.com/fairplay/certificate',
    contentId: 'content-123'
  }
};

Custom License Acquisition (iOS)

import { VideoConfig, OnGetLicensePayload } from 'react-native-video';

const customGetLicense = async (payload: OnGetLicensePayload): Promise<string> => {
  // Custom license acquisition logic
  const response = await fetch(payload.licenseUrl, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/octet-stream',
      'Authorization': 'Bearer custom-token'
    },
    body: payload.spc
  });
  
  if (!response.ok) {
    throw new Error('Failed to acquire license');
  }
  
  return await response.text();
};

const config: VideoConfig = {
  uri: 'https://example.com/protected-video.m3u8',
  drm: {
    type: 'fairplay',
    licenseUrl: 'https://drm.example.com/license',
    certificateUrl: 'https://drm.example.com/certificate',
    contentId: 'content-123',
    getLicense: customGetLicense
  }
};

Multi-Session DRM (Android)

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/protected-video.mpd',
  drm: {
    type: 'widevine',
    licenseUrl: 'https://drm.example.com/license',
    multiSession: true // Allow multiple concurrent DRM sessions
  }
};

Platform Support

PropertyAndroidiOSvisionOStvOS
licenseUrl
certificateUrl-
contentId-
type
licenseHeaders
multiSession---
getLicense-
  • VideoConfig - Main video configuration type that includes DRM parameters

Build docs developers (and LLMs) love