Skip to content

Commit

Permalink
fix facing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
binarykitchen committed Nov 23, 2024
1 parent 2971360 commit ff75e75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface VideomailClientOptions {

width?: number | undefined;
height?: number | undefined;
facingMode: string;
facingMode: ConstrainDOMString;
facingModeButton: boolean;

stretch: boolean;
Expand Down
21 changes: 12 additions & 9 deletions src/wrappers/visuals/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ class Recorder extends Despot {

private recordingBuffer?: Buffer | undefined;

private facingMode: ConstrainDOMString;

constructor(visuals: Visuals, replay: Replay, options: VideomailClientOptions) {
super("Recorder", options);

this.visuals = visuals;
this.replay = replay;
this.facingMode = options.video.facingMode;
}

private writeStream(buffer: Buffer, opts?: WriteStreamParams) {
Expand Down Expand Up @@ -1288,22 +1291,22 @@ class Recorder extends Despot {
}
}

private switchFacingMode(facingMode?: ConstrainDOMString) {
private switchFacingMode() {
if (!getBrowser(this.options).isMobile()) {
return;
}

let newFacingMode: ConstrainDOMString | undefined;

if (facingMode === "user") {
newFacingMode = "environment";
} else if (facingMode === "environment") {
newFacingMode = "user";
if (this.facingMode === "user") {
this.facingMode = "environment";
} else if (this.facingMode === "environment") {
this.facingMode = "user";
} else {
this.options.logger.debug(`Recorder: unsupported facing mode ${facingMode}`);
this.options.logger.warn(
`Recorder: unsupported facing mode ${pretty(this.facingMode)}`,
);
}

this.loadGenuineUserMedia({ switchingFacingMode: newFacingMode });
this.loadGenuineUserMedia({ switchingFacingMode: this.facingMode });
}

private initEvents() {
Expand Down

0 comments on commit ff75e75

Please sign in to comment.