Camera does not turn off when publishVideo(false) is called

If you look carefully release notes, this was fixed at 2.22.0: Releases - OpenVidu Docs

Make sure you are using 2.22.0 in your clients and server, or greater versions.

1 Like

Thank you so much, now it works fine when I’m toggling on/off the camera. However, when I first initiate the video conference with my video off, the camera indicator stays on until I turn on my camera then turn the camera off, then the light indicator switches off. Any workaround this?

I updated these lines of code:

if (!isUseVideo) {
        publisher.publishVideo(false, true);
        return
    }

How about when we first init the publisher? Is there a way I can set publishVideo to false, true so on initial load, it will turn off the camera completely (the indicator).

OV.initPublisher(
    targetElement,
    {
        audioSource: undefined, // The source of audio. If undefined default audio input
        videoSource: undefined, // The source of video. If undefined default video input
        publishAudio: false,     // Whether you want to start the publishing with audio unmuted or muted
        publishVideo: false,     // Whether you want to start the publishing with video enabled or disabled
        resolution: '640x480',  // The resolution of your video
        frameRate: 30,          // The frame rate of your video
        insertMode: 'APPEND',   // How the video will be inserted according to targetElement
        mirror: false           // Whether to mirror your local video or not
    },
    (error) => {                // Function to be executed when the method finishes
        if (error) {
            console.error('Error while initializing publisher: ', error);
        } else {
            console.log('Publisher successfully initialized');
        }
    }
);

I know that we should be able to call publishVideo(false, true) before publishing, so I tried something like this:

openviduSession
.connect(connectionDetail.token, connectionData)
.then(() => {

    console.log("MeetingRoom - Init Publisher Stream")
    const newPublisher = openvidu.initPublisher(undefined, {
        ...defaultPublisherProperties,
        audioSource: selectedMicrophoneDeviceId, // The source of audio. If undefined default microphone
        videoSource: selectedVideoDeviceId, // The source of video. If undefined default webcam
        publishAudio: isUseMicrophone, // Whether you want to start publishing with your audio unmuted or not
        publishVideo: isUseVideo, // Whether you want to start publishing with your video enabled or not
    });

    newPublisher.isHost = isHost
    newPublisher.raiseHand = false
    
    if (!isUseVideo) newPublisher.publishVideo(false, true);
    
    openviduSession.publish(newPublisher);
    dispatch(reduxSetPublisher(newPublisher))
    dispatch(setInMeetingRoom(true))
})
.catch((error) => {
    console.log(
        "MeetingRoom - There was an error connecting to the session:",
        error.code,
        error.message
    );
});

But still the camera indicator is still on when I initially join the room with my camera off.

Hi @cruizba even if I do pass the second parameter as false when unpublishing the video, the video at the remote end freezes. Is there a workaround for this? Did I missing something?

Thanks in advance for help.

AFAIK this is fixed since version 2.22.0

You can see that behaviour at: OpenviduCall