I wanted to detect switch off and switch on event on Twilio network bandwidth API. I am following this article (https://www.twilio.com/docs/video/tutorials/using-bandwidth-profile-api).
This is my configuration for api.
bandwidthProfile: {
video: {
mode: 'grid',
trackSwitchOffMode: 'detected',
maxSubscriptionBitrate: 2400000, // 2.4MB
dominantSpeakerPriority: 'high',
maxTracks: 3,
renderDimensions: {
high: { width: 1080, height: 720 },
standard: { width: 640, height: 480 },
low: { width: 160, height: 80 }
}
}
},
I am getting isSwitchOff value false every time.
Thanks in advance
Edit This is the code where isSwitchedOff
is used:
const [isSwitchedOff, setIsSwitchedOff] = useState(track && track.isSwitchedOff);
useEffect(() => {
setIsSwitchedOff(track && track.isSwitchedOff)
if (track) {
const handleSwitchedOff = () => setIsSwitchedOff(true)
const handleSwitchedOn = () => setIsSwitchedOff(false)
track.on("switchedOff", handleSwitchedOff)
track.on("switchedOn", handleSwitchedOn)
return () => {
track.off("switchedOff", handleSwitchedOff);
track.off("switchedOn", handleSwitchedOn);
};
}}, [track]);