Getting Started

‘Integrate StreamLayer into GoogleTV and AndroidTV apps with Maven installation, SDK initialization, theme customization, and screen offset delegate setup.’

GoogleTV / AndroidTV SDK

Welcome to the StreamLayer GoogleTV / AndroidTV SDK documentation. StreamLayer supports GoogleTV and AndroidTV applications through the Android SDK. This guide covers installation, initialization, and integration for Android TV devices.

Quick Start Path

  1. Read the Introduction — Understand what StreamLayer delivers and how the SDK architecture works.
  2. Follow the Android SDK Integration Guide — The Android TV SDK shares the Android SDK. Follow the full setup guide for dependencies, SDK API Key, and initialization.
  3. Configure for Android TV — Review the GoogleTV-specific notes below for screen offset handling, theme customization, and layout setup.
  4. Customize the Theme — Use Customizing Themes to match the StreamLayer Element to your TV app's branding.

What You Can Build

FeatureDescriptionGuide
StreamLayer ElementInteractive UI surface with D-pad navigationAndroid Integration Guide
Custom ThemesMatch the StreamLayer Element to your TV app's brandingCustomizing Themes
Layout ModesPortrait, landscape, and squeezeback formats for TVLayout Guide

Reference Documentation

DocumentationDescription
Android SDK Integration GuideFull Android SDK setup and configuration
Layout GuidePortrait, landscape, and squeezeback layout setup
Customizing ThemesTheme and style customization

System Requirements

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

GoogleTV vs AndroidTV

Google TV is 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. Since Google TV is built on the Android TV OS, any app that runs on Android TV also runs on Google TV, and vice versa. There is no difference in app compatibility between the two — they share the same Play Store catalog of TV apps and both support Chromecast built-in.

Quick 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>")
}

Initialize the SDK 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)
}

GoogleTV-Specific Notes

  • Screen Offset Delegate: Use a screen offset delegate to adjust player layout when the StreamLayer Element is active. See the example below.
  • Themes: Customize the StreamLayer Element appearance using SLRTheme. See Customizing Themes for details.
  • Layout: For portrait and landscape orientation setup, see the Layout Guide.

Screen Offset Delegate 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
    }
}

Support

For GoogleTV / AndroidTV-specific issues or questions:


Related