Live Stream Support (Android)
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
We don't support live stream on Android by default. But you could follow the instructions below to enable and enhance the function of live stream.
The library packages are accessible through the MavenCentral repositories. You can check for the latest stable released version using the MavenCentral tag on top of this doc.
Make sure your project is using the mavenCentral
repository in your project build.gradle
or build.gradle.kts
repositories block:
repositories {
...
mavenCentral()
}
Add these dependencies based on your requirements:
Firework SDK: The main dependency of Firework Android SDK is required for the library initialization and video features.
Livestream Library: If you are planning to use a Livestream from an external source.
def fireworkSdkVersion = "latest_firework_sdk_version"
implementation 'com.firework:sdk:$fireworkSdkVersion'
// Support for livestream
implementation 'com.firework.external.livestream:singleHostPlayer:$fireworkSdkVersion'
// Glide (Optional)
implementation 'com.firework.external.imageloading:glide:$fireworkSdkVersion'
Call this code in your custom application class onCreate
method to initialize the Firework SDK:
import com.firework.sdk.FireworkSdk
import com.firework.sdk.FireworkSdkConfig
import com.firework.sdk.FireworkInitError
import com.firework.imageloading.glide.GlideImageLoaderFactory
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
// build Firework Android SDK configuration
val config = FireworkSdkConfig.Builder(context = this)
.clientId(FW_CLIENT_ID) // Client OAUTH Id
.userId("My app User ID") // Optional field to set the User ID in your eco-system.
.imageLoader(GlideImageLoaderFactory.createInstance(context = this)) // Glide, Picasso, or your ImageLoader implementation
.enableCache(true) // Enable or disable video players cache, enabled by default
.maxCacheSizeBytes(MAX_CACHE_SIZE_BYTES) // Max cache size used by video players, 25MB by default
.muteOnLaunch(true) // Mute videos on lauch
.addLivestreamPlayerInitializer(SingleHostLivestreamPlayerInitializer()) // For single-host livestream use
.build()
// Setup using newest version of livstream player.
FireworkSdk.setLivestreamPlayerVersion(playerVersion = FwLivestreamPlayerVersion.V2)
// initialize Firework Android SDK
FireworkSdk.init(
fireworkSdkConfig = config,
onSuccess = {
// Successful initialization
},
onError = { error ->
when (error) {
is FireworkInitError.InitializationError -> {
// Handle initialization error
}
is FireworkInitError.AlreadyInitializedError -> {
// The SDK is already initialized
}
}
},
)
}
}
Since the Firework company is developing multiple SDKs for different purposes and they may lead to dependency conflicts, we introduced BoM solution which can be used when your app depends on more than one Firework SDKs or like to use the Firework opensource libraries.
In this solution, your project's gradle file should only define the platform dependency with the latest BoM version:
def fireworkSdkVersion = "latest_firework_bom_version"
implementation platform'com.firework:firework-bom:$fireworkBomVersion'
// no version is needed
implementation `com.firework:sdk`
implementation `com.firework.external.imageloading:glide`
implementation `com.firework.external.livestream:singleHostPlayer`
Our latest livestream player feature is based on Player Version 2. Please call the setLivestreamPlayerVersion()
function before initializing the SDK.
import com.firework.sdk.FireworkSdk
import com.firework.sdk.FireworkSdkConfig
import com.firework.sdk.FireworkInitError
import com.firework.imageloading.glide.GlideImageLoaderFactory
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
// build Firework Android SDK configuration
val config = ...
// Setup using newest version of livstream player.
FireworkSdk.setLivestreamPlayerVersion(playerVersion = FwLivestreamPlayerVersion.V2)
// initialize Firework Android SDK
FireworkSdk.init(
fireworkSdkConfig = config,
onSuccess = {
// Successful initialization
},
onError = { error ->
when (error) {
is FireworkInitError.InitializationError -> {
// Handle initialization error
}
is FireworkInitError.AlreadyInitializedError -> {
// The SDK is already initialized
}
}
},
)
}
}