This is a React Native project demonstrating how to play DRM-protected video streams using Gumlet on both Android (Widevine) and iOS (FairPlay) platforms. It uses react-native-video for media playback.
Before starting, ensure you have set up your local development environment according to the React Native Environment Setup Guide.
To play your DRM streams, configure the following inputs in the app interface:
- HLS URL: The
.m3u8stream URL for the video. - FairPlay License URL: The license server URL for FairPlay.
- FairPlay Certificate URL: The certificate URL used to request the FairPlay license.
- MPD URL: The MPEG-DASH
.mpdstream URL (Widevine DRM is not supported on HLS.m3u8formats in standard Android environments; you must use DASH.mpd). - Widevine License Proxy URL: The base license server URL.
- Format:
https://widevine.gumlet.com/licence/<ORG_ID>/<ASSET_ID> - Note: Ensure this URL does not contain pre-existing query parameters, as the app will automatically sign and append the required
tokenandexpiresquery parameters.
- Format:
- Widevine Proxy Secret (Base64): Your organization's token signing secret key from the Gumlet DRM Dashboard. This key is used on the client-side to dynamically generate an HMAC-SHA1 signature token.
- Token Lifetime (seconds): The validity window for the dynamically generated signature token.
Run the following command from the root of your project:
npm install
# or
yarn installIf you are running the app on iOS, navigate to the ios directory and install the pods:
cd ios
pod install
cd ..npm run ios
# or
yarn iosnpm run android
# or
yarn androidTo prevent unauthorized access, Gumlet requires each license request to be signed using an HMAC-SHA1 signature.
The client automatically generates the signature on playback using the following formula:
- Extract the Path: The protocol, host, and
/licenceprefix are stripped to get the core identifier path (e.g.,/<ORG_ID>/<ASSET_ID>). - Calculate Expiration: A timestamp in milliseconds representing
now + token_lifetimeis calculated. - Generate Message: The message to sign is constructed as:
/<ORG_ID>/<ASSET_ID>?expires=<expiration_timestamp> - HMAC-SHA1 Signature: The message is signed using the Base64-decoded
Widevine Proxy Secretkey. - Append parameters: The resulting hex signature and the expiration timestamp are appended to the license request URL:
?token=<hex_signature>&expires=<expiration_timestamp>