Merge pull request #3585 from element-hq/toger5/add-log-screenshare
Add log to screenshare
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
type Participant,
|
type Participant,
|
||||||
ParticipantEvent,
|
ParticipantEvent,
|
||||||
type LocalParticipant,
|
type LocalParticipant,
|
||||||
|
type ScreenShareCaptureOptions,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import { observeParticipantEvents } from "@livekit/components-core";
|
import { observeParticipantEvents } from "@livekit/components-core";
|
||||||
import {
|
import {
|
||||||
@@ -516,27 +517,37 @@ export const createLocalMembership$ = ({
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const toggleScreenSharing =
|
let toggleScreenSharing = null;
|
||||||
|
if (
|
||||||
"getDisplayMedia" in (navigator.mediaDevices ?? {}) &&
|
"getDisplayMedia" in (navigator.mediaDevices ?? {}) &&
|
||||||
!getUrlParams().hideScreensharing
|
!getUrlParams().hideScreensharing
|
||||||
? (): void =>
|
) {
|
||||||
// If a connection is ready, toggle screen sharing.
|
toggleScreenSharing = (): void => {
|
||||||
// We deliberately do nothing in the case of a null connection because
|
const screenshareSettings: ScreenShareCaptureOptions = {
|
||||||
// it looks nice for the call control buttons to all become available
|
audio: true,
|
||||||
// at once upon joining the call, rather than introducing a disabled
|
selfBrowserSurface: "include",
|
||||||
// state. The user can just click again.
|
surfaceSwitching: "include",
|
||||||
// We also allow screen sharing to be toggled even if the connection
|
systemAudio: "include",
|
||||||
// is still initializing or publishing tracks, because there's no
|
};
|
||||||
// technical reason to disallow this. LiveKit will publish if it can.
|
const targetScreenshareState = !sharingScreen$.value;
|
||||||
void localConnection$.value?.livekitRoom.localParticipant
|
logger.info(
|
||||||
.setScreenShareEnabled(!sharingScreen$.value, {
|
`toggleScreenSharing called. Switching ${
|
||||||
audio: true,
|
targetScreenshareState ? "On" : "Off"
|
||||||
selfBrowserSurface: "include",
|
}`,
|
||||||
surfaceSwitching: "include",
|
);
|
||||||
systemAudio: "include",
|
// If a connection is ready, toggle screen sharing.
|
||||||
})
|
// We deliberately do nothing in the case of a null connection because
|
||||||
.catch(logger.error)
|
// it looks nice for the call control buttons to all become available
|
||||||
: null;
|
// at once upon joining the call, rather than introducing a disabled
|
||||||
|
// state. The user can just click again.
|
||||||
|
// We also allow screen sharing to be toggled even if the connection
|
||||||
|
// is still initializing or publishing tracks, because there's no
|
||||||
|
// technical reason to disallow this. LiveKit will publish if it can.
|
||||||
|
localConnection$.value?.livekitRoom.localParticipant
|
||||||
|
.setScreenShareEnabled(targetScreenshareState, screenshareSettings)
|
||||||
|
.catch(logger.error);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const participant$ = scope.behavior(
|
const participant$ = scope.behavior(
|
||||||
localConnection$.pipe(map((c) => c?.livekitRoom.localParticipant ?? null)),
|
localConnection$.pipe(map((c) => c?.livekitRoom.localParticipant ?? null)),
|
||||||
|
|||||||
Reference in New Issue
Block a user