Device Manager
Manage audio and video device settings.
info
Always make sure to call deviceManager.storeConstraints()
after devices have
changed, so that a following start_stream
event will
actually use them.
import { DeviceManager } from 'eyeson';
const deviceManager = new DeviceManager();
deviceManager.onChange(event => { // changeHandler
event.error; // if set it contains { name, message }, default null
event.cameras; // available cameras
event.microphones; // available microphones
event.speakers; // available speakers
event.sinkId; // available sinkId (audio output selection)
event.stream; // stream to test devices with
event.constraints; // selected media constraints
event.options; // selected options
});
deviceManager.start(isMobile); // start checking device changes, isMobile defaults to false
deviceManager.setVideoInput(deviceId); // switch camera
deviceManager.setAudioInput(deviceId); // switch microphone
deviceManager.setAudioOutput(sinkId); // switch audio output, speakers
deviceManager.storeConstraints(); // store current selection
deviceManager.removeListener(changeHandler); // remove listeners if registered via onChange
deviceManager.updateWithOptions(options, isMobile); // options = { audio: true/false, video: true/false, eco: true/false }, isMobile defaults to false
deviceManager.stop(); // stop checking device changes
Virtual Background
Since v1.6.2 virtual background is available. For more information, see Techblog How To Provide Virtual Backgrounds In Your Meetings.
const virtualBackgroundType = DeviceManager.getStoredVirtualBackgroundType();
const deviceManager = new DeviceManager();
deviceManager.setVirtualBackgroundType(virtualBackgroundType);
deviceManager.storeConstraints(); // store selected type
Available types are off
, blur:8
, blur:16
, and image:<url|path>
.