Company
Date Published
Author
Phil Nash
Word count
1780
Language
English
Hacker News points
None

Summary

You can choose between two cameras, select one based on its ID, and switch between them. The mediaDevices API allows you to access the camera's video stream and enumerate all available devices for both audio and video input. You can also use the facingMode constraint to select a front-facing or rear-facing camera on mobile devices. To switch between cameras, retain a reference to the current stream and stop it when switching to another one. The mediaDevices API provides a way to influence which camera is selected by using constraints such as facingMode or deviceId.