Skip to content

Commit

Permalink
feat: Persist camera facing mode using localStorage
Browse files Browse the repository at this point in the history
ViaAnthroposBenevolentia committed Jan 30, 2025

Verified

This commit was signed with the committer’s verified signature.
erikmd Erik Martin-Dorel
1 parent 3d90dcc commit 85b2f64
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion js/camera/camera.js
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ export class CameraManager {

// Toggle facingMode
this.config.facingMode = this.config.facingMode === 'user' ? 'environment' : 'user';
localStorage.setItem('facingMode', this.config.facingMode);

// Stop current stream
if (this.stream) {
@@ -88,7 +89,7 @@ export class CameraManager {
} catch (error) {
console.error('Failed to switch camera:', error);
// Revert to previous facing mode on error
this.config.facingMode = this.config.facingMode === 'user' ? 'environment' : 'user';
this.config.facingMode = localStorage.getItem('facingMode') || 'environment';
}
}

3 changes: 2 additions & 1 deletion js/main/agent.js
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ export class GeminiAgent{
// Initialize camera
this.cameraManager = new CameraManager({
width: this.resizeWidth,
quality: this.quality
quality: this.quality,
facingMode: localStorage.getItem('facingMode') || 'environment'
});
this.cameraInterval = null;

0 comments on commit 85b2f64

Please sign in to comment.