Skip to content

Events

To listen for events sent by the SDK and overlay, add listeners using easeLive.on:

kotlin
easeLive.on<EaseLiveEvent.ReadyEvent> {
    Log.d(TAG, "EL ready")
}

easeLive.on<EaseLiveEvent.ErrorEvent> { e ->
    Log.d(TAG, "EL error " + e.error)
    if (e.error.level == Error.LEVEL_FATAL) {
        // fatal error. For example the UI failed to load.
        // remove the overlay and fallback to a normal video
        easeLive?.destroy()
        easeLive = null
    } else {
        // non-fatal error/warning.
    }
}
java
class ExampleListen {
    EaseLive easeLive;

    void setupEaseLiveEvents() {
        easeLive.on(EaseLiveEvent.ReadyEvent.class, e -> Log.d(TAG, "EL ready"));
        easeLive.on(EaseLiveEvent.ErrorEvent.class, e -> {
            Error error = e.getError();
            if (error.getLevel() == Error.LEVEL_FATAL) {
                easeLive.destroy();
                easeLive = null;
            }
        });
    }
}

To listen for events and then later stop listening:

kotlin
val onEaseLiveReady: (EaseLiveEvent.ReadyEvent) -> Unit = { }
// start listening
easeLive!!.on(onEaseLiveReady)
// stop listening
easeLive!!.off(onEaseLiveReady)

To send an event to the overlay, call easeLive.emit:

kotlin
easeLive.emit(EaseLiveEvent.MessageEvent("myPrefix.myEvent", JSONObject()))
java
class ExampleEmit {
    EaseLive easeLive;

    void sendCustomEvent() {
        easeLive.emit(new EaseLiveEvent.MessageEvent("myPrefix.myEvent", new JSONObject()));
    }
}

Events from the SDK to the app

EaseLiveEvent.ReadyEvent

Sent from the SDK when all the components becomes fully operational.

EaseLiveEvent.ErrorEvent

Sent when an error occurs in the SDK or plugins. The app should destroy the SDK on fatal errors.

AttributeDescriptionTypeRequired
errorError objecttv.easelive.easelivesdk.model.ErrorRequired

The error contained in the notification has an identification code to specify if it's a Fatal error or just a Warning, it's possible to check that reading the error.getLevel() value and check if it's equal to Error.LEVEL_FATAL.

Events from the app to the overlay

EaseLiveEvent.MessageEvent

Sent from the mobile app to notify about a generic message, which can be used for custom functionality in the overlay.

AttributeDescriptionTypeRequired
eventEvent name as defined in the overlay projectStringRequired
metadataJSON object to sendJSONObjectOptional

Example

Events from the overlay to the app

EaseLiveEvent.StatusEvent

Sent when the status of the overlay changes. When the overlay was disabled, it should be removed from the app.

AttributeDescriptionTypeRequired
STATUSNew statusStringRequired

Status is a String with possible values enabled, hidden, disabled.

EaseLiveEvent.BridgeReadyEvent

Sent when the bridge is ready to receive events. Events from the app will not be sent until this is received.

EaseLiveEvent.PlayerControlsEvent

Sent when the stage of the overlay UI is clicked, and should trigger a change in the visibility of the player controls.

AttributeDescriptionTypeRequired
visibleNew controls stateBooleanRequired

EaseLiveEvent.StageSwipedEvent

Sent when the stage of the overlay UI is swiped, and can be used to trigger a change in the visibility of player controls.

AttributeDescriptionTypeRequired
directionSwipe directiontv.easelive.easelivesdk.model.DirectionRequired

EaseLiveEvent.PlayerTimeEvent

Sent when the player should seek to the given timecode.

AttributeDescriptionTypeRequired
timecodeNew timecode as milliseconds since 1970-01-01T00:00:00ZLongRequired

EaseLiveEvent.PlayerStateEvent

Sent when the player should change its playback state, for example to pause or play.

AttributeDescriptionTypeRequired
stateNew statetv.easelive.easelivesdk.model.PlayerStateRequired

EaseLiveEvent.MessageEvent

Sent from the overlay UI to notify about a generic message, which can be used for custom functionality.

