Hi,
I am following the documentation https://docs.openvidu.io/en/2.16.0/advanced-features/switch-camera/.
I do have some confusions here.
- Which file the documented code can be put (angular)?
- What is the difference between session and this.session and how can get the values?
- Im trying to implement in toolbar.compnent.ts file for which I am calling this function from the toolbar switch camera button.
This is pretty much what I am trying to do as I do not have session variables in the toolbar ts file.
switchCamera() {
let OV = new OpenVidu();
getDevices().then(devices => {
// Getting only the video devices
videoDevices = devices.filter(device => device.kind === ‘videoinput’);
if (videoDevices && videoDevices.length > 1){
// Creating a new publisher with specific videoSource
// In mobile devices the default and first camera is the front one
newPublisher = OV.initPublisher('html-element-id', {
videoSource: isFrontCamera ? videoDevices[0].deviceId :videoDevices[1].deviceId,
publishAudio: true,
publishVideo: true,
mirror: isFrontCamera // Setting mirror enable if front camera is selected
});
isFrontCamera = !isFrontCamera;
if (!this.publisher ){
this.publisher = this.localUsersService.getWebcamPublisher();
}
this.openViduWebRTCService.getWebcamSession().unpublish(this.publisher);
this.publisher = newPublisher
this.openViduWebRTCService.getWebcamSession().publish(this.publisher);
}
});
}
This code can switch the camera from front and back. But it is showing the video only to remote user. The person who is streaming can not see the video.