Integration with Exoplayer (Android)

The Teltoo ExoPlayer library provides a way to create instances of MediaSource which can be directly used to call the prepare method of the ExoPlayer classes.

So to activate Teltoo, use the TeltooFactory class to create MediaSource instances instead of HlsMediaSource , DashMediaSource or SsMediaSource .

Teltoo Exoplayer library runs on the same process the application does. There are no other system processes launched by Teltoo SDK. Therefore, Teltoo will remain active, connected and seeding content as long as the player is playing the video stream. In other words Teltoo lifecycle is tied to the MediaSource object.

Follow the steps below to complete the integration:

1. Add the Teltoo Android repository and SDK dependency to the project build.gradle file, ie:


repositories {
jcenter()
google()
maven { url "https://sdk.teltoo.com/android" }
}

dependencies {
implementation 'com.teltoo:exoplayer:+'
}

2. Set the Teltoo ApiKey as a meta-data in the application manifest (AndroidManifest.xml):


<meta-data
        android:name="com.teltoo.ApiKey"
        android:value="TELTOO_API_KEY"/>

3. Set up the player:

Create a TeltooExoplayer Factory:


TeltooExoplayer.Factory teltooFactory = new
TeltooExoplayer.Factory(Context);

Create the MediaSource:


MediaSource teltooSource =
teltooFactory.createMediaSource(Uri.parse(streamURL));

Prepare the ExoPlayer instance:


player.prepare(teltooSource);

Optionally add a listener to receive Teltoo status information:


teltooFactory.addListener(new Teltoo.EventListener() {
       @Override
       public void onError(String description) {
           Log.e (TAG, "TELTOO: error: "+description);
       }

       @Override
       public void onState(boolean connected) {
           Log.d (TAG, "TELTOO: connected: "+connected);
       }

       @Override
       public void onMessage(String message) {
           Log.d (TAG, "TELTOO: message: "+message);
       }

       @Override
       public void onStats(int connectedPeers, int totalBytesReceived, int p2pBytesReceived, int cacheBytes, int requestWithoutTeltoo) {
           Log.d (TAG, "TELTOO: stats: peers:"+connectedPeers+" p2p bytes:"+p2pBytesReceived);
       }
   });

Teltoo Android SDK is built using Android NDK, and it is compatible with all Android architectures. It is possible to create different application APK files for every architecture in order to reduce the application size. Check the link below or contact us for further information. https://developer.android.com/studio/build/configure-apk-splits.html

Copied to Clipboard