Tutorial: Work with surfaces

Work with surfaces

Get all available instances in the system:

console.log(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: // bottom
            intance.moveBottom();
            break;
        case 38: // up
            instance.moveUp();
            break;
        case 39: // top
            intance.moveTop();
            break;
        case 40: // down
            instance.moveDown();
            break;
    }
});