To test this feature and view the example code, please see the Android SDK 5 Example Code Quick Start guide.

The SDK is created and initialised when the client application starts up (upon calling OTVSDK.load()) and is destroyed when the application terminates. Typically, the SDK is created by the following code within the application entry point activity onCreate() method.


Player lifecycle

An OTVVideoView object must be created and configured to enable users to watch any content.

  1. The application follows instructions from the user to play content by providing the SDK with the URL.

    If the streaming content is served over HTTPS, you may need to disable SSL verification under certain circumstances.

  2. The application instantiates an OTVVideoView (typically through the layout definitions), and the application passes the URL using mOTVVideoView.setVideoPath(url).
  3. The player is destroyed when playback stops.

Changing streams

Streams can be changed by either:

  • Stopping playback, destroying the instance of the player and creating a new instance with a new URL.
  • Updating the existing instance of the player instructing it to use a different URL.

Stream type detection

When OtvVideoView#setVideoPath() is called, the SDK can detect the stream type by:

  • Observing the filename extension in the path (for example, .m3u8 for HLS, .manifest for DASH)
  • Sending an HTTP HEAD request and observing the returned ContentType value.

If neither of the methods can identify the stream type, playback will fail with an error. Alternatively, if the app can determine the content type from the stream metadata, it can inform the player explicitly by using mOTVVideoView.setVideoPath(String path, int contentType).

Example code

Basic playback Java version

package com.nagra.example.basic;

import android.content.res.Configuration;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import nagra.otv.sdk.OTVSDK;
import nagra.otv.sdk.OTVVideoView;

public class MainActivity extends Activity {
  private final String STREAM_URI = "";

  private FrameLayout mFrame = null;
  private OTVVideoView mOTVVideoView = null;

  protected void onCreate(Bundle savedInstanceState) {

    // The OTVSDK.load() method must be called before SDK can be used
    // You may wish to do this in an application class

    mFrame = findViewById(;

    if (mOTVVideoView == null) {
      mOTVVideoView = new OTVVideoView(this);

   * This code is only necessary if you want to switch between different layouts or change config
   * values such as video display area between rotations. As long as androidManifest contains
   * android:configChanges="orientation|screenSize" then your view/player should not be destroyed on rotation.
   * see for more information
  public void onConfigurationChanged(Configuration newConfig) {
    if (mOTVVideoView.getParent() != null) {
      ViewGroup parent = (ViewGroup) mOTVVideoView.getParent();

  public void onPause() {
    if (mOTVVideoView != null) {

  public void onResume() {
    if (mOTVVideoView != null) {