Lumen help

Integrate with CDN Load Balancer SDK for Android & Android TV

Introduction

Prequisite

SDK Installation

                dependencyResolutionManagement {
    repositories {
        maven { url 'https://sdk.streamroot.io/android' }
    }
}
            
                // It is good practice to lock dependencies version
def dc_version = "22.09.1"

implementation "io.streamroot.lumen.delivery.client:orchestrator-sdk:$dc_version"
            

Configuration

                -keep class io.streamroot.** { *; }
-dontwarn io.streamroot.lumen.**
            
                <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            
                <?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>
            
                <manifest ...>
    <application
        ...
        android:usesCleartextTraffic="true"
        android:networkSecurityConfig="@xml/network_security_config">
    </application>
</manifest>
            

Set the Delivery Client Key

                <meta-data
android:name="io.streamroot.lumen.delivery.client.DeliveryClientKey"
android:value="<delivery-client-key>"
/>
            

Code Integration

                class Application: MultiDexApplication() {

    override fun onCreate() {
        super.onCreate()
        /* If you could not add your Delivery Client Key in your AndroidManifest.xml
         * Call instead: LumenDeliveryClient.initializeApp(this, "<delivery-client-key>")
         */
        LumenDeliveryClient.initializeApp(this)
        ...
    }
}
            
                public class Application extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        /* If you could not add your Delivery Client Key in your AndroidManifest.xml
         * Call instead: LumenDeliveryClient.initializeApp(this, "<delivery-client-key>")
         */
        LumenDeliveryClient.initializeApp(this);
        ...
    }
}
            
                android:name=".Application"
            
                android:name=".Application"
            
                private fun createDeliveryClient(
    player: ExoPlayer,
    loadControl: DefaultLoadControl,
    bandwidthMeter: ExoPlayerBandwidthMeter
) : LumenDeliveryClient {
    val playerInteractor = PlayerInteractor(player, loadControl, bandwidthMeter)
    return LumenDeliveryClient.orchestratorBuilder(this) //< applicationContext
            /*
             * Set the player interactor that will be used by the SDK
             * Check the bridge section to know more
             *
             * param: an instance of a class subclassing LumenPlayerInteractorBase.
             */
            .playerInteractor(playerInteractor)
            /*
             * Build a LumenDeliveryClient instance
             *
             * param: String. The video stream url
             */
            .build(manifestUrl)
}
            
                private LumenDeliveryClient createDeliveryClient(ExoPlayer player, DefaultLoadControl loadControl, PlayerInteractor.ExoPlayerBandwidthMeter bandwidthMeter) {
    final PlayerInteractor playerInteractor = new PlayerInteractor(player, loadControl, bandwidthMeter);

    return LumenDeliveryClient
            .orchestratorBuilder(this)
            /*
             * Set the player interactor that will be used by the SDK
             * Check the bridge section to know more
             *
             * param: an instance of a class subclassing LumenPlayerInteractorBase.
             */
            .playerInteractor(playerInteractor)
            /*
             * Build a LumenDeliveryClient instance
             *
             * param: String. The video stream url
             */
            .build(manifestUrl);
}
            
                deliveryClient.start()
val finalUrl = deliveryClient.localUrl()
            
                deliveryClient.start()
final String finalUrl = deliveryClient.localUrl();
            
                val mediaItem = MediaItem.fromUri(Uri.parse(finalUrl))
            
                MediaItem mediaItem = MediaItem.fromUri(Uri.parse(finalUrl));
            
                // Calling stop will finish ongoing tasks and release all resources used
deliveryClient.stop()
            
                // Calling stop will finish ongoing tasks and release all resources used
deliveryClient.stop();
            

Additional Options

                private fun createDeliveryClient(
    player: ExoPlayer,
    loadControl: DefaultLoadControl,
    bandwidthMeter: ExoPlayerBandwidthMeter
) : LumenDeliveryClient {
    val playerInteractor = PlayerInteractor(player, loadControl, bandwidthMeter)   return LumenDeliveryClient
            .orchestratorBuilder(applicationContext)
            .playerInteractor(playerInteractor)
            .options {
                /*
                * Set Orchestrator property
                *
                * param: String
                */
                orchestratorProperty("MY_PROPERTY")
                /*
                * Set the Delivery Client Key
                * Is only required if it was not set in AndroidManifest.xml
                * Will override the AndroidManifest.xml DeliveryClientKey
                *
                * param: String
                */
                deliveryClientKey("<delivery-client-key>")
                /*
                * Set the content id
                * A string that identifies your content
                * By default, it uses the stream url
                *
                * param: String
                */
                contentId("MY_CONTENT_ID")
                /*
                * Set the log level
                * See the "How to investigate?" to know more
                *
                * param: LumenLogLevel
                */
                logLevel(LumenLogLeven.INFO)
                /*
                * Set latency in seconds
                *
                * param: Int
                */
                latency(3)
                /*
                * Set a proxy server
                * Allows the use of a proxy server in the middle
                * Format is host:port
                *
                * params: String
                */
                proxyServer("MY_PROXY_HOST:PORT")
            }
            .build(manifestUrl)
}
            
                private LumenDeliveryClient createDeliveryClient(ExoPlayer player, DefaultLoadControl loadControl, PlayerInteractor.ExoPlayerBandwidthMeter bandwidthMeter) {
    final PlayerInteractor playerInteractor = new PlayerInteractor(player, loadControl, bandwidthMeter);

    return LumenDeliveryClient
            .orchestratorBuilder(this)
            .playerInteractor(playerInteractor)
            .options(o -> {
                /*
                * Set Orchestrator property
                *
                * param: String
                */
                o.orchestratorProperty("MY_PROPERTY");
                /*
                * Set the Delivery Client Key
                * Is only required if it was not set in AndroidManifest.xml
                * Will override the AndroidManifest.xml DeliveryClientKey
                *
                * param: String
                */
                o.deliveryClientKey("<delivery-client-key>");
                /*
                * Set the content id
                * A string that identifies your content
                * By default, it uses the stream url
                *
                * param: String
                */
                o.contentId("MY_CONTENT_ID");
                /*
                * Set the log level
                * See the "How to investigate?" to know more
                *
                * param: LumenLogLevel
                */
                o.logLevel(LumenLogLeven.INFO);
                /*
                * Set latency in seconds
                *
                * param: Int
                */
                o.latency(3);
                /*
                * Set a proxy server
                * Allows the use of a proxy server in the middle
                * Format is host:port
                *
                * params: String
                */
                o.proxyServer("MY_PROXY_HOST:PORT");

                return null;
            }).build(manifestUrl);
}
            

Troubleshooting

                LumenDeliveryClient.setLogLevel(LumenLogLevel.INFO)
LumenDeliveryClient.initializeApp(this)
            
                LumenDeliveryClient.setLogLevel(LumenLogLevel.INFO);
LumenDeliveryClient.initializeApp(this);
            

Explore CDN services