VdoCipher Android SDK

Secure Video Streaming using Android App

Latest version: 1.0.0-beta3

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.0.0-alpha11'
    

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 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);
    ...
    ...
    @Override
    public 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 preferences.

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

  // load a media to the player
    VdoPlayer.VdoInitParams vdoParams = VdoPlayer.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(VdoPlayer.VdoInitParams vdoInitParams) {
        Log.i(TAG, "onLoading");
    }

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

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=".OnlinePlayerActivity"
        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 local storage for offline playback on Android devices running Lollipop and above (API level 20+).

Steps for Offline Android download for videos

Changelog

1.0.0-alpha7

  • Support for closed captions.
  • Support for setting aspect ratio and video stretch mode in VdoPlayerFragment.
  • Fixed offline media assets not being deleted on some devices when remove api is used.
  • Fixed occasional crash on background thread when starting a new download.
  • Bug fixes.

1.0.0-alpha6

  • Added support for downloading media to local storage and playback of offline media
  • Simplified VdoInitParams interface
  • Bug fixes

1.0.0-alpha3

  • Introduced multiple error codes and extended some in `ErrorCodes` class
  • Added Builder class to `VdoInitParams` as optionsal way to create init params
  • Fixed application crash when initiating secure playback
  • Other minor bug fixes

1.0.0-alpha2

  • Fixed onMediaEnded callbacks not received in some cases.
  • Fixed loading new VdoInitParams on VdoPlayer which already has a media running: discard current media immediately and load new params.
  • Improved support for testing playback on emulators.
  • Bug fixes.

1.0.0-alpha1

  • Changed player initialization workflow. Now you can initialize a PlayerHost to obtain a VdoPlayer instance without specifying any VdoInitParams. Once obtained, a VdoPlayer instance can be used to load media for playback.
  • Changed VdoPlayer api. Many api and callback methods have been added/removed/renamed in accordance with increased player capabilities. The javadoc lists the new api.
  • A playbackInfo string along with otp or signature is required for loading media to the player.
  • Added playback speed control related api.
  • Security enhancements and bug fixes.