Skip to content

Commit eddd0ca

Browse files
authored
Add throwOnFail to groupCall.setScreensharingEnabled (#2787)
* Add throwOnFail to groupCall.setScreensharingEnabled For element-hq/element-call#652 * Update mediaHandler.ts
1 parent 5a07873 commit eddd0ca

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/webrtc/groupCall.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ export class GroupCall extends TypedEventEmitter<
600600

601601
return true;
602602
} catch (error) {
603+
if (opts.throwOnFail) throw error;
603604
logger.error("Enabling screensharing error", error);
604605
this.emit(GroupCallEvent.Error,
605606
new GroupCallError(GroupCallErrorCode.NoUserMedia, "Failed to get screen-sharing stream: ", error),

src/webrtc/mediaHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export type MediaHandlerEventHandlerMap = {
3333
export interface IScreensharingOpts {
3434
desktopCapturerSourceId?: string;
3535
audio?: boolean;
36+
// For electron screen capture, there are very few options for detecting electron
37+
// apart from inspecting the user agent or just trying getDisplayMedia() and
38+
// catching the failure, so we do the latter - this flag tells the function to just
39+
// throw an error so we can catch it in this case, rather than logging and emitting.
40+
throwOnFail?: boolean;
3641
}
3742

3843
export class MediaHandler extends TypedEventEmitter<

0 commit comments

Comments
 (0)