Native Integration
This is the integration guide for Saucelive's native player.
System Requirements
- Android SDK version 24 or higher
Installing the Native Player
In the settings.gradle file at the project root, add the mavenCentral() repository.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
- Add the dependency in the
build.gradlefile. SDK version info
dependencies {
implementation("io.github.mobidoo-official:SauceLive_Android:$SDK Version")
}
Native Player Initialization
This code must be added before anything else.
If you don't have an
Applicationclass, create one and register it inAndroidManifest.xml.
SauceLivePlayerClient.init(context: Context, partnerId: String)
| Parameter | Type | Description |
|---|---|---|
| context | Context | Used to configure the API host and initialize Koin models |
| partnerId | String | Required to use the player. Must be provided by the partner |
Call the initialization function in your Application class
Application classclass Application: Application(){
override fun onCreate() {
super.onCreate()
SauceLivePlayerClient.init(this,"Partner ID")
}
}
Using the Native Player
SauceLivePlayerClient.getInstance() : SauceLivePlayerClient
- This object is required to play the native live player and configure callbacks.
Call this method wherever the player is needed
ex) Playing the live player
class MainActivity: ComponentActivity() {
private val sauceClipPlayerClient = SauceClipPlayerClient.getInstance()
. . .
override fun onCreate(savedInstanceState: Bundle?) {
sauceLivePlayerClient.startPlayer(this,broadcastId,accessToken)
}
}
이벤트 Callback Listener 등록
setCallbackListener(playerCallback: PlayerCallbackListener)
- A callback listener that acts as a bridge for the web player
sauceLivePlayerClient.setCallbackListener(object : sauceLivePlayerClient.PlayerCallbackListener {
override fun onLoginRequest() {
}
override fun onCouponDownload(couponCode: String){
}
override fun onCouponCustom(couponData: String) {
}
})
PlayerCallbackListener
- onLoginRequest( ) : Triggered when login is required (e.g., for chat or reward participation) and the user clicks the login button in the popup.
- onCouponDownload(couponCode: String) : Called when a coupon of type
Downloadis registered during the live session. The registered coupon code is passed via callback. - onCouponCustom(couponData: String) : Called when a coupon of type
Customis registered during the live session. The registered coupon data is passed via callback.
Player UI Configuration
The player UI can be configured via the config settings.
Player Playback
startPlayer(context: Context,broadcastId: String,token: String?)
- Starts the live player.
sauceLivePlayerClient.startPlayer(context,broadcastId,token)
| Params | Type | Description |
|---|---|---|
| context | Context | |
| broadcastId | String | Live ID or VOD ID |
| token | String? | Token for user authentication (optional if not required) |
Updated 5 months ago
