GoogleTV / AndroidTV Integration Guide

Getting Started with StreamLayer SDK for GoogleTV / AndroidTV

Prerequisites

System Requirements

  • Android Studio 4.0 or higher
  • Target SDK version 33 or higher
  • Minimum SDK version 21
  • Kotlin or Java

GoogleTV vs AndroidTV - what's the difference?

Google TV is simply a redesigned user interface that runs on top of the Android TV operating system. Android TV is the underlying operating system that provides access to apps. It's simply a difference in interface. Google TV and Android TV share the same app ecosystem and capabilities.

Since Google TV is built on the Android TV OS, any app that runs on Android TV will also run on Google TV, and vice versa. There is virtually no difference in app compatibility between the two. Google TV devices utilize the same Play Store catalog of TV apps – in fact, the app store interface is identical on both Google TV and Android TV. Both support Chromecast built-in for casting content from your phone or computer to the TV screen, which works across apps on both platforms .


Obtain an SDK API Key

You need an SDK API key to integrate StreamLayer into your Android TV app.

If you don’t have one:

  1. Contact StreamLayer support to create an organization and set up your dashboard.
  2. You’ll receive an invitation email with credentials and a link to the admin panel.
  3. After accessing the admin panel, generate an API key from the Developer Settings section.

Installation

The SDK is distributed via a Maven public repository. Find the latest version here.

Add the following dependencies to your module-level build.gradle:

dependencies {
  implementation("io.streamlayer:androidsdk:<insert latest version>")
  implementation("io.streamlayer:android-media3:<insert latest version>")
}

Integration

SDK Initialization

Initialize the SDK before using StreamLayerFragment.

In your Application class:

override fun onCreate() {
    super.onCreate()
    StreamLayer.initializeApp(this, BuildConfig.SL_SDK_KEY)
    StreamLayer.setGamificationOptions(
        StreamLayer.GameOptions(
            isGlobalLeaderboardEnabled = false,
            isInvitesEnabled = false,
            isOnboardingEnabled = false,
            showGamificationNotificationOnboarding = false
        )
    )
    StreamLayer.setCustomTheme(
        SLRTheme(
            mainTheme = R.style.TVMainOverlayTheme,
            baseTheme = R.style.TVMainOverlayTheme
        )
    )
    StreamLayer.setInvitesEnabled(false)
    StreamLayerMedia3Player.initSdk(this)
}

You can customize themes as needed: Customizing Themes

Integrating the SDK Overlay

For details on layout setup, including portrait and landscape orientation, see the Layout Guide.


Implement Screen Offset Delegate

Use a screen offset delegate to adjust player layout.

Example:

val appHostDelegate = object : SLRAppHost.Delegate {
    override fun onScreenSizeChanged(size: SLRAppHost.SLRScreenSize) {
        binding.playerView.updateLayoutParams<ConstraintLayout.LayoutParams> {
            topMargin = size.topMargin
            bottomMargin = size.bottomMargin
            marginEnd = size.endMargin
            marginStart = size.startMargin

            width = size.playerMinWidth
            height = size.playerHeight
            verticalBias = size.verticalBias
        }
        binding.playerView.outlineProvider = object : ViewOutlineProvider() {
            override fun getOutline(view: View, outline: Outline) {
                outline.setRoundRect(0, 0, view.width, view.height, size.playerCornerRadius)
            }
        }
        binding.playerView.clipToOutline = true
    }
}

Additional Features

Check other features