The FireworkSdk object is the main entry point for the Firework Android SDK. It provides methods for SDK initialization, player management, shopping, livestream, and advanced configurations.
Checks whether the Firework SDK has been successfully initialized.
This method returns true if the SDK's initialization process has completed successfully, including dependency injection setup and all core modules registration. It is essential to verify initialization status before calling any other SDK methods to avoid runtime errors.
Signature:
Initialization Requirements
The SDK is considered initialized when both of the following conditions are met:
The dependency injection (DI) system has been set up
The init method has completed successfully with all modules registered
Use Cases
Conditional Feature Access: Check initialization before accessing SDK features
Error Prevention: Avoid crashes by verifying SDK readiness before operations
State Management: Track SDK lifecycle in your application
Debugging: Verify initialization status when troubleshooting integration issues
Important Notes
This method is thread-safe and can be called from any thread
Calling SDK methods before initialization will typically result in failures or exceptions
The SDK can only be initialized once per application lifecycle
If initialization fails, this method will return false
Video Player
startPlayer()
Launch the fullscreen video player.
Variant 1: With URL
Launch a specific video directly using its URL.
Signature:
Parameters:
viewOptions - Player configuration options
url - Video URL to play
Returns:PlayerLaunchResult indicating success or failure
Example:
Variant 2: With Feed Configuration
Launch the player with a feed configuration.
Signature:
Parameters:
viewOptions - Player and feed configuration options
Returns:PlayerLaunchResult indicating success or failure
This method programmatically closes the full-screen player Activity launched by the Firework SDK.
When invoked, it triggers a close event that all running player Activities listen to and respond
by executing a graceful shutdown process.
Signature:
Example:
Shopping Features
shopping
Access shopping-related functionality and callbacks.
onSuccess - Optional callback with boolean indicating if already in PIP
onError - Optional callback invoked on PIP entry failure
Example:
closePip()
Close Picture-in-Picture mode and dismiss the player.
Signature:
Example:
Player Versions
setVideoPlayerVersion()
Set the version of the video player to use.
Signature:
Parameters:
playerVersion - The video player version
Available Values:
FwVideoPlayerVersion.V1 - Video Player version 1
FwVideoPlayerVersion.V2 - Video Player version 2 (recommended)
Example:
setLivestreamPlayerVersion()
Set the version of the livestream player to use.
Signature:
Parameters:
playerVersion - The livestream player version
Available Values:
FwLivestreamPlayerVersion.V1 - Livestream Player version 1
FwLivestreamPlayerVersion.V2 - Livestream Player version 2 (recommended)
Example:
Important: Call player version setters before FireworkSdk.init().
Player Launch Mode
setPlayerLaunchMode()
Configure the Android launch mode for the player activity.
Signature:
Parameters:
playerActivityLaunchMode - The launch mode to set
Available Values:
FwPlayerActivityLaunchMode.SINGLE_TASK - Standard single task launch mode
FwPlayerActivityLaunchMode.SINGLE_INSTANCE - Single instance for complete isolation
FwPlayerActivityLaunchMode.SINGLE_TASK_WITH_OWN_AFFINITY - Single task with custom affinity
Example:
Tracking and Metrix
setTrackingLevel()
Sets the level of data tracking.
Signature:
Parameters:
FwTrackingLevel - the level of data tracking to be set.
Available Values:
FwTrackingLevel.ALL - Sends all analytic events
FwTrackingLevel.ESSENTIAL_ONLY - Sends only the essential tracking events.
FwTrackingLevel.NONE - Sends no tracking events
Notes:
Please note that if you set the FwTrackingLevel to FwTrackingLevel.NONE, data regarding users watching videos and livestreams will not be reported. This may negatively impact the data reports related to each video or livestream displayed in the Business Portal.
fun startPlayer(
viewOptions: ViewOptions,
url: String
): PlayerLaunchResult
val viewOptions = viewOptions {
playerOptions {
showShareButton(true)
enablePipMode(true)
}
}
when (val result = FireworkSdk.startPlayer(viewOptions, "https://video-url")) {
is PlayerLaunchResult.Success -> {
// Player launched successfully
}
is PlayerLaunchResult.Failure -> {
// Handle failure: result.message
}
}
fun startPlayer(
viewOptions: ViewOptions
): PlayerLaunchResult
val viewOptions = viewOptions {
baseOptions {
feedResource(FeedResource.Discovery)
}
playerOptions {
showShareButton(true)
enablePipMode(true)
}
}
when (val result = FireworkSdk.startPlayer(viewOptions)) {
is PlayerLaunchResult.Success -> {
// Player launched successfully
}
is PlayerLaunchResult.Failure -> {
// Handle failure: result.message
}
}
fun closeFullScreenPlayer()
// Close the player when user logs out
fun onUserLogout() {
FireworkSdk.closeFullScreenPlayer()
// Perform other logout logic
}
// Close the player when app goes to background
override fun onPause() {
super.onPause()
if (shouldClosePlayerOnBackground) {
FireworkSdk.closeFullScreenPlayer()
}
}
override fun onDestroy() {
FireworkSdk.closePip()
super.onDestroy()
}
fun setVideoPlayerVersion(playerVersion: FwVideoPlayerVersion)
// Use V2 player (recommended)
FireworkSdk.setVideoPlayerVersion(FwVideoPlayerVersion.V2)
// Call before SDK initialization
FireworkSdk.init(config)
fun setLivestreamPlayerVersion(playerVersion: FwLivestreamPlayerVersion)
// Use V2 player (recommended)
FireworkSdk.setLivestreamPlayerVersion(FwLivestreamPlayerVersion.V2)
// Call before SDK initialization
FireworkSdk.init(config)
fun setPlayerLaunchMode(playerActivityLaunchMode: FwPlayerActivityLaunchMode)
// Set single instance mode
FireworkSdk.setPlayerLaunchMode(FwPlayerActivityLaunchMode.SINGLE_INSTANCE)
// Then launch player
FireworkSdk.startPlayer(viewOptions)
fun setTrackingLevel(trackingLevel: FwTrackingLevel)