AttributeDescriptionTypeRequired
eventEvent nameStringRequired
metadataEvent metadataJSONObjectRequired

Example

EaseLiveEvent.PlayerSpeedEvent

Sent when the player should change its speed (playback rate). E.g. 0.5 is half speed, 1 is normal speed, 2 is 2x fast-forward.

AttributeDescriptionTypeRequired
speedNew playback speedFloatRequired

EaseLiveEvent.PlayerVolumeEvent

Sent when the player should change its audio volume. E.g. 0 is silent, 100 is normal volume.

AttributeDescriptionTypeRequired
volumeNew audio volumeIntRequired

EaseLiveEvent.PlayerMuteEvent

Sent when the player should change its audio mute status. E.g. true is muted, false is unmuted.

AttributeDescriptionTypeRequired
muteNew audio mute statusBooleanRequired

EaseLiveEvent.PlayerVideoScaleEvent

Sent when the player should change the video surface's scale and position.

AttributeDescriptionTypeRequired
scaleXHorizontal scale factor, between 0 and 1.FloatRequired
scaleYVertical scale factor, between 0 and 1.FloatRequired
pivotXHorizontal anchor for the scaling animation, between 0 and 1.FloatRequired
pivotYVertical anchor of the scaling animation, between 0 and 1.FloatRequired
durationDuration of the scale animation in milliseconds.LongRequired

Events from the player plugin to the overlay

These events are sent by the PlayerPlugin to the overlay.

EaseLiveEvent.PlayerReadyEvent

Sent when the player becomes ready to play.

EaseLiveEvent.PlayerTimeEvent

Sent when the player reads the timecode for the current playback position. All timecodes should be in milliseconds since 1970-01-01T00:00:00Z.

AttributeDescriptionTypeRequired
timecodeTimecode at current playback positionLongRequired
initialTimecodeTimecode at the start of the seekable windowLongOptional
maxTimecodeTimecode at the end of the seekable windowLongOptional

The initialTimecode and maxTimecode are optional. If not present the stream is considered to be a Live stream without a seekable buffer.

EaseLiveEvent.PlayerMetadataEvent

Sent when the player reads metadata from the stream.

AttributeDescriptionTypeRequired
metadataJSON containing metadataJSONObjectRequired

EaseLiveEvent.PlayerStateEvent

Sent when the player changes state, for example a change from paused to playing.

AttributeDescriptionTypeRequired
stateNew statetv.easelive.easelivesdk.model.PlayerStateRequired

Where state is a String with possible values playing, stopped, paused, seeking, buffering.

EaseLiveEvent.PlayerControlsEvent

Sent when the player changes the visibility of the player controls. Typically when the player stage is clicked or if the native controls hide automatically after a timeout, the player plugin should notify about this change.

AttributeDescriptionTypeRequired
visibleNew controls visibilityBooleanRequired

EaseLiveEvent.PlayerSpeedEvent

Sent when the player has changed its speed (playback rate). E.g. 0.5 is half speed, 1 is normal speed, 2 is 2x fast-forward.

AttributeDescriptionTypeRequired
speedNew playback speedFloatRequired

EaseLiveEvent.PlayerVolumeEvent

Sent when the player has changed its audio volume. E.g. 0 is silent, 100 is normal volume.

AttributeDescriptionTypeRequired
volumeNew audio volumeIntRequired

EaseLiveEvent.PlayerMuteEvent

Sent when the player has changed its audio mute status. E.g. true is muted, false is unmuted.

AttributeDescriptionTypeRequired
muteNew audio mute statusBooleanRequired

EaseLiveEvent.PlayerVideoScaleEvent

Sent when the player will change the video surface's scale and position.

AttributeDescriptionTypeRequired
scaleXHorizontal scale factor, between 0 and 1.floatRequired
scaleYVertical scale factor, between 0 and 1.floatRequired
pivotXHorizontal anchor for the scaling animation, between 0 and 1.floatRequired
pivotYVertical anchor of the scaling animation, between 0 and 1.floatRequired
durationDuration of the scale animation in milliseconds.longRequired