SystemEvents Interface

Estimated reading time: 7 minutes

An application can receive notifications of system events by the SystemEvents interface.
The below table shows supported event types.

Event type Description SystemEventsTypeId SystemEventInfo
Power Status Inform when the status of power is changed.
(i.e. display is turned on or turned off.)
powerStatusChanged PowerStatusInfo
Network Interface Inform when the status of network interface (eth/wlan) is changed.
(i.e. network interface is disabled or enabled.)
networkInterfaceChanged NetworkInterfaceInfo
Network Connection Inform when the status of network connection (eth/wlan) is changed.
(i.e. network connection is established or disconnected.)
networkStatusChanged NetworkStatusInfo
External Input Status Inform when the status of external input (HDMI only) is changed.
(i.e. external input is connected or disconnected with the other device or input signal is detected or lost.)
inputsStatusChanged InputsStatusInfo
Volume Status Inform when the volume or mute status is changed. volumeInfoChanged VolumeInfo
Request of Input Source Change[1] Notify when the change of the input source is requested. beforeInputSrcChange InputSrcInfo
Completion of Input Source Change[1] Notify when the change of the external input is completed. inputSrcChanged InputSrcInfo

[1] Supported only on WebAppRuntime v1.2.65.11.

The SystemEvents interface offers methods to inform the changes of system events (shown in the above table) to an application. An application can control their status by receiving system event status. (i.e. An application can add the decimated object tag only when external input event has been detected.)

Interface: SystemEvents

Methods

  • void addListener(SystemEventsTypeId type, SystemEventsCallback callback)
  • void removeListener(SystemEventsTypeId type, SystemEventsCallback callback)

Interface: SystemEvent

SystemEvent is the event of SystemEventsCallback.

Attributes

  • SystemEventsTypeId systemEventTypeId
  • SystemEventInfo eventMessage

Methods

  • void preventDefault()

    When the HTML5 application calls preventDefault(), the propagation of the event is stopped. Its default action should not be taken as it normally would be. The HTML5 application should handle its default action explicitly.
    This method is available in InputSrcInfo.

Enum: SystemEventsTypeId

It represents the system event types.

  • powerStatusChanged

    Inform RC ON and RC OFF

  • networkInterfaceChanged

    Inform network interface (eth/wlan) is enabled or disabled

  • networkStatusChanged

    Inform network connection is established, IP status is changed

  • inputsStatusChanged

    Inform external input status is changed (support only HDMI)

  • volumeInfoChanged

    Inform volume and mute status is changed

  • beforeInputSrcChange

    Notify when the change of the input source is requested.

  • inputSrcChanged

    Notify when the change of the external input is completed.

Interface: SystemEventInfo

SystemEventInfo is the base interface of each event status.

Attributes

  • DOMTimeStamp timeStamp

    timestamp shows the time when the event has been fired.

Interface: PowerStatusInfo

PowerStatusInfo inherits SystemEventInfo and represents the power information.

Attributes

Enum: PowerStatusType

It represents the RC ON and OFF event types.

  • active

    This value represents RC ON

  • standby

    This value represents RC OFF

Interface: NetworkInterfaceInfo

NetworkInterfaceInfo inherits SystemEventInfo and represents the network interface (wlan and wired) information.

Attributes

  • NetworkInterfaceType netif

    This attribute shows the network interface which is enabled or disabled

  • boolean enabled

enabled shows the network interface is enabled or disabled.

  • true if network interface is enabled.
  • false if network interface is disabled.
Enum: NetworkInterfaceType

NetworkInterfaceType represents network interface type.

  • wlan0
  • eth0

Interface: NetworkStatusInfo

NetworkStatusInfo inherits SystemEventInfo and represents the network connection status (wlan and wired).

Attributes

  • NetworkConnectionStatus connectionInfo

    connectionInfo shows the network connection information (IP address, netmask and so on).

  • boolean enabled
    enabled shows the network connection is established or not.

    • true if network is established
    • false if network is disconnected
Interface: NetworkConnectionStatus

NetworkConnectionStatus represents the network connection detail status.

Attributes
  • NetworkInterfaceType netif
  • DOMString errorDetail
  • DOMString hwAddress
  • DOMString ipAddrV4
  • DOMString ipAddrV6
  • DOMString netmask
  • DOMString gateway
  • Array dns

Interface: InputsStatusInfo

InputsStatusInfo inherits SystemEventInfo and represents the external input (HDMI) status.

Attributes

  • DOMString uri

    uri shows external input which changes status.

  • DOMString title

    title shows the name of external input (e.g. HDMI 1, HDMI 2, ...)

  • boolean connection

    connection shows HDMI device connection status.

    • true if HDMI device is connected.
    • false if HDMI device is disconnected
  • boolean status

    status shows HDMI signal status.

    • true if HDMI input signal is detected.
    • false if HDMI input signal is lost.

Interface: VolumeInfo

VolumeInfo inherits SystemEventInfo and represents the volume status.

