Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
www: add audio and video toggles to device request screen
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgang42 committed Dec 5, 2022
1 parent 64355cd commit 314e3bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion www/atoms/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const localState = atom<Local>({
const setAudioVideoEnabled =
(audioEnabled: boolean, videoEnabled: boolean) =>
(local: Local): Local => {
assert(local.status === "connecting" || local.status === "connected");
assert(local.status === "requestingDevices" || local.status === "connecting" || local.status === "connected");
return { ...local, audioEnabled, videoEnabled };
};

Expand Down
6 changes: 3 additions & 3 deletions www/components/room/controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function TrackControl(track: "video" | "audio") {
const peers = useRecoilValue(peersState);
const stream = mapGet(streamMap, LocalStreamKey);

assert(local.status === "connecting" || local.status === "connected");
assert(local.status === "requestingDevices" || local.status === "connecting" || local.status === "connected");

const { audioEnabled, videoEnabled } = getVideoAudioEnabled(stream);
const enabled = track === "audio" ? audioEnabled : videoEnabled;
Expand Down Expand Up @@ -97,11 +97,11 @@ function TrackControl(track: "video" | "audio") {
);
}

function AudioControl() {
export function AudioControl() {
return TrackControl("audio");
}

function VideoControl() {
export function VideoControl() {
return TrackControl("video");
}

Expand Down
3 changes: 3 additions & 0 deletions www/components/room/request-devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
stopStream,
} from "../../lib/mesh/stream";
import Select from "../lib/select";
import {AudioControl, VideoControl} from "./controls";
import LocalPreview from "./local-preview";
import PreForm from "./pre-form";

Expand Down Expand Up @@ -108,6 +109,7 @@ export default function RequestDevices() {
}
setValue={handleAudioChange}
/>
<AudioControl/>
<Select
id="video-select"
fallback="No cameras found"
Expand All @@ -131,6 +133,7 @@ export default function RequestDevices() {
}
setValue={handleVideoChange}
/>
<VideoControl/>
</>
}
handleSubmit={joinRoom}
Expand Down

0 comments on commit 314e3bb

Please sign in to comment.