I am building a simple WebRTC app with OpenTok. I need to be able to select camera, audio input and audio output. Currently that doesn\'t s
So,
The answer gave by @Adam Ullman is not valid anymore since there is a separate audio element created alongside the video element preventing us to use the setSinkId
method of the video element.
I found a solution consisting in finding the audio element from the video one and using its own setSinkId
.
Code:
const subscriber_videoElementCreated = async event => {
const videoElem = event.element;
const audioElem = Array.from(videoElem.parentNode.childNodes).find(child => child.tagName === 'AUDIO');
if (typeof audioElem.sinkId !== 'undefined') {
try {
await audioElem.setSinkId(deviceId);
} catch (err) {
console.log('Could not update speaker ', err);
}
}
};