Android SDK 5 Example Code Quick Start
This guide enables you to demonstrate CONNECT Player features and view the example code.
Prerequisites
Make sure you have the latest Android Studio installed, including:
Android SDK - install the latest version from Android Studio when prompted.
Gradle - use the latest version as recommended by Android Studio.
JDK - use the version provided with Android Studio.
Download the Android SDK pack, which supplies all the files needed to launch the player and start streaming content.
opy-sdk-android-5.14.x-example-code.zip
This package contains the application projects which demonstrate how to use the player features.opy-sdk-android-5.14.x-example-prm.zip
This package demonstrates how to work with PRM-encrypted streams.- opy-sdk-android-5.14.x-example-kotlin.zip
This package demonstrates how to implement the same features in the Kotlin language. - opy-sdk-android-5.14.x-sdk-integration.aar
The SDK binary file used for integration purposes. - opy-sdk-android-5.14.x-sdk-prm-integration.aar
The PRM version of the SDK binary file used for integration purposes. You will also need the PRM Operator Vault file opvault.json. - A device running Android 5.x (Lollipop) onwards with debugging enabled; the player cannot run on an Android Studio simulator.
Procedure
Save the SDK pack to your desktop and unzip it. The package contains a zipped set of example code, extract the contents of the example-code.zip file to your desktop.
- Start Android Studio, select Open an existing Android Studio project and select the required project in the top-level directory of the extracted package. The following projects are available:
- basic-playback This demonstrates playback of a clear stream with no additional functionality.
- chromecast Clear playback with support for Chromecast
- dynamic-ads-ima Clear playback with adverts with Google IMA.
- encrypted-playback Playback of Playback of Widevine encrypted content.
- encrypted-playback-playready Playback of Playback of PlayReady encrypted content.
- customised-encrypted-playback Non-default implementation of Playback of Widevine encrypted content.
- event-timeline Clear playback with feedback and analysis of performance tracking or playback issues.
- insight Sends playback metrics and statistics to an Insight analytics server.
- multi-instance Provides multiple instances of the player.
- offline Offline playback of DASH streams.
- offline-service Downloading as a service for DASH streams.
- output-control Clear playback with output control.
- resolution-capping Clear playback with resolution capping.
- thumbnails Clear playback with thumbnail previews.
- track-selection Clear playback with multi-audio.
- watermark-pull-mode QuickMark forensic watermarking using pull mode.
- watermark-push-mode QuickMark forensic watermarking using push mode.
- Copy one of the SDK files in your package (e.g. opy-sdk-android-5.14.x.x-sdk-integration.aar) to the common/libs/ directory.
- Connect an Android device to your development machine via USB, and build and run the application.
PRM example code
The example-code-prm.zip file contains additional examples for use with PRM.
- prm Playback of PRM protected playback.
- offline-hls Offline playback of HLS streams.
- offline-service Downloading as a service for both HLS and DASH streams.
- Extract the package example-code-prm.zip.
- Copy one of the PRM-supporting SDK files in your package (e.g. opy-sdk-android-5.14.x-sdk-prm-integration.aar) to the common/libs/ directory.
- For each mini-project, replace your opvault.json with the one at <mini-project>/src/main/res/raw/opvault.json. (The existing one will not work with your PRM server)
- Connect an Android device to your development machine via USB, and build and run the application.
Kotlin example code
Follow similar steps for examples in Kotlin (example-code-kotlin.zip). The Kotlin example code samples contain examples for both PRM and non-PRM scenarios. When testing with PRM, make sure you choose the correct SDK version and use your own opvault.json.
- basic-playback-kt This demonstrates playback of a clear stream with no additional functionality.
- customised-encrypted-playback-kt Non-default implementation of Playback of Widevine encrypted content.
- encrypted-playback-kt Playback of Playback of Widevine encrypted content.
- offline-hls-kt Offline playback of HLS streams.
- offline-kt Offline playback of Widevine streams.
- offline-service-kt Downloading as a service for DASH streams.
- offline-service-prm-kt Downloading as a service for DASH and HLS streams.
- prm-kt Playback of PRM protected playback.
- resolution-capping-kt Clear playback with resolution capping
- track-selection-kt Clear playback with multi-audio.
For full details on integrating the SDK with your application, see the Android SDK 5 Integration Guide. See also the API reference guide provided in the Android SDK pack.