Skip to content

Commit 7949b3a

Browse files
committed
feat: option to disable video initially
This can be used to implement two buttons in the host apps: - Start audio call - Start video call
1 parent b5b41ee commit 7949b3a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Commands are given to the app via URL hash:
2121

2222
**IMPORTANT:** `PAYLOAD` **must** be base64 encoded (NOTE: you might still need to URL-encode the base64 string to be a valid URL hash) before passing it to the app in the URL hash.
2323

24+
In order to start the app in audio-only mode initially,
25+
provide `noOutgoingVideoInitially` in the query (search) string
26+
of the initial URL, e.g. `/index.html?noOutgoingVideoInitially#startCall`.
27+
2428
## Contributing
2529

2630
### Installing Dependencies

src/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@ export default function App() {
2020
const outVidRef = useRef<HTMLVideoElement | null>(null);
2121
const incVidRef = useRef<HTMLVideoElement | null>(null);
2222

23+
const enableVideoInitiallyRef = useRef<boolean | null>(null);
24+
if (enableVideoInitiallyRef.current == null) {
25+
enableVideoInitiallyRef.current = !location.search.includes(
26+
"noOutgoingVideoInitially",
27+
);
28+
}
29+
const enableVideoInitially = enableVideoInitiallyRef.current;
30+
2331
const [isOutAudioEnabled, setIsOutAudioEnabled] = useState(true);
24-
const [isOutVideoEnabled, setIsOutVideoEnabled] = useState(true);
32+
const [isOutVideoEnabled, setIsOutVideoEnabled] =
33+
useState(enableVideoInitially);
2534
const isOutAudioEnabledRef = useRef(isOutAudioEnabled);
2635
isOutAudioEnabledRef.current = isOutAudioEnabled;
2736
const isOutVideoEnabledRef = useRef(isOutVideoEnabled);

0 commit comments

Comments
 (0)