From 081905f51c83b5523c276a15702ae8f3cc684dea Mon Sep 17 00:00:00 2001 From: Barnabas Nsoh Date: Wed, 28 Aug 2024 16:15:11 +0000 Subject: [PATCH] move agent mode setup to handleStream function --- .../selfie/src/selfie-capture/SelfieCapture.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/web-components/components/selfie/src/selfie-capture/SelfieCapture.js b/packages/web-components/components/selfie/src/selfie-capture/SelfieCapture.js index 7ab38fbd..0bdfd4b4 100644 --- a/packages/web-components/components/selfie/src/selfie-capture/SelfieCapture.js +++ b/packages/web-components/components/selfie/src/selfie-capture/SelfieCapture.js @@ -644,6 +644,11 @@ class SelfieCaptureScreen extends HTMLElement { async _switchCamera() { this.facingMode = this.facingMode === 'user' ? 'environment' : 'user'; + if (this.facingMode === 'user') { + this.videoContainer.querySelector('video').classList.remove('agent-mode'); + } else { + this.videoContainer.querySelector('video').classList.add('agent-mode'); + } this.startImageCapture.disabled = true; this.switchCamera.disabled = true; SmartCamera.stopMedia(); @@ -775,7 +780,7 @@ class SelfieCaptureScreen extends HTMLElement { } else { video.src = window.URL.createObjectURL(stream); } - + this.setupAgentMode(); video.onloadedmetadata = () => { video.play(); }; @@ -828,8 +833,6 @@ class SelfieCaptureScreen extends HTMLElement { } else if (this.hasAttribute('data-camera-ready')) { getPermissions(this, { facingMode: this.facingMode }); } - - this.setupAgentMode(); } disconnectedCallback() { @@ -863,7 +866,6 @@ class SelfieCaptureScreen extends HTMLElement { if (supportAgentMode || this.hasAttribute('show-agent-mode-for-tests')) { this.switchCamera.hidden = false; - this.shadowRoot.querySelector('video').classList.add('agent-mode'); } else { this.switchCamera.hidden = true; }