-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch camera not working #170
Comments
shohrejf
changed the title
switch camera does not work in the video recorder
switch camera not working
Jun 29, 2022
Facing the same issue too, the camera switch does not seem to be working. |
I'm seeing same issue, reverted to 3.18.4 and it works |
3.18.4 is working but not turn on the flash light on iPhone. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: