Tutorial: Work with displays

Work with displays

Get all available instances in the system:

console.log(stbDisplayManager.list);

Get information about first available display:

var display = stbDisplayManager.list[0];

console.log('display.type:', display.type);
console.log('display.height:', display.height);
console.log('display.width:', display.width);

Detect state HDMI device with one of the following methods:

// legacy
window.stbEvent = {
    onEvent: function ( event ) {
        switch ( Number(event) ) {
            case 32:
                console.log('HDMI device has been connected.');
                break;
            case 33:
                console.log('HDMI device has been disconnected.');
                break;
        }
    }
};

// new recommended approach
stbDisplayManager.list[0].onStateChange = function ( state ) {
    switch ( state ) {
        case 1:
            console.log('HDMI device has been connected, but not in active state e.i. standby mode, TV is off.');
            break;
        case 2:
            console.log('HDMI device has been connected in active state.');
            break;
        default:
            console.log('HDMI device has been disconnected.');
            break;
    }
};

Force output to DVI mode:

stbDisplayManager.list[0].forceToDVI = true;