You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i am using this code in my project:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const [availableDeviceIds, setAvailableDeviceIds] = useState([]);
const [counter, setCounter] = useState(0);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
and my videoRecorder is:
i am using this code in my project:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const [availableDeviceIds, setAvailableDeviceIds] = useState([]);
const [counter, setCounter] = useState(0);
useEffect(() => {
navigator.mediaDevices.enumerateDevices().then(mediaDevices => {
const videoDevices = mediaDevices.filter(x => x.kind === 'videoinput');
videoDevices.map((x: any, index) => {
setAvailableDeviceIds(x.deviceId);
});
});
}, [availableDeviceIds]);
const handleSwitchCamera = () => {
console.log('availableDeviceIds', availableDeviceIds);
};
const turnOnCamera = (deviceId: any) => {
if (onTurnOnCamera) {
onTurnOnCamera();
}
navigator.mediaDevices.enumerateDevices().then(mediaDevices => {
const fallbackContraints = {
audio: true,
video: true,
};
let currentConstraints: any;
if (availableDeviceIds?.lenght > 0) {
currentConstraints = merge(
{
video: {
deviceId: {
exact: availableDeviceIds[counter],
},
},
},
constraints,
);
} else {
currentConstraints = merge(
{
video: {
deviceId: {
exact: availableDeviceIds[0],
},
},
},
constraints,
);
}
};
const handleSuccess = stream => {
setStream(stream);
if (onCameraOn) {
onCameraOn();
}
// setSrc(stream);
// onTurnOnCamera();
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
and my videoRecorder is:
<VideoRecorder
constraints={{
audio: true,
video: true,
}}
src={src}
stream={stream}
/>
And after clicking on the button that calls the handleSwitchCamera function, the screen turns black.
The text was updated successfully, but these errors were encountered: