From 57c09dbf7fc6e3f417a0eb53ce2be99a996240ef Mon Sep 17 00:00:00 2001 From: Konrad Bochnia Date: Wed, 18 Oct 2023 12:25:47 +0200 Subject: [PATCH] Add autoStreaming and preview options to screenshare (#51) * Fix screenshare state being lost on disconnect * Add `autoStreaming` and `preview` options to screenshare * Run prettier --- .../package-lock.json | 2 +- .../src/MainControls.tsx | 21 +++++++++++ src/reducer.tsx | 4 +-- src/useMedia/index.tsx | 28 +++++++++++++-- src/useMedia/types.ts | 2 ++ yarn.lock | 36 +++++++++---------- 6 files changed, 70 insertions(+), 23 deletions(-) diff --git a/examples/use-camera-and-microphone-example/package-lock.json b/examples/use-camera-and-microphone-example/package-lock.json index dbc8c36..cdebda6 100644 --- a/examples/use-camera-and-microphone-example/package-lock.json +++ b/examples/use-camera-and-microphone-example/package-lock.json @@ -40,7 +40,7 @@ "version": "0.1.3", "license": "Apache-2.0", "dependencies": { - "@jellyfish-dev/ts-client-sdk": "0.1.3", + "@jellyfish-dev/ts-client-sdk": "^0.2.0", "events": "3.3.0", "lodash.isequal": "4.5.0" }, diff --git a/examples/use-camera-and-microphone-example/src/MainControls.tsx b/examples/use-camera-and-microphone-example/src/MainControls.tsx index 936a2e4..c78f349 100644 --- a/examples/use-camera-and-microphone-example/src/MainControls.tsx +++ b/examples/use-camera-and-microphone-example/src/MainControls.tsx @@ -32,6 +32,9 @@ const videoPreviewAtom = atomWithStorage("videoPreview", un const audioAutoStreamingAtom = atomWithStorage("audioAutoStreaming", undefined); const audioPreviewAtom = atomWithStorage("audioPreviewAtom", undefined); +const screenshareAutoStreamingAtom = atomWithStorage("screenshareAutoStreaming", undefined); +const screensharePreviewAtom = atomWithStorage("screensharePreviewAtom", undefined); + const autostartAtom = atomWithStorage("autostart", false, undefined, { unstable_getOnInit: true }); export const MainControls = () => { @@ -47,6 +50,9 @@ export const MainControls = () => { const [audioAutoStreaming, setAudioAutoStreaming] = useAtom(audioAutoStreamingAtom); const [audioPreview, setAudioPreview] = useAtom(audioPreviewAtom); + const [screenshareAutoStreaming, setScreenshareAutoStreaming] = useAtom(screenshareAutoStreamingAtom); + const [screensharePreview, setScreensharePreview] = useAtom(screensharePreviewAtom); + const [autostart, setAutostart] = useAtom(autostartAtom); const { init } = useSetupMedia({ @@ -67,6 +73,8 @@ export const MainControls = () => { defaultTrackMetadata: DEFAULT_AUDIO_TRACK_METADATA, }, screenshare: { + autoStreaming: screenshareAutoStreaming, + preview: screensharePreview, trackConstraints: true, defaultTrackMetadata: DEFAULT_VIDEO_TRACK_METADATA, }, @@ -129,6 +137,19 @@ export const MainControls = () => { set={setAudioPreview} radioClass="radio-secondary" /> + + +