Skip to content

Events

The events are sent from the SDK and plugins using NotificationCenter. The payload for the event is sent in the Notification's userInfo dictionary.

To listen for events is necessary to add an observer using the method

Swift
NotificationCenter.default.addObserver(self, 
    selector: #selector(onEaseLiveReady(notification:)), 
    name: EaseLiveNotificationKeys.easeLiveReady, 
    object: nil)

To post an event is possible using

Swift
NotificationCenter.default.post(
    name: EaseLiveNotificationKeys.playerTime, 
    object: nil, 
    userInfo: [
        EaseLiveNotificationKeys.timecodeUserInfoKey: currentTimecode
    ])

It is possible to send notification to the SDK from anywhere in the app and the SDK will receive them, an example of this is if the mobile app wants to communicate with the web app for both generic messages or language message.

Constants for all the notification names of the events are defined in EaseLiveNotificationKeys.

Events from the SDK

EaseLiveNotificationKeys.easeLiveReady

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

EaseLiveNotificationKeys.easeLiveError

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.errorUserInfoKeyError objectEaseLiveErrorRequired

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.level value and check if it's equal to EaseLiveError.Level.fatal.

Events from the app

EaseLiveNotificationKeys.appLanguage

Sent from the mobile app when it wants to change the language of the overlay UI.

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.languageUserInfoKeyNew languageStringRequired

EaseLiveNotificationKeys.appMessage

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.jsonStringUserInfoKeyThe stringified JSON object to sendStringRequired

Example

Events from the overlay UI

EaseLiveNotificationKeys.bridgeAppStatus

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.statusUserInfoKeyNew statusStringRequired

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

EaseLiveNotificationKeys.bridgeReady

Sent when the bridge is ready to receive events. The app should wait for this event before sending events over the bridge.

EaseLiveNotificationKeys.bridgeStage

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.controlsUserInfoKeyNew controls stateStringRequired

The value of controls should be either visible or hidden.

EaseLiveNotificationKeys.bridgeStageSwipe

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
EaseLiveNotificationKeys.directionUserInfoKeySwipe directionStringRequired

The value of direction should be left, right, up or down.

EaseLiveNotificationKeys.bridgeTime

Sent when the player should change its current time (for example a seek action).

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.timecodeUserInfoKeyNew timecodeInt64Required

EaseLiveNotificationKeys.bridgeState

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.stateUserInfoKeyNew stateStringRequired

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

EaseLiveNotificationKeys.bridgeLanguage

Sent when the overlay UI has set the active language.

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.languageUserInfoKeyActive languageStringRequired
EaseLiveNotificationKeys.availableUserInfoKeyAvailable languagesString[]Required

EaseLiveNotificationKeys.bridgeMessage

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.jsonStringUserInfoKeyThe info to sendStringRequired

Example

EaseLiveNotificationKeys.bridgeSpeed

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.speedUserInfoKeyNew playback speed.FloatRequired

EaseLiveNotificationKeys.bridgeVolume

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.volumeUserInfoKeyNew audio volume.IntRequired

EaseLiveNotificationKeys.bridgeMute

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.muteUserInfoKeyNew audio mute status.BoolRequired

EaseLiveNotificationKeys.bridgeVideoScale

Sent when the player should change the video surface's scale and position. Values are relative to the original video size.

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.videoScaleXUserInfoKeyHorizontal scale factor, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoScaleYUserInfoKeyVertical scale factor, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoPivotXUserInfoKeyHorizontal anchor for the scaling animation, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoPivotYUserInfoKeyVertical anchor of the scaling animation, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoScaleDurationUserInfoKeyDuration of the scale animation in milliseconds.IntRequired

Events from the player plugin

EaseLiveNotificationKeys.playerReady

Sent when the player becomes ready to play.

EaseLiveNotificationKeys.playerTime

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.timecodeUserInfoKeyTimecode at current playback positionInt64Required
EaseLiveNotificationKeys.initialTimecodeUserInfoKeyTimecode at the start of the seekable windowInt64Optional
EaseLiveNotificationKeys.maxTimecodeUserInfoKeyTimecode at the end of the seekable windowInt64Optional

The EaseLiveNotificationKeys.initialTimecodeUserInfoKey and EaseLiveNotificationKeys.maxTimecodeUserInfoKey are optional. If not present the stream is considered to be a Live stream without a seekable buffer.

EaseLiveNotificationKeys.playerError

Notifies the SDK of an error in the player or player plugin.

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.errorUserInfoKeyError objectEaseLiveErrorRequired

EaseLiveNotificationKeys.playerMetadata

Sent when the player reads metadata from the stream. The payload should be a JSON formatted String.

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.metadataUserInfoKeyJSON string containing metadataStringRequired

EaseLiveNotificationKeys.playerState

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.stateUserInfoKeyNew stateStringRequired

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

EaseLiveNotificationKeys.playerStage

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
EaseLiveNotificationKeys.controlsUserInfoKeyNew controls stateStringRequired

The value of controls should be either visible or hidden.

EaseLiveNotificationKeys.playerSpeed

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.speedUserInfoKeyThe new playback speedFloatRequired

EaseLiveNotificationKeys.playerVolume

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.volumeUserInfoKeyThe new audio volumeIntRequired

EaseLiveNotificationKeys.playerMute

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.muteUserInfoKeyThe new audio mute statusBoolRequired

EaseLiveNotificationKeys.playerVideoScale

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

AttributeDescriptionTypeRequired
EaseLiveNotificationKeys.videoScaleXUserInfoKeyHorizontal scale factor, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoScaleYUserInfoKeyVertical scale factor, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoPivotXUserInfoKeyHorizontal anchor for the scaling animation, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoPivotYUserInfoKeyVertical anchor of the scaling animation, between 0 and 1.FloatRequired
EaseLiveNotificationKeys.videoScaleDurationUserInfoKeyDuration of the scale animation in milliseconds.IntRequired