# How to switch cameras when previewing locally?

**URL:** <https://devforum.zoom.us/t/how-to-switch-cameras-when-previewing-locally/64049>\
**Category:** Web\
**Created:** [February 9, 2022, 7:44am UTC](https://devforum.zoom.us/t/how-to-switch-cameras-when-previewing-locally/64049 "2022-02-09T07:44:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lixiaoliangbj](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lixiaoliangbj/32/34981_2.png) [@lixiaoliangbj](https://devforum.zoom.us/u/lixiaoliangbj)\
**Post date:** [February 9, 2022, 7:44am UTC](https://devforum.zoom.us/t/how-to-switch-cameras-when-previewing-locally/64049/1 "2022-02-09T07:44:45Z")

</div>

**Description**  
ZoomVideo.createLocalVideoTrack(deviceId?: string) It doesn’t work to set deviceId

**Browser Console Error**  
no

**Which Web Video SDK version?**  
@zoom1234/videosdk 1.1.7

**Video SDK Code Snippets**  
const devices = await ZoomVideo.getDevices();  
const videoDevices = devices.filter(function (device) {  
return device.kind === ‘videoinput’;  
});  
// select external camera,my selected camera is Logitech C505e  
const selectedCamera = videoDevices[2];  
const selectedCameraId = selectedCamera.deviceId;  
const localVideoTrack = ZoomVideo.createLocalVideoTrack(selectedCameraId);  
console.log(‘selectedCamera:’, selectedCamera); // selectedCamera.label is ‘C505e HD Webcam #3 (046d:08e4)’  
await localVideoTrack.start(document.getElementById(“js-preview-video”));  
console.log(‘localVideoTrack:’, localVideoTrack);  
console.log(‘video tracks:’, localVideoTrack.videoStream.getVideoTracks()); // MediaStreamTrack.label is ‘FaceTime高清摄像头（内建） (05ac:8514)’

**Device (please complete the following information):**

- Device: [Macbook Pro]
- OS: [macOS 11.3.1]
- Browser: [Chrome]
- Browser Version [95.0.4638.54 (Official Build) (x86\_64)]

---

<div class="post-metadata">

**Author:** ![lixiaoliangbj](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lixiaoliangbj/32/34981_2.png) [@lixiaoliangbj](https://devforum.zoom.us/u/lixiaoliangbj)\
**Post date:** [February 21, 2022, 11:23am UTC](https://devforum.zoom.us/t/how-to-switch-cameras-when-previewing-locally/64049/2 "2022-02-21T11:23:05Z")

</div>

![WX20220209-153049](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/7/a/7a2f1a7bb407d46f01a9f885855d96a12c140793.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [March 23, 2022, 9:23pm UTC](https://devforum.zoom.us/t/how-to-switch-cameras-when-previewing-locally/64049/3 "2022-03-23T21:23:14Z")

</div>

Closed on March 23, 2022, 9:23pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
