A React-Native pallycon-react-native-sdk plugin which provides easy to apply Multi-DRM(Android: Widevine, iOS: FairPlay) when developing media service apps for Android and iOS. Please refer to the links below for detailed information.
- Android 6.0 (API 23) & Android targetSdkVersion 34 or higher
- iOS 14.0 higher
- To develop using the SDK, you must first sign up for the PallyCon Site and obtain a
Site ID
.
To add PallyCon Multi-DRM Sdk
to your React-Native app, read the Installation instructions. Below are the Android and iOS properties required for PallyConMultiDrmSdk
to work properly.
The pallycon-react-native-sdk
uses the PallyCon Multi-DRM SDK. This PallyCon Multi-DRM SDK
is used to acquire and manage licences. This SDK is applied to the forked react-native-video and downloaded when running yarn install
.
The example project in pallycon-react-native-sdk
uses react-native-video to play DRM content.
The provided react-native-video
is applied with PallyCon Multi-DRM SDK
, and if you use pallycon-react-native-sdk
, you need to configure it like below.
dependencies: {
...
//examples/advanced/package.json or examples/basic/package.json
"react-native-video": "git+https://github.com/inka-pallycon/react-native-video.git"
...
}
Android
To integrate the Widevine Android SDK, follow these steps to add the GitHub package repository to your build.gradle
file:
Add the following code snippet to the allprojects
section of your build.gradle
file to include the PallyCon Widevine Android SDK GitHub repository:
allprojects {
repositories {
maven {
url = uri("https://maven.pkg.github.com/inka-pallycon/pallycon-widevine-android-sdk")
credentials {
username = "GitHub User ID" // Replace with your GitHub User ID
password = "Token" // Replace with your GitHub Personal Access Token
}
}
google()
// other repositories...
}
}
The username should be your GitHub User ID. The password should be your GitHub Personal Access Token (PAT). For instructions on generating a Personal Access Token, refer to the official GitHub documentation: Managing your Personal Access Tokens.
Make sure you set compileSdkVersion
in "android/app/build.gradle".
android {
compileSdkVersion 34
...
}
iOS
pallycon-react-native-sdk
uses cocoapods to install PallyCon Multi-DRM iOS SDK
.
For information on how to install and use cocoapods, please refer to the cocoapods official website.
- DRM content streaming playback
- DRM content download and offline playback
- DRM content streaming playback
- Run the following command to execute the example.
// move to the pallycon-react-native-sdk folder
% cd pallycon-react-native-sdk
% yarn install
% yarn pack -o pallycon-react-native-sdk.tgz
// move to the example/advanced or example/basic folder
% cd example/advanced
% yarn install
// move to ios folder
% cd ios
% pod install
% cd ..
// run ios
% npx react-native run-ios
// xcode run
% cd ios && open advanced.xcworkspace
import PallyConMultiDrmSdk, {
PallyConEventType,
PallyConContentConfiguration,
PallyConDownloadState,
} from "pallycon-react-native-sdk"
PallyConMultiDrmSdk.initialize(siteId)
Register events that occur inside the SDK.
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.complete, (event) => {
// Called when download is complete
})
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.pause, (event) => {
// Called when downloading is stopped during download
})
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.remove, (event) => {
// Called when download remove
})
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.stop, (event) => {
// Called when download stops
})
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.download, (event) => {
// Called when download starts
})
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.contentDataError,
(event) => {
// Called when an error occurs in the parameters passed to the sdk
}
)
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.drmError, (event) => {
// Called when a license error occurs
})
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.licenseServerError,
(event) => {
// Called when an error comes down from the license server
}
)
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.downloadError,
(event) => {
// Called when an error occurs during download
}
)
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.networkConnectedError,
(event) => {
// Called in case of network error
}
)
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.detectedDeviceTimeModifiedError,
(event) => {
// Called when device time is forcibly manipulated
}
)
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.migrationError,
(event) => {
// Called when sdk migration fails
}
)
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.licenseCipherError,
(event) => {
// Called when license cipher fails
}
)
PallyConMultiDrmSdk.addPallyConEvent(
PallyConEventType.unknownError,
(event) => {
// Internally called when an unknown error occurs
}
)
When downloading, register a listener to know the size of the currently downloaded data.
PallyConMultiDrmSdk.addPallyConEvent(PallyConEventType.progress, (event) => {
// event.url is url
// event.percent is downloaded percent
})
Get the current download status of the content.
try {
const state = await PallyConMultiDrmSdk.getDownloadState(config)
switch (state) {
case PallyConDownloadState.DOWNLOADING:
break
case PallyConDownloadState.PAUSED:
break
case PallyConDownloadState.COMPLETED:
break
default:
break
}
} catch (e) {
setError(e.message)
}
Describes the API required for the content download process.
// start download
PallyConMultiDrmSdk.addStartDownload(PallyConContentConfiguration)
// cancel downloads
PallyConMultiDrmSdk.cancelDownloads()
// pause downloads
PallyConMultiDrmSdk.pauseDownloads()
// resume downloads
PallyConMultiDrmSdk.resumeDownloads()
Remove the downloaded license and content.
// remove downloaded content
PallyConMultiDrmSdk.removeDownload(PallyConContentConfiguration)
// remove license for content
PallyConMultiDrmSdk.removeLicense(PallyConContentConfiguration)
Called when you end using the SDK.
PallyConMultiDrmSdk.release()