-
Notifications
You must be signed in to change notification settings - Fork 84
/
minimal.tsx
45 lines (39 loc) · 1.34 KB
/
minimal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use client';
import { LiveKitRoom, useToken, VideoConference, setLogLevel } from '@livekit/components-react';
import type { NextPage } from 'next';
import { generateRandomUserId } from '../lib/helper';
import { useMemo } from 'react';
const MinimalExample: NextPage = () => {
const params = typeof window !== 'undefined' ? new URLSearchParams(location.search) : null;
const roomName = params?.get('room') ?? 'test-room';
setLogLevel('info', { liveKitClientLogLevel: 'warn' });
const tokenOptions = useMemo(() => {
const userId = params?.get('user') ?? generateRandomUserId();
return {
userInfo: {
identity: userId,
name: userId,
},
};
}, []);
const token = useToken(process.env.NEXT_PUBLIC_LK_TOKEN_ENDPOINT, roomName, tokenOptions);
return (
<div data-lk-theme="default" style={{ height: '100vh' }}>
<LiveKitRoom
video={false}
audio={false}
token={token}
serverUrl={process.env.NEXT_PUBLIC_LK_SERVER_URL}
onMediaDeviceFailure={(e) => {
console.error(e);
alert(
'Error acquiring camera or microphone permissions. Please make sure you grant the necessary permissions in your browser and reload the tab',
);
}}
>
<VideoConference />
</LiveKitRoom>
</div>
);
};
export default MinimalExample;