| ARRIS Enterprises, Inc. Confidential Information |
TOI3/JS EventsTOI uses JavaScript events and event listeners to allow the portal to asynchronously respond to events within the KreaTV platform. Useful events include playback of a recorded program reaching the end, the connection or disconnection of an HDMI cable, errors with playback or with the network, and so on. The portal registers listeners, also known as callback functions, with event targets (a TOI object that generates events). When the event occurs, the appropriate callback function will be called, and useful information about the event will be passed into the callback as an argument. ExamplesVideo output eventLet's look at a simplified example of adding an event listener to detect when a TV is connected or disconnected with a HDMI cable:
This example begins by asking the Video Output Service for the current When the HDMI cable is inserted or removed, the ON_DISPLAY_CAPABILITIES_CHANGED event
will be triggered, and any registered listeners will be called. In the above
example, the added listener is the Media PlayerIt is common to add event listeners to the media player, to receive notifications on state changes (e.g. a transition from play to paused). Let's look at how this is set up:
The documentation for |