Switching Camera in the session

Hello everyone,

I’m trying to add a button to switch camera during a session, I’m currently working on the openvidu-insecure-angular project.
At the moment, I can get all the devices avalaible and then selected the one I want, then I switch it by initializing a new publisher and then publishing it. And then I do :

this.mainStreamManager = publisher;
this.publisher = publisher;

So it working for the current user in the session but the other one connected to the session don’t have any changement. It means that the user which change his camera only changed for him and not for the other one.
I can understand it with my solution because I’m forcing the display of the new camera in the current mainStreamManager but I have no clue how to changed it for everyone…?
I would like to know if it’s possible to get the current publisher and then set a new camera for it so it would work I guess, but I have no clue how to retrieve the current publisher ?

Kinds Regards

Hello @DreamEp,

You need to unpublish the old publisher and publish the new publisher created.

Everything is detailed in OpenVidu switch cameras documentation

@CSantosM Thanks you very much it looks like it’s working, but I got a new problem by doing that.
By unpublishing the publisher the other members of the session will get a white screen on their mainStreamManager, so they have to click on the new publisher to update their mainStreamManager.
Is there a way to change dynamically the mainStreamManager for the other users of the session ?
Or a way to don’t unpublish the publisher, I know we can use replaceTracks but I dont know how to get tracks out of streams.
Like I can’t change the videoSource dynamically from a publisher with the deviceid ?

Just changing the mediaStreamManager object by the new subscriber received in your Angular app.

As the docs says and I have no doubt that you have read it: