Hello.
I want to switch video source on the fly, for screensharing. I read https://openvidu.io/docs/advanced-features/switch-camera/ and try to use navigator.mediaDevices.getDisplayMedia(), but replaceTrack function got exception InvalidModificationError. Can you explain what i need to do next? I do not understand. Reset with reload or initPublisher is not an option. Thanks.
Ok. My bad. I have been replaced audio track with video track(from the example in doc, where getSenders()[0] return audio. But i changed it to [1](get video sender), now no exceptions, but video not changed. replaceTrack function returned undefined instead track.
No luck here for the same problem. Did you get it done then?
it works well with 2.12.0 version now. I think in 2.11.0 its broken.
You are right. Tried with 2.12.0 and now it runs correctly. Working code:
// Switch to screen share
OV.getUserMedia({audioSource: false, videoSource: 'screen'})
.then(function (media) {
var track = media.getVideoTracks()[0];
publisher.replaceTrack(track);
});
// Switch back to camera
OV.getUserMedia({audio: false, video: true})
.then(function(media) {
var track = media.getVideoTracks()[0];
publisher.replaceTrack(track);
});