I am using twilio-video v2.7.
Objective:
Restart the video track after stopping it.
Use case:
Turn off the camera led indicator when video is off and vice-versa just like google meet.
const toggleVideo = () => {
const isOff = !isVideoOn;
room.localParticipant.videoTracks.forEach((t) => {
if (isOff) {
t.track.enable();
t.track.attach(screenRef.current)
} else {
t.track.disable();
t.track.stop()
t.unpublish()
t.track.detach()
}
});
setVideoToggle(isOff);
};