Skip to content

Commit

Permalink
Merge pull request #17 from i-am-NaN/master
Browse files Browse the repository at this point in the history
Fixed switch camera function
  • Loading branch information
aldrinjenson authored Feb 12, 2023
2 parents 38288fa + b5bb5a4 commit eb0d9bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ class CameraModal extends Modal {


switchCameraButton.onclick = async () => {
cameraIndex = (cameraIndex + 1) % cameras.length;
this.videoStream = await getVideoStream();
cameraIndex = (cameraIndex + 1) % cameras.length;
this.videoStream = await navigator.mediaDevices.getUserMedia({video: { deviceId: cameras[cameraIndex].deviceId }, audio: true});
videoEl.srcObject = this.videoStream;
videoEl.play();
};

snapPhotoButton.onclick = () => {
Expand Down Expand Up @@ -187,4 +189,4 @@ class CameraModal extends Modal {
}
}

export default CameraModal
export default CameraModal

0 comments on commit eb0d9bb

Please sign in to comment.