The Subscriber has maxResolution and maxFrameRate properties:
maxResolution
- Object containing a width and a height property. When set the Subscriber will try to use a resolution that falls within those values.maxFrameRate
- The maximum frame rate the Subscriber should use. This is an integer value.
You can initialise these values by passing them to the session.subscribe method eg.
var subscriber = session.subscribe(stream, subscriberEl, {
maxResolution: {
width: 640,
height: 480
},
maxFrameRate: 15
});
You can also set these values later once you have already started subscribing with:
subscriber.setMaxResolution({
width: 640,
height: 480
});
subscriber.setMaxFrameRate(15);
Here is an example of how you would dynamically set the resolution and frame rate. This example has moveOnStage
and moveOffStage
methods which will move the participants on and off stage. The logic for moving those participants on and off stage is not included. It is assumed though that some kind of signaling will be used to move people on and off stage. It is also assumed that the name of the streams for a person who is initially on stage is set to 'onstage'
.
var onStageResolution = {
width: 1280,
height: 720
},
onStageFrameRate = 30,
offStageResolution = {
width: 320,
height: 240
},
offStageFrameRate = 15;
var moveOnStage = function (subscriber) {
$('#' + subscriber.id).addClass('onstage');
subscriber.setMaxResolution(onStageResolution);
subscriber.setMaxFrameRate(onStageFrameRate);
}
var moveOffStage = function (subscriber) {
$('#' + subscriber.id).removeClass('onstage');
subscriber.setMaxResolution(offStageResolution);
subscriber.setMaxFrameRate(offStageFrameRate);
}
session.on('streamCreated', function (event) {
var maxResolution = offStageFrameRate,
maxFrameRate = offStageFrameRate;
if (event.stream.name === 'onstage') {
maxResolution = onStageResolution;
maxFrameRate = onStageFrameRate;
}
session.subscribe(event.stream, 'subscribers', {
insertMode: 'append',
maxResolution: maxResolution,
maxFrameRate: maxFrameRate
});
});