Example: Channel Table

The channel table is a list containing the names of channels, their logical channel number, and the multicast address used to access the channel. This example demonstrates how the channel table object can be sent from an infocast server and received/displayed on the IP-STB. The code uses the Information Service (see IS example for more details) by subscribing to the cfg.media.chaneltable object. This results in a callback if there are changes to the objects value.

The object is transmitted from the Infocast server, and received by the IP-STB automatically. If a channel list was previously displayed, it is removed from the document. The portal then adds a TSPAN element to the DOM, one for each line in the channel table.

if (!is.isObjectDefined("cfg.media.channeltable")) {
    alert("cfg.media.channeltable not found!");
    return;
}

// if there already is a channel table in the document, remove it
(textbox.childNodes.length > 0) 
removeChannelTable();
var channeltable = is.getObject("cfg.media.channeltable");

Displaying

The last thing to happen is building the list for displaying in the portal. SVG does not perform word wrapping automatically, so the portal first splits the channel table (one big string) into an array of strings based on the newline character. For each item in this array, a new DOM element (TSPAN) is created and attached to the DOM. The SVG 'dy' attribute is used to position each element reletave to the previous one.

var channelarray = channeltable.split("\n");
for(i=0; i < channelarray.length; i++) {
    var e = document.createElement("tspan");
    e.textContent = channelarray[i];
    e.setAttribute("x", "0");
    e.setAttribute("dy", linespacing);
    textbox.appendChild(e);
}