Android Native SDK
Latest version: 1.8.1
This SDK enables you to securely stream DRM-protected videos through your Android app.
#
Getting Started- Add VdoCipher maven repo to app module's
build.gradle
repositories { // other repo, e.g. jcenter() maven{ url "https://github.com/VdoCipher/maven-repo/raw/master/repo" }}
- Add dependency
compile 'com.vdocipher.aegis:vdocipher-android:1.7.3'
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 SDKcompile project(':vdocipher')
#
Integrating video playbackTo integrate a player, just drop a VdoPlayerFragment
into your activity layout with an id.
<fragment android:name="com.vdocipher.aegis.player.VdoPlayerFragment" android:id="@+id/online_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 = (VdoPlayerFragment)getFragmentManager().findFragmentById(R.id.online_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(OnlinePlayerActivity.this);......@Overridepublic void onInitializationSuccess(VdoPlayer.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 playerVdoInitParams vdoParams = VdoInitParams.createParamsWithOtp(otp, playbackInfo);player.load(vdoParams);
This should be followed by onLoading
and onLoaded
callbacks signalling that media playback can start now.
@Overridepublic void onLoading(VdoPlayer.VdoInitParams vdoInitParams) { Log.i(TAG, "onLoading");}
@Overridepublic void onLoaded(VdoPlayer.VdoInitParams vdoInitParams) { Log.i(TAG, "onLoaded"); // playback can be controlled now}
#
Guides#
Handling orientation changeTo 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=".OnlinePlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"></activity>
#
Using ProGuardIf 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 SDKThe 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 protectionSafetynet 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 securitySome 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.