Tutorial: Work with surfaces

Work with surfaces

Get all available instances in the system:

console.log('all available instances in the system:', stbSurfaceManager.list);

Set order information for all surfaces with operation check status:

if ( !stbSurfaceManager.setOrder([s3, s2, s1]) ) {
    console.log('Was not able to reorder!');
}

Switch two given surfaces:

stbSurfaceManager.swap(stbSurfaceManager.list[0], stbSurfaceManager.list[1]);
stbSurfaceManager.swap(stbSurfaceManager.list[1], stbSurfaceManager.list[0]);

Restore the default surfaces order:

stbSurfaceManager.reset();

Surface instance manipulations on user input:

var instance = stbSurfaceManager.list[0];

window.addEventListener('keydown', function ( event ) {
    switch ( event.keyCode ) {
        case 37:
            console.log('keydown: bottom');
            intance.moveBottom();
            break;
        case 38:
            console.log('keydown: up');
            instance.moveUp();
            break;
        case 39:
            console.log('keydown: top');
            intance.moveTop();
            break;
        case 40:
            console.log('keydown: down');
            instance.moveDown();
            break;
    }
});