Skip to content

Commit

Permalink
move agent mode setup to handleStream function
Browse files Browse the repository at this point in the history
  • Loading branch information
ayinloya committed Aug 28, 2024
1 parent 42b870b commit 081905f
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -775,7 +780,7 @@ class SelfieCaptureScreen extends HTMLElement {
} else {
video.src = window.URL.createObjectURL(stream);
}

this.setupAgentMode();
video.onloadedmetadata = () => {
video.play();
};
Expand Down Expand Up @@ -828,8 +833,6 @@ class SelfieCaptureScreen extends HTMLElement {
} else if (this.hasAttribute('data-camera-ready')) {
getPermissions(this, { facingMode: this.facingMode });
}

this.setupAgentMode();
}

disconnectedCallback() {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 081905f

Please sign in to comment.