Callbacks
There are a number of Javascript callbacks that you can access in order to respond to system events and react accordingly.
Recommend Using in the Playlist HTML Overlay
These callbacks are usually more useful when implementing code within an HTML overlay vs a Webapp.
Callback | Description | Returns |
---|---|---|
onApiStatusChange | Called when the API Status changes. You can use this to react to the device going online or offline. | The current status string |
onPageChange | Called when the Playlist transitions to a new page. Useful for overrides and responding to different pages. | The current page object |
onPlaylistChange | Called when the Playlist is updated, typically when playlist name or id is changed. | The current playlist object |
onGeoChange | Called when the geographic coordinates of the device change. You'll need a device and a Player that supports forwarding geographic coordinates such as our Android Player running on an Android tablet. | The current coordinates object |
onOverrideStart | Called when an Override starts | The starting override object |
onOverrideEnd | Called when an Override ends | The ending override object |
onSerialMessage | Called when a message is received (a string) from the configured serial port on the device | The message string |
onPageDuration | called when page start or page duration changes. Only works for: page with a fixed "duration" set page without a "duration" but there's a video (E.g. YouTube) that would cause the playlist to advance. | The number 'float' |
Example of callbacks usage:
window.onloadTelemetryTV = function (ttv) {
ttv.onApiStatusChange(function (status) {
console.log(`API Status change to: ${status}`);
});
ttv.onPageChange(function (page) {
console.log(`Current Page: ${page.name} (${page.id})`);
});
ttv.onPlaylistChange(function (playlist) {
console.log(`Current Playlist: ${playlist.name} (${playlist.id})`);
});
ttv.onGeoChange(function (coordinates) {
console.log('My oordinates are now:', coordinates);
});
ttv.onOverrideStart(function (override) {
console.log(`Override started: ${override.name} (${override.id})`);
});
ttv.onOverrideEnd(function (override) {
console.log(`Override ended: ${override.name} (${override.id})`);
});
ttv.onSerialMessage(function (message) {
console.log('Serial Message received:', message);
});
ttv.onPageDuration((cb) => {
window.console.log('Length of video', cb)
})
};
Updated about 2 months ago