Video Management
Configure video playback support for the StreamLayer Android SDK. Use built-in Media3 or ExoPlayer extensions, or implement the SLRVideoPlayerProvider interface for custom players.
Video Management
Certain units within the StreamLayer Element may require video playback support. For instance, when a user scrolls through social content and wants to play an embedded video, the SDK requests a video player from the host app on demand.
Your host app can use any video playback library — the SDK does not depend on a specific one. The SDK provides the SLRVideoPlayerProvider interface for this purpose. You can implement it yourself or install a ready-to-use extension.
Media3 and ExoPlayer Extensions
The default Android MediaPlayer has issues with certain modern video formats. Two popular alternatives are Media3 and ExoPlayer. Both use ExoPlayer internally but have compatibility differences — only one should be used in your project.
These extensions are distributed via the public Maven repository. Add the appropriate dependency to your module-level build.gradle:
dependencies {
// add exo player extension
implementation "io.streamlayer:android-exoplayer:<insert latest version>"
// or add media3 extension
implementation "io.streamlayer:android-media3:<insert latest version>"
}Find the latest versions for the Media3 extension and ExoPlayer extension on Maven Central.
Initialize the extension before StreamLayerFragment is used. In your Application class, initialize the extension after the SDK:
// initialize the StreamLayer SDK with SDK key
StreamLayer.initializeApp(this, {SDK_KEY})
....
// initialize exo player extension
StreamLayerExoPlayer.initSdk(this)
// or initialize media3 extension
StreamLayerMedia3Player.initSdk(this)SLRVideoPlayerProvider
If your host app uses a different video playback library, implement the SLRVideoPlayerProvider interface. This interface has two functions:
getVideoPlayer()— returns an SLRVideoPlayer based on incoming parametersgetVideoPlayerView()— returns an SLRVideoPlayerView based on incoming parameters
Register your SLRVideoPlayerProvider implementation using StreamLayer.setVideoPlayerProvider() after SDK initialization:
// initialize the StreamLayer SDK with SDK key
StreamLayer.initializeApp(this, {SDK_KEY})
....
StreamLayer.setVideoPlayerProvider(provider)For examples of implementing SLRVideoPlayerProvider with ExoPlayer, see the demo app.
Related
- Integration Guide — Complete SDK setup instructions
- Spoiler Prevention — Sync content with live playback position
Updated 21 days ago
