Tutorial: Work with Digital Video Broadcasting

Work with Digital Video Broadcasting

Get array of all available instances in the system:

console.log(stbDvbManager.list);

Get first available input:

var input = stbDvbManager.list[0];

Manual control of antenna power state:

// turn on
input.antennaPower = true;

// turn off
input.antennaPower = false;

Get information about input:

console.log('current state of this tuner:', input.state);

console.log('signal level:', input.signalLevel);

console.log('signal quality:', input.signalQuality);

console.log('supported scan types for this tuner:', input.supportedScanTypes);

console.log('currently supported scan types for this tuner:', input.currentScanTypes);

console.log('bit error rate:', input.bitErrorRate);

Set current scan type for this input:

console.log('DVB-C signal:', input.setSignalType(1));

console.log('DVB-T signal:', input.setSignalType(2));

console.log('DVB-T2 signal (not available for MAG270):', input.setSignalType(3));

console.log('DVB-S/DVB-S2 signal:', input.setSignalType(4));

Set event listeners to handle received data:

input.onScanProgress = function ( info ) {
    console.log('DVB channels scanning is in progress:', info);
    // {"state":"searching","channel":0,"frequency":51000,"progress":0,"inputIndex":0,"polarization":"H"}
};

input.onChannelFound = function ( info ) {
    console.log('DVB channel is found:', info);
    // {"frequency":474000,"inputIndex":0,"bandwidth":4000,"polarization":"H","modulation":-1,"symbolRate":6875800,"id":"C.0.000474.06875-01","type":1,"uri":"dvb://C.0.000474.06875-01","scrambled":false,"name":"MEGA","provider":"","isRadio":false,"channelNumber":0}
};

input.onAntennaPower = function () {
    console.log('DVB antenna is powered off.');
};

Start channel scanning (parameters explanation see in stbDvbInput.startScan method):

input.startScan({
    from: 10,
    to: 100,
    type: 2,
    bandwidth: 6,
    step: 5,
    modulation: 0,
    scanMode: 0,
    frequency: 12,
    networkId: 0
});

Tune receiver to specified frequency (parameters explanation see in stbDvbInput.tune method):

input.tune({
    frequency: 10,
    polarization: 'V',
    symbolRate: 2,
    type: 2
});

Stop channel scan:

input.stopScan();

Make a new channel list as a subset of parent list:

var channelList1, channelList2;

channelList1 = stbDvbManager.createChannelList(['lt', 'channelNumber', 123]);
console.log('any channels with LCN less than 123:', channelList1);

channelList2 = stbDvbManager.createChannelList();
console.log(channelList2);

Root list of all available channels from all inputs:

console.log(stbDvbManager.channelList);

Get the channel index in this channel list:

channelList2.add(channelList1.getChannel('123').id);

Remove the given channel from this channel list with check operation status:

if ( !channelList2.remove('ccid:0.12.1') ) {
    console.log('Was not able to remove a channel!');
}

if ( !channelList2.remove(5) ) {
    console.log('Was not able to remove a channel!');
}

Get channel detailed info:

console.log('channel detailed info:', channelList2.getChannel(5));
console.log('channel detailed info:', channelList2.getChannel('ccid:0.12.1'));

Get channel range:

console.log('channel range:', channelList2.slice(1, 5));

Get the channel index in this channel list:

console.log('the channel index in this channel list:', channelList2.indexOf('ccid:0.12.1'));

Remove all channels from this channel list:

channelList2.clear();