Skip to main content

Android Native SDK

Latest version: 1.10.1

Sample Android App

Javadocs

This SDK enables you to securely stream DRM-protected videos through your Android app.

Getting Started

  1. If you have a settings.gradle file in your project root, then you need to add the repositories in the settings.gradle inside dependencyResolutionManagement. Else, this will go in build.gradle file in project root.
repositories {
// other repo, e.g. google() or mavenCentral()
maven{
url "https://github.com/VdoCipher/maven-repo/raw/master/repo"
}
}
  1. Add dependency
// use the latest available version
implementation 'com.vdocipher.aegis:vdocipher-android:1.10.1'

Note: If your project has a local dependency on a previous version of the SDK (AAR module dependency), you'll need to remove them from the project.

// remove this dependency if it exists from use of a previous version of SDK
compile project(':vdocipher')

Integrating video playback

To integrate a player, just drop a VdoPlayerSupportFragment into your activity layout with an id.

<fragment
android:name="com.vdocipher.aegis.player.VdoPlayerSupportFragment"
android:id="@+id/vdo_player_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:keepScreenOn="true"/>

and receive its instance in your activity using findFragmentbyId()

playerFragment = (VdoPlayerSupportFragment)getSupportFragmentManager().findFragmentById(R.id.vdo_player_fragment);

Get a VdoPlayer instance by calling PlayerHost.initialize() method on the playerFragment and receive the player in the onInitializationSuccess callback.

You can add callbacks for listening to playback events using VdoPlayer.addPlaybackEventListener() on the VdoPlayer object that is received in the onInitializationSuccess callback.

playerFragment.initialize(PlayerActivity.this);
...
...
@Override
public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean wasRestored) {
Log.i(TAG, "onInitializationSuccess");
this.player = player;

// add a listener for playback events
player.addPlaybackEventListener(playbackListener);
// ...
}

Once you have a player, you can start loading media onto it for playback. You'll need a VdoInitParams object to specify which media to load along with your playback preferences.

A VdoInitParams object needs playbackInfo and either otp or signature generated from your server.

// load a media to the player
VdoInitParams vdoParams = VdoInitParams.createParamsWithOtp(otp, playbackInfo);
player.load(vdoParams);

This should be followed by onLoading and onLoaded callbacks signalling that media playback can start now.

@Override
public void onLoading(VdoInitParams vdoInitParams) {
Log.i(TAG, "onLoading");
}

@Override
public void onLoaded(VdoInitParams vdoInitParams) {
Log.i(TAG, "onLoaded");
// playback can be controlled now
}

Guides

Handling orientation change

To make orientation change seamless, please override config changes for your activity by adding the following to your AndroidManifest.xml. This means that your activity won't go through the regular life-cycle events on device orientation change. If you require to change the layout, please use onConfigurationChanged callback in your activity to change the size or hide/unhide view elements.

Replace the name of activity with correct name.

<activity android:name=".PlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>

Using ProGuard

If you use ProGuard in your app, you might need to add the following rule to your ProGuard file.

-keep class com.vdocipher.aegis.* { ;  }

Offline Download using SDK

The VdoCipher Android SDK offers capability to download videos to the device's local storage. Videos would then be available for offline playback. This feature is available for Android devices running Lollipop and above (API level 20+).

Steps for Offline Android download for videos ยป

SafetyNet implementation in your Android App for enhanced Emulator protection

Safetynet Implementation via Google APIs allow higher app based security and ensures playback only in genuine physical devices

Steps for SafetyNet integration for higher security on app side ยป

Block devices with ADB debugging for higher security

Some users switch on ADB debugging in phone. For higher security, it should be blocked. We have kept this optional as there will be few users who will not be able to play without switching ADB debugging off. To block playback on devices with ADB debugging turned ON, use the setAllowAdbDebugging method of VdoInitParams.Builder when making the vdoParams:

VdoInitParams vdoParams = new VdoInitParams.Builder()
.setOtp(...)
.setPlaybackInfo(...)
.setAllowAdbDebugging(false)
.build();

To ensure that such blocked users get useful message so that they can switch off ADB debugging and play the video, please handle the error code 1202 as shown in this sample code change in sample code. This will handle the error code and show a useful message to users.