# Switch Camera on iphone doesn't work with 1.11.5 after user restarts video

**URL:** <https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940>\
**Category:** Video SDK\
**Created:** [May 29, 2024, 3:56pm UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940 "2024-05-29T15:56:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkpchang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jkpchang/32/60160_2.png) [@jkpchang](https://devforum.zoom.us/u/jkpchang)\
**Post date:** [May 29, 2024, 3:56pm UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940/1 "2024-05-29T15:56:06Z")

</div>

\*\* Video SDK 1.11.5 for web app (React) \*\*

**Description**  
We’ve installed the latest 1.11.5 Video SDK (for web) and found out that the `switchCamera` function for iPhone doesn’t work after the user has stopped and restarted the video.

**How To Reproduce**

```auto
await mediaStream.startVideo();

// works
await mediaStream.switchCamera(MobileVideoFacingMode.Environment); 
await mediaStream.switchCamera(MobileVideoFacingMode.User); 

await mediaStream.stopVideo();
await mediaStream.startVideo();

// doesn't works
await mediaStream.switchCamera(MobileVideoFacingMode.Environment); 

```

The camera is still the front-facing camera. Doesn’t matter how many times I switch back and forth, it remains showing the front-facing camera.

The same behavior works well in version 1.11.0. Seems like a regression bug.

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [May 30, 2024, 5:30am UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940/2 "2024-05-30T05:30:19Z")

</div>

Hey @jkpchang

Thanks for your feedback.

We can reproduce this issue and will fix it soon.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![dareveggen](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dareveggen/32/59986_2.png) [@dareveggen](https://devforum.zoom.us/u/dareveggen)\
**Post date:** [May 30, 2024, 6:31am UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940/3 "2024-05-30T06:31:34Z")

</div>

this happened to me as well, waiting for the solution

thanks

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [May 30, 2024, 7:34am UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940/4 "2024-05-30T07:34:27Z")

</div>

Hey @dareveggen @jkpchang

Thanks for your feedback.

A workaround for it is to specify the `cameraId` parameter on `stream.startVideo` method so that `stream.switchCamera` won’t be affected by this issue.

```javascript
await mediaStream.startVideo({cameraId:MobileVideoFacingMode.User});
// works
await mediaStream.switchCamera(MobileVideoFacingMode.Environment); 
await mediaStream.switchCamera(MobileVideoFacingMode.User); 

await mediaStream.stopVideo();
await mediaStream.startVideo({cameraId:MobileVideoFacingMode.User}); // Explicitly set the camera ID.

// works
await mediaStream.switchCamera(MobileVideoFacingMode.Environment); 

```

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![drivezoneonline365](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/drivezoneonline365/32/58299_2.png) [@drivezoneonline365](https://devforum.zoom.us/u/drivezoneonline365)\
**Post date:** [June 2, 2024, 5:45pm UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940/5 "2024-06-02T17:45:21Z")

</div>

Add debugging statements to log the current state of the camera and any errors returned by the SDK functions. For example:  
await mediaStream.startVideo();  
console.log(‘Video started’);

// Initial switch works  
await mediaStream.switchCamera(MobileVideoFacingMode.Environment);  
console.log(‘Switched to environment camera’);  
await mediaStream.switchCamera(MobileVideoFacingMode.User);  
console.log(‘Switched to user camera’);

await mediaStream.stopVideo();  
console.log(‘Video stopped’);  
await mediaStream.startVideo();  
console.log(‘Video started again’);

// Subsequent switch fails  
try {  
await mediaStream.switchCamera(MobileVideoFacingMode.Environment);  
console.log(‘Switched to environment camera’);  
} catch (error) {  
console.error(‘Error switching to environment camera:’, error);  
}

### Workaround

As a temporary workaround, you might want to reinitialize the media stream completely after restarting the video. This can be more resource-intensive, but it could bypass the issue until a permanent fix is provided.

### Reinitialize Media Stream Example

async function reinitializeMediaStream() {  
await mediaStream.stopVideo();  
await mediaStream.stop(); // Completely stop the media stream

```
// Reinitialize the media stream
await mediaStream.startVideo();
console.log('Reinitialized video stream');

try {
    await mediaStream.switchCamera(MobileVideoFacingMode.Environment);
    console.log('Switched to environment camera');
} catch (error) {
    console.error('Error switching to environment camera:', error);
}

```

}

// Usage  
await reinitializeMediaStream();

```auto
For more information, visit: [Drive Zone](https://drivezoneapk.com/)

```

---

<div class="post-metadata">

**Author:** ![jkpchang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jkpchang/32/60160_2.png) [@jkpchang](https://devforum.zoom.us/u/jkpchang)\
**Post date:** [June 3, 2024, 4:03pm UTC](https://devforum.zoom.us/t/switch-camera-on-iphone-doesnt-work-with-1-11-5-after-user-restarts-video/110940/6 "2024-06-03T16:03:29Z")

</div>

Thanks Vic… This works.
