Video Management
Video Management
To ensure the best user experience, certain overlays may require a video playback support. For instance, when the user is scrolling the Twitter or Games overlay and want to play some video. The SDK will request the host app to provide the video player on demand based on video settings.
Your host app can use any library for supporting video playback - the SDK doesn't depend on them. The SDK provides interface for supporting video playback - SLRVideoPlayerProvider. You can implement this api by yourself or install ready to use extensions.
Media3 and ExoPlayer extensions
The default MediaPlayer has issues with supporting some modern video formats. So when developing for Android, there are several widely used video players, the most populars are the new Media3 and the old ExoPlayer. Both of them use ExoPlayer internally, but they have compatibility issues. So only one of them will be used on the client side.
These extensions are distributed via a Maven public repository. Add the following dependency to your module level build.gradle script.
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>"
}You can find the latest versions of the Media3 extension here and ExoPlayer extension here.
It is important to initialize the extension before the StreamLayerFragment is used. Use the following functions in your Application class and initialize extension when the SDK is initialized:
// 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 use different library for supporting video playback you can implement SLRVideoPlayerProvider api interface by yourself. This interface contains 2 functions:
getVideoPlayer()- which returns SLRVideoPlayer based on incoming paramsgetVideoPlayerView()- which returns SLRVideoPlayerView based on incoming params.
It is important to register your SLRVideoPlayerProvider implementation using StreamLayer.setVideoPlayerProvider function when the SDK is initialized:
// initialize the StreamLayer SDK with SDK key
StreamLayer.initializeApp(this, {SDK_KEY})
....
StreamLayer.setVideoPlayerProvider(provider)Examples of how to implement SLRVideoPlayerProvider based on ExoPlayer can be found here and here.
Updated 12 months ago
