Android SDK Setup

1. System Requirements

The THEOplayer Android SDK can be used for Android devices using Android 4.1+ (minSdkVersion 16).

2. Importing the library

Importing the THEOplayer Android SDK Library can be done following these steps:

  1. In your Android Studio, go to File > New Module > Import .JAR / .AAR Package.
  2. Navigate to the location where the theoplayer SDK aar file is stored and select it.
  3. Go to your project dependencies by going to File > Project Structure > dependencies tab.
  4. Add a new dependency by clicking the plus sign in the top-right corner and choose Module Dependency. Select the THEOplayer SDK aar file and click OK.

Additionally, you can import the sources jar to be able to immediately see the API java source files with their documentation in Android Studio. Follow the following after successfully importing the library steps for that:

  1. In the Projects Overview, set the view to the project view. You should now see “External Libraries”
  2. Under “External Libraries” you should be able to find the theoplayer-android SDK library, right click and select “Library Properties”.
  3. In the top left corner of the Library Properties window, click the first green plus sign.
  4. Find and select the theoplayer-android SDK jar file and click ok.

3. Using the THEOplayerView

In order to use THEOplayer in an Android app, you will need the THEOplayerView as the central component. This class can be loaded in a Layout and this will create a new player object for you to interact with.

Important: In order to react to the activity state, users need to call the onResume, onPause and onDestroy when the matching methods are called in the activity using the THEOplayerView.

3.1. Setting up the THEOplayerView using XML

When using XML to set your layout, you can add the following code to your XML file:


    android:layout_height="match_parent" />


Once you have the THEOplayerView in your layout, you can get a reference to it by using the findViewById-method.

3.2. Setting up the THEOplayerView using Java

Next to using XML to configure your view, you can also instantiate the view programmatically in Java. This can be done in the following way:


THEOplayerView view = new THEOplayerView(activity);


This view can then be placed inside another view and positioned in your layout.

4. Using the player

Once a player is created and set in your view, you can start interacting with the player instance using the THEOplayer API.

Setting a source

Create a SourceDescription object and set the player's source


SourceDescription sourceDescription = SourceDescription.Builder.sourceDescription("")


Add a player event listener

This example shows you how to listen to the player play event.


EventListener eventListener = new EventListener() {
    public void handleEvent(PlayEvent event) {
tpv.getPlayer().addEventListener(PlayerEventTypes.PLAY, eventListener);


Remove a player event listener


tpv.getPlayer().removeEventListener(PlayerEventTypes.PLAY, eventListener);