Skip to content

Commit 30725b7

Browse files
authored
Add quick setup instruction (#15)
## Description Add quick setup instruction and few small configuration changes
1 parent c190da2 commit 30725b7

File tree

8 files changed

+112
-16
lines changed

8 files changed

+112
-16
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,3 @@ dist
130130
.pnp.*
131131

132132
build
133-
134-
.vscode

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Docusarus",
11+
"skipFiles": ["<node_internals>/**"],
12+
"runtimeExecutable": "yarn",
13+
"args": ["start"]
14+
}
15+
]
16+
}

docusaurus.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,15 @@ const config: Config = {
100100
items: [
101101
{
102102
label: "React Native",
103-
to: "/guide/category/quick-setup---react-native",
103+
to: "/guide/category/react-native-integration",
104104
},
105105
{
106106
label: "React",
107-
to: "/guide/category/quick-setup---react",
107+
to: "/guide/category/react-integration",
108+
},
109+
{
110+
label: "Backend",
111+
to: "/guide/server",
108112
},
109113
],
110114
},
@@ -118,7 +122,7 @@ const config: Config = {
118122
},
119123
{
120124
label: "GitHub",
121-
href: "https://github.com/",
125+
href: "https://github.com/fishjam-cloud",
122126
},
123127
{
124128
label: "Software Mansion",

guide/index.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,85 @@
22
sidebar_position: 1
33
---
44

5-
# Setup
5+
# Quick Setup
6+
7+
Integrate Fishjam Cloud into your React Native application.
8+
9+
### Install package
10+
11+
```bash npm2yarn
12+
npm install @fishjam-cloud/react-native-client
13+
```
14+
15+
### Fetch participant token
16+
17+
Login to [Fishjam Cloud Dashboard](https://fishjam.io/app) and get your Room Manager url. Next, use it to fetch
18+
participant token for new room:
19+
20+
```ts
21+
const response = await fetch(
22+
`https://fishjam.io/api/v1/connect/*YOUR_ID*/room-manager/?room=ROOM_NAME&user=USER_NAME`,
23+
);
24+
25+
const { fishjamUrl, participantToken } = await response.json();
26+
```
27+
28+
### Join Room and start streaming
29+
30+
To start streaming, you have to prepare your camera and join room:
31+
32+
```ts
33+
import { joinRoom, useCamera } from "@fishjam-cloud/react-native-client";
34+
35+
36+
function StartStreamingButton({ roomName, userName }) {
37+
38+
const { prepareCamera } = useCamera();
39+
40+
41+
const startStreaming = useCallback(async () => {
42+
const response = await fetch(
43+
`https://fishjam.io/api/v1/connect/*YOUR_ID*/room-manager/?room=${roomName}&user=${userName}`
44+
);
45+
const { fishjamUrl, participantToken } = await response.json();
46+
47+
await prepareCamera({ enableCamera: true });
48+
49+
await joinRoom(fishjamUrl, participantToken);
50+
51+
});
52+
53+
return <Button onPress={startStreaming}>Start Streaming</Button>
54+
}
55+
```
56+
57+
### Show other participants
58+
59+
Fetching other participants of your room, can be done with `useParticipants` hook. And to display their video stream,
60+
you can use `VideoRendererView` component. Example code could look like this:
61+
62+
```ts
63+
import { useParticipants, VideoRendererView } from '@fishjam-cloud/react-native-client';
64+
65+
function Component() {
66+
const { participants } = useParticipants();
67+
68+
const videoTracks = participants.flatMap((participant) =>
69+
participant.tracks.filter(
70+
(track) => track.type === 'Video' && track.isActive,
71+
),
72+
);
73+
74+
return (
75+
<View>
76+
{videoTracks.map((track) => (
77+
<VideoRendererView key={track.id} trackId={track.id} videoLayout="FIT" />
78+
))}
79+
</View>
80+
);
81+
}
82+
```
83+
84+
### More
85+
86+
Checkout our [full documentation](/guide/category/react-native-integration) for more details.

guide/react-native/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"label": "Quick Setup - React Native",
2+
"label": "React Native Integration",
33
"position": 3,
44
"link": {
55
"type": "generated-index",

guide/react-native/start-streaming.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ enabled camera and microphone will start streaming to Room.
1616

1717
## Enable your camera
1818

19-
First, you have to enable your camera by calling `startCamera` method.
19+
First, you have to enable your camera by calling `prepareCamera` method.
2020
You can open show camera preview with `VideoPreviewView` component
2121

2222
```ts
2323
import { useCamera, VideoPreviewView } from '@fishjam-cloud/react-native-client';
2424

2525
function Component() {
26-
const { startCamera } = useCamera();
26+
const { prepareCamera } = useCamera();
2727

2828
useEffect(() => {
29-
startCamera({ enableCamera: true });
29+
prepareCamera({ enableCamera: true });
3030
}, [])
3131

3232
return <VideoPreviewView />

guide/react/_category_.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"label": "Quick Setup - React",
2+
"label": "React Integration",
33
"position": 4,
44
"link": {
55
"type": "generated-index",
6-
"description": "How to integrate Fishjam Cloud into your React mobile app."
6+
"description": "How to integrate Fishjam Cloud into your React web app."
77
}
88
}

src/pages/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ function HomepageHeader() {
1717
</Heading>
1818
<p className="hero__subtitle">{siteConfig.tagline}</p>
1919
<div className={styles.buttons}>
20-
<Link
21-
className="button button--secondary button--lg"
22-
to="/guide/react-native/installation"
23-
>
20+
<Link className="button button--secondary button--lg" to="/guide/">
2421
Setup React Native App - 5min ⏱️
2522
</Link>
2623
</div>

0 commit comments

Comments
 (0)