Appearance
Widget plugin
A widget plugin can be used to embed native UI inside the overlay.
An embed layer is created in the Studio project, configured with the name of the widget to use. The widget plugin registers itself as the renderer of that layer by specifying the same name in its componentName
property. When the overlay creates the layer the plugin's install
function is called, where it can add its own subviews.
Implementation
Create a class implementing WidgetPlugin
interface.
String getComponentName()
Set to same name that was configured on the embed layer in the Studio project, in which the widget will show.
void install(FrameLayout container, WidgetData data);
Called when an embed layer will be created in the overlay. Here you can add your views to the container.
Attribute | Description | Type |
---|---|---|
container | Embed layer's view in which to add your views | FrameLayout |
data | Information about the current overlay | WidgetData |
data.accountId | Account ID of the overlay | String |
data.projectId | Project ID of the overlay | String |
data.programId | Program ID of the overlay | String |
data.env | Environment of the overlay ("prod","staging","dev") | String |
data.params | Other parameters passed to the current loaded overlay | HashMap<String,String> |
data.embedData | Data configured on the embed layer in the Studio project | HashMap<String,String> |
data.layerInstanceId | Instance ID of the embed layer | String |
void show(FrameLayout container, WidgetData data)
Called when an embed layer will be shown in the overlay.
void hide(FrameLayout container, WidgetData data)
Called when an embed layer will be hidden in the overlay.
void destroy()
Called when the widget will be removed, ie the EaseLive instance is being destroyed.
void onPlayerTime(long time)
Called when time changes in the player. The value is UTC time in milliseconds since 1970-01-01. Can be used to sync timed data shown in the widget.
void onPlayerState(PlayerState state)
Called when player state changes.
Usage
Register widget plug-in after instantiating EaseLive, but before create is called
swift
easeLive = EaseLive(...)
// register before create easeLive.create
easeLive.use(new MyCustomWidget())
easeLive.create()
Example
kotlin
class MyCustomWidget: WidgetPlugin {
override fun getComponentName(): String {
return "myCustomWidget"
}
override fun install(container: FrameLayout, data: WidgetData) {
val button = Button(container.context)
button.isFocusable = true
button.isFocusableInTouchMode = true
button.text = "my button"
container.addView(
button,
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
)
}
override fun show() {
// called when the layer will be shown in the overlay
// start data updating, animations, etc
}
override fun hide() {
// called when the layer will be hidden in the overlay
// stop data updating, animations, etc
}
override fun destroy() {
// called when the container layer will be removed
}
override fun onPlayerTime(time: Long) {
// player's absolute time in milliseconds since 1970-01-01T00:00:00Z.
// can be used to sync timed data shown in the widget
}
override fun onPlayerState(state: PlayerState) {
if (state == PlayerState.PLAYING) {
// video is playing
}
}
}
easeLive = EaseLive(easeLiveView,
accountId,
projectId,
programId)
// register widget plug-in before create
easeLive.use(new MyCustomWidget())
easeLive.create()