react-native-twilio-video-webrtc icon indicating copy to clipboard operation
react-native-twilio-video-webrtc copied to clipboard

FlipCamera error

Open Anytram opened this issue 4 years ago • 7 comments

Hello, twilioRef?.current?.flipCamera() throws an exception while I try to flip camera when denied permissions to camera usage on iOS platform. How can I catch this error? flipCamera() method returns undefined photo_2021-07-23 10 45 15

Anytram avatar Jul 23 '21 09:07 Anytram

While the error handling could be improved, I think the best way to avoid this would be to disable the camera flip behavior until the camera has started. You can know what that happens by listening to the onCameraDidStart event.

slycoder avatar Jul 26 '21 02:07 slycoder

It was helpful, thank you. I have another question on android you cannot connect to session if you don't have camera permissions ([FailToConnect]ERROR: {"error": "No camera is supported on this device"}), on iOS you can connect but for example flip throws an error, wouldn't be great to unify those behaviour?

Anytram avatar Jul 27 '21 06:07 Anytram

Also I have question about android, when the app asks for permissions first time and we deny it, and then app asks again Twilio still throws [FailToConnect]ERROR: {"error": "No camera is supported on this device"}. The same situation after denying the first ask and changing permissions in device setting. It disappears only after restarting the app and this is kind of problematic. Can I somehow force Twilio to refresh?

Anytram avatar Jul 27 '21 06:07 Anytram

@slycoder can you look into this?

Anytram avatar Jul 30 '21 12:07 Anytram

Before asking again, you might need to unmount the twilio video component and remount it.

slycoder avatar Aug 19 '21 08:08 slycoder

How can I unmount that component?

Anytram avatar Aug 19 '21 08:08 Anytram

You can add a state variables, like isAskingForPermissions, and then guard the twilio video component with that:

{!isAskingForPermissions && <TwilioVideo ... />}

So that once isAskingForPermissions is true, then the component will be unmounted, and when it becomes false again, it will be remounted.

slycoder avatar Aug 20 '21 03:08 slycoder