Attributes

  • Numeric volume

    volume shows volume value.

  • boolean mute

    mute shows volume is muted or not.

    • true if volume turn to muted.
    • false if mute is canceled.

Interface: InputSrcInfo

InputSrcInfo inherits SystemEventInfo and represents the information related to beforeInputSrcChange and inputSrcChanged .

Attributes

  • DOMString uri

    uri shows the URL of the external input.

  • DOMString title

    title shows the external input name (e.g. HDMI 1, HDMI 2, ...)

  • DOMString dispNum

    dispNum shows the sequence number of the external input (e.g. “HDMI 1”: “1”)

Example

Define and register callbacks

// define callback to handle Power Status events
function onPowerStatusChanged(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.timestamp = " + event.eventMessage.timeStamp);
  console.log("eventMessage.status = " + event.eventMessage.status);
}
// define callback to handle Network Interface events
function onNetworkInterfaceChanged(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.timestamp = " + event.eventMessage.timeStamp);
  console.log("eventMessage.netif = " + event.eventMessage.netif);
  console.log("eventMessage.enabled = " + event.eventMessage.enabled);
}
// define callback to handle Network Status events
function onNetworkStatusChanged(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.timestamp = " + event.eventMessage.timeStamp);
  console.log("eventMessage.connectionInfo.netif = " + event.eventMessage.connectionInfo.netif);
  console.log("eventMessage.connectionInfo.errorDetail = " + event.eventMessage.connectionInfo.errorDetail);
  console.log("eventMessage.connectionInfo.hwAddress = " + event.eventMessage.connectionInfo.hwAddress);
  console.log("eventMessage.connectionInfo.ipAddrV4 = " + event.eventMessage.connectionInfo.ipAddrV4);
  console.log("eventMessage.connectionInfo.ipAddrV6 = " + event.eventMessage.connectionInfo.ipAddrV6);
  console.log("eventMessage.connectionInfo.netmask = " + event.eventMessage.connectionInfo.netmask);
  console.log("eventMessage.connectionInfo.gateway = " + event.eventMessage.connectionInfo.gateway);
  console.log("eventMessage.connectionInfo.dns = " + event.eventMessage.connectionInfo.dns);
  console.log("eventMessage.enabled = " + event.eventMessage.enabled);
}
// define callback to handle External Input Status events
function onInputsStatusChanged(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.timestamp = " + event.eventMessage.timeStamp);
  console.log("eventMessage.uri = " + event.eventMessage.uri);
  console.log("eventMessage.title = " + event.eventMessage.title);
  console.log("eventMessage.connection = " + event.eventMessage.connection);
  console.log("eventMessage.status = " + event.eventMessage.status);
}
// define callback to handle Volume Status events
function onVolumeInfoChanged(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.timestamp = " + event.eventMessage.timeStamp);
  console.log("eventMessage.volume = " + event.eventMessage.volume);
  console.log("eventMessage.mute = " + event.eventMessage.mute);
}

// define callback to handle request of Input Source Change
function onBeforeInputSrcChange(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.url = " + event.eventMessage.url);
  console.log("eventMessage.title = " + event.eventMessage.title);
  console.log("eventMessage.dispNum = " + event.eventMessage.dispNum);
}

// define callback to handle completion of Input Source Change
function onInputSrcChanged(event){
  console.log("systemEventTypeId = " + event.systemEventTypeId);
  console.log("eventMessage.url = " + event.eventMessage.url);
  console.log("eventMessage.title = " + event.eventMessage.title);
  console.log("eventMessage.dispNum = " + event.eventMessage.dispNum);
}

// register callbacks
sony.tv.systemevents.addListener('powerStatusChanged', onPowerStatusChanged);
sony.tv.systemevents.addListener('networkInterfaceChanged', onNetworkInterfaceChanged);
sony.tv.systemevents.addListener('networkStatusChanged', onNetworkStatusChanged);
sony.tv.systemevents.addListener('inputsStatusChanged', onInputsStatusChanged);
sony.tv.systemevents.addListener('volumeInfoChanged', onVolumeInfoChanged);
sony.tv.systemevents.addListener('beforeInputSrcChange', onBeforeInputSrcChange);
sony.tv.systemevents.addListener('inputSrcChanged', onInputSrcChanged);

// unregister callbacks
sony.tv.systemevents.removeListener('powerStatusChanged', onPowerStatusChanged);
sony.tv.systemevents.removeListener('networkInterfaceChanged', onNetworkInterfaceChanged);
sony.tv.systemevents.removeListener('networkStatusChanged', onNetworkStatusChanged);
sony.tv.systemevents.removeListener('inputsStatusChanged', onInputsStatusChanged);
sony.tv.systemevents.removeListener('volumeInfoChanged', onVolumeInfoChanged);
sony.tv.systemevents.removeListener('beforeInputSrcChange', onBeforeInputSrcChange);
sony.tv.systemevents.removeListener('inputSrcChanged', onInputSrcChanged);
Last modified: 7 May 2021