From 20a6f3300a18332a3180a4bb3f6dbc9684967c13 Mon Sep 17 00:00:00 2001 From: i-am-NaN <83778820+i-am-NaN@users.noreply.github.com> Date: Sat, 11 Feb 2023 13:02:18 -0800 Subject: [PATCH 1/3] Update Modal.ts --- src/Modal.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Modal.ts b/src/Modal.ts index d6a7b32..a599a15 100644 --- a/src/Modal.ts +++ b/src/Modal.ts @@ -128,8 +128,11 @@ class CameraModal extends Modal { switchCameraButton.onclick = async () => { - cameraIndex = (cameraIndex + 1) % cameras.length; - this.videoStream = await getVideoStream(); + cameraIndex = (cameraIndex + 1) % cameras.length; + this.videoStream = null; + this.videoStream = yield navigator.mediaDevices.getUserMedia({video: { deviceId: cameras[cameraIndex].deviceId }, audio: true}); + videoEl.srcObject = this.videoStream; + videoEl.play(); }; snapPhotoButton.onclick = () => { @@ -187,4 +190,4 @@ class CameraModal extends Modal { } } -export default CameraModal \ No newline at end of file +export default CameraModal From 6dfea4d4bff1cbfd7d22c3ccd00ce470aa872dae Mon Sep 17 00:00:00 2001 From: i-am-NaN <83778820+i-am-NaN@users.noreply.github.com> Date: Sat, 11 Feb 2023 13:11:43 -0800 Subject: [PATCH 2/3] Update Modal.ts --- src/Modal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Modal.ts b/src/Modal.ts index a599a15..6cf01c8 100644 --- a/src/Modal.ts +++ b/src/Modal.ts @@ -130,7 +130,7 @@ class CameraModal extends Modal { switchCameraButton.onclick = async () => { cameraIndex = (cameraIndex + 1) % cameras.length; this.videoStream = null; - this.videoStream = yield navigator.mediaDevices.getUserMedia({video: { deviceId: cameras[cameraIndex].deviceId }, audio: true}); + this.videoStream = await navigator.mediaDevices.getUserMedia({video: { deviceId: cameras[cameraIndex].deviceId }, audio: true}); videoEl.srcObject = this.videoStream; videoEl.play(); }; From b5bb5a4c7574e3b790ce806aa1e74373c7d0120d Mon Sep 17 00:00:00 2001 From: i-am-NaN <83778820+i-am-NaN@users.noreply.github.com> Date: Sun, 12 Feb 2023 13:12:47 -0800 Subject: [PATCH 3/3] Update Modal.ts --- src/Modal.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Modal.ts b/src/Modal.ts index 6cf01c8..6b81bb3 100644 --- a/src/Modal.ts +++ b/src/Modal.ts @@ -129,7 +129,6 @@ class CameraModal extends Modal { switchCameraButton.onclick = async () => { cameraIndex = (cameraIndex + 1) % cameras.length; - this.videoStream = null; this.videoStream = await navigator.mediaDevices.getUserMedia({video: { deviceId: cameras[cameraIndex].deviceId }, audio: true}); videoEl.srcObject = this.videoStream; videoEl.play();