ServicePlayerConnector

class ServicePlayerConnector<T : BVPlaybackService>(context: Context, serviceClass: KClass<T>)

Helper that manages the start + bind lifecycle between a UI layer and BVPlaybackService.

Usage

private val connector by lazy {
ServicePlayerConnector(this, AppPlaybackService::class)
}

override fun onStart() {
super.onStart()
connector.connect(playerConfig = buildPlayerConfig()) { player ->
binding.playerView.setUnifiedPlayer(player)
if (player.getCurrentMediaConfig() == null) {
connector.getService()?.loadMedia(mediaConfig)
}
}
}

override fun onStop() {
super.onStop()
connector.disconnect()
}

Constructors

Link copied to clipboard
constructor(context: Context, serviceClass: KClass<T>)

Functions

Link copied to clipboard
fun connect(playerConfig: PlayerConfig? = null, analyticsConfig: AnalyticsConfig? = null, onConnected: (UniPlayer) -> Unit)

Starts and binds to the service.

Link copied to clipboard

Unbinds from the service. The service continues running in the background.

Link copied to clipboard

Returns the UniPlayer instance, or null if not yet connected.

Link copied to clipboard
fun getService(): T?

Returns the typed service instance (e.g. to call BVPlaybackService.loadMedia).