Tutorial: Work with UPnP resources

Work with UPnP resources

Initialization of UPnP service:

stbUPnP.init();

Get current server list in network:

console.log('current server list in network:', stbUPnP.getServerListSync());

Set event listeners to handle received data:

stbUPnP.onOpenServer = function ( data, error ) {
    if ( !error ) {
        console.log('onOpenServer data:', data);
    } else {
        console.log('onOpenServer error:', error);
    }
};

stbUPnP.onOpenPage = function ( data, error ) {
    if ( !error ) {
        console.log('onOpenPage data:', data);
    } else {
        console.log('onOpenPage error:', error);
    }
};

stbUPnP.onOpenContext = function ( data, error ) {
    if ( !error ) {
        console.log('onOpenContext data:', data);
    } else {
        console.log('onOpenContext error:', error);
    }
};

Open server, setting current server:

stbUPnP.openServer(udn);

Get information about pages:

console.log('total pages amount of the current folder:', stbUPnP.pagesCount);

console.log('items per page:', stbUPnP.pageSize);

console.log('current page number:', stbUPnP.pageNumber);

Open page in the current folder:

stbUPnP.openPage(pageId);

Set not case sensitive filter by item name:

stbUPnP.setFilterName(name);

Set filter by item type (all, audio files, images, video or folders):

stbUPnP.setFilterType(stbUPnP.TYPE_VIDEO);

Start retrieving data:

stbUPnP.openContext(contentType);

Deinitialization of UPnP service:

stbUPnP.deinit();