@fishjam-cloud/react-native-client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -0
- package/android/build.gradle +6 -6
- package/app.plugin.js +1 -1
- package/build/RNFishjamClientModule.d.ts +7 -5
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/common/client.d.ts +8 -1
- package/build/common/client.d.ts.map +1 -1
- package/build/common/client.js +9 -2
- package/build/common/client.js.map +1 -1
- package/build/components/VideoPreviewView.d.ts +3 -3
- package/build/components/VideoPreviewView.d.ts.map +1 -1
- package/build/components/VideoPreviewView.js +1 -1
- package/build/components/VideoPreviewView.js.map +1 -1
- package/build/hooks/useAudioSettings.d.ts.map +1 -1
- package/build/hooks/useAudioSettings.js +4 -5
- package/build/hooks/useAudioSettings.js.map +1 -1
- package/build/hooks/useBandwidthEstimation.d.ts +0 -3
- package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
- package/build/hooks/useBandwidthEstimation.js +3 -6
- package/build/hooks/useBandwidthEstimation.js.map +1 -1
- package/build/hooks/useCamera.d.ts +12 -21
- package/build/hooks/useCamera.d.ts.map +1 -1
- package/build/hooks/useCamera.js +52 -52
- package/build/hooks/useCamera.js.map +1 -1
- package/build/{common/eventEmitter.d.ts → hooks/useFishjamEvent.d.ts} +2 -3
- package/build/hooks/useFishjamEvent.d.ts.map +1 -0
- package/build/{common/eventEmitter.js → hooks/useFishjamEvent.js} +11 -2
- package/build/hooks/useFishjamEvent.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts.map +1 -1
- package/build/hooks/useMicrophone.js +3 -7
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/useParticipants.d.ts +0 -3
- package/build/hooks/useParticipants.d.ts.map +1 -1
- package/build/hooks/useParticipants.js +6 -6
- package/build/hooks/useParticipants.js.map +1 -1
- package/build/hooks/useReconnection.d.ts.map +1 -1
- package/build/hooks/useReconnection.js +8 -18
- package/build/hooks/useReconnection.js.map +1 -1
- package/build/hooks/useScreencast.d.ts.map +1 -1
- package/build/hooks/useScreencast.js +3 -7
- package/build/hooks/useScreencast.js.map +1 -1
- package/build/index.d.ts +4 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/types.d.ts +25 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js +10 -1
- package/build/types.js.map +1 -1
- package/build/utils/foregroundService.d.ts +30 -0
- package/build/utils/foregroundService.d.ts.map +1 -0
- package/build/utils/foregroundService.js +41 -0
- package/build/utils/foregroundService.js.map +1 -0
- package/ios/RNFishjamClient.swift +37 -30
- package/ios/RNFishjamClientModule.swift +11 -7
- package/package.json +19 -19
- package/.eslintignore +0 -7
- package/.eslintrc +0 -6
- package/.prettierrc +0 -9
- package/.watchmanconfig +0 -1
- package/android/.editorconfig +0 -9
- package/android/src/main/AndroidManifest.xml +0 -2
- package/android/src/main/java/org/membraneframework/reactnative/AudioDeviceKind.kt +0 -34
- package/android/src/main/java/org/membraneframework/reactnative/AudioSwitchManager.kt +0 -61
- package/android/src/main/java/org/membraneframework/reactnative/EmitableEvents.kt +0 -14
- package/android/src/main/java/org/membraneframework/reactnative/Errors.kt +0 -31
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClient.kt +0 -866
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClientModule.kt +0 -294
- package/android/src/main/java/org/membraneframework/reactnative/Utils.kt +0 -11
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewView.kt +0 -40
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewViewModule.kt +0 -17
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererView.kt +0 -58
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererViewModule.kt +0 -25
- package/android/src/main/java/org/membraneframework/reactnative/VideoView.kt +0 -77
- package/babel.config.js +0 -2
- package/build/common/eventEmitter.d.ts.map +0 -1
- package/build/common/eventEmitter.js.map +0 -1
- package/expo-module.config.json +0 -17
- package/ios/RNFishjamClient.podspec +0 -30
- package/ios/swift-format-config.json +0 -56
- package/plugin/broadcastExtensionFiles/Info.plist +0 -27
- package/plugin/broadcastExtensionFiles/MembraneBroadcastSampleHandler.swift +0 -50
- package/plugin/broadcastExtensionFiles/MembraneScreenBroadcastExtension.entitlements +0 -10
- package/plugin/src/withMembrane.ts +0 -310
- package/plugin/tsconfig.json +0 -9
- package/scripts/lint.sh +0 -18
- package/scripts/lint_check.sh +0 -14
- package/src/RNFishjamClientModule.ts +0 -73
- package/src/__tests__/index.test.tsx +0 -199
- package/src/common/client.ts +0 -33
- package/src/common/eventEmitter.ts +0 -21
- package/src/common/metadata.ts +0 -12
- package/src/common/webRTC.ts +0 -31
- package/src/components/VideoPreviewView.tsx +0 -33
- package/src/components/VideoRendererView.tsx +0 -31
- package/src/hooks/useAudioSettings.ts +0 -115
- package/src/hooks/useBandwidthEstimation.ts +0 -24
- package/src/hooks/useCamera.ts +0 -270
- package/src/hooks/useMicrophone.ts +0 -38
- package/src/hooks/useParticipants.ts +0 -118
- package/src/hooks/useReconnection.ts +0 -41
- package/src/hooks/useScreencast.ts +0 -146
- package/src/index.tsx +0 -63
- package/src/protos/fishjam/peer_notifications.ts +0 -299
- package/src/stats/types.ts +0 -56
- package/src/stats/useRTCStatistics.ts +0 -97
- package/src/types.ts +0 -49
- package/tsconfig.json +0 -9
- package/typedoc.json +0 -5
package/README.md
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# Fishjam Cloud React Native client
|
|
2
|
+
|
|
3
|
+
`@fishjam-cloud/react-native-client` is a React Native wrapper for
|
|
4
|
+
[android-client](https://github.com/fishjam-dev/android-client-sdk) and
|
|
5
|
+
[ios-client](https://github.com/fishjam-dev/ios-client-sdk). It allows you to
|
|
6
|
+
quickly and easily create a mobile client app in React Native for a
|
|
7
|
+
[Fishjam](https://github.com/fishjam-dev/fishjam) server.
|
|
8
|
+
|
|
9
|
+
# Documentation
|
|
10
|
+
|
|
11
|
+
API documentation is available
|
|
12
|
+
[here](https://fishjam-cloud.github.io/mobile-client-sdk/modules/_fishjam_cloud_react_native_client.html)
|
|
13
|
+
|
|
14
|
+
# Installation
|
|
15
|
+
|
|
16
|
+
Firstly install `react-native-client` with `yarn` or `npm`
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
yarn add @fishjam-cloud/react-native-client
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
or
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
npm install @fishjam-cloud/react-native-client
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Expo plugin
|
|
29
|
+
|
|
30
|
+
If you're using development builds with `eas build` or bare workflow you can try
|
|
31
|
+
using expo plugin to do the configuration below for you. Simply run:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
expo install @fishjam-cloud/react-native-client
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Add plugin to your `app.json` if it's not already added:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"expo": {
|
|
42
|
+
"name": "example",
|
|
43
|
+
...
|
|
44
|
+
"plugins": [
|
|
45
|
+
"@fishjam-cloud/react-native-client"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If you want to use screensharing feature, enable the following flag:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"expo": {
|
|
56
|
+
"name": "example",
|
|
57
|
+
...
|
|
58
|
+
"plugins": [
|
|
59
|
+
[
|
|
60
|
+
"@fishjam-cloud/react-native-client",
|
|
61
|
+
{
|
|
62
|
+
"setUpScreensharing": true,
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
On bare workflow run `expo prebuild` to configure the app, then run
|
|
71
|
+
`pod install`. On development build `eas build` should take care of it.
|
|
72
|
+
|
|
73
|
+
### Android
|
|
74
|
+
|
|
75
|
+
1. Add camera and microphone permissions to your `AndroidManifest.xml`.
|
|
76
|
+
2. Rebuild the app. That's it!
|
|
77
|
+
|
|
78
|
+
### iOS
|
|
79
|
+
|
|
80
|
+
On iOS installation is a bit more complicated, because you need to setup a
|
|
81
|
+
screen broadcast app extension for screensharing.
|
|
82
|
+
|
|
83
|
+
1. Add camera and microphone permissions to your main `Info.plist`.
|
|
84
|
+
```xml
|
|
85
|
+
<key>NSCameraUsageDescription</key>
|
|
86
|
+
<string>Allow $(PRODUCT_NAME) to use the camera</string>
|
|
87
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
88
|
+
<string>Allow $(PRODUCT_NAME) to use the microphone</string>
|
|
89
|
+
```
|
|
90
|
+
2. We recommend adding `audio` background mode in `Info.plist` so that the app
|
|
91
|
+
doesn't disconnect when it's in background:
|
|
92
|
+
|
|
93
|
+
```xml
|
|
94
|
+
<key>UIBackgroundModes</key>
|
|
95
|
+
<array>
|
|
96
|
+
<string>audio</string>
|
|
97
|
+
</array>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
2. Open your `<your-project>.xcworkspace` in Xcode
|
|
101
|
+
3. Create new Broadcast Upload Extension. Select File → New → Target... →
|
|
102
|
+
Broadcast Upload Extension → Next. Choose the name for the new target, select
|
|
103
|
+
Swift language and deselect "Include UI Extension".
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
Press Finish. In the next alert xcode will ask you if you want to activate
|
|
108
|
+
the new scheme - press Cancel.
|
|
109
|
+
|
|
110
|
+
4. Configure app group. Go to "Signing & Capabilities" tab, click "+ Capability"
|
|
111
|
+
button in upper left corner and select "App Groups".
|
|
112
|
+
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
Then in the "App Groups" add a new group or select existing. Usually group
|
|
116
|
+
name has format `group.<your-bundle-identifier>`. Verify that both app and
|
|
117
|
+
extension targets have app group and dev team set correctly.
|
|
118
|
+
|
|
119
|
+
5. A new folder with app extension should appear on the left with contents like
|
|
120
|
+
this:
|
|
121
|
+
|
|
122
|
+

|
|
123
|
+
|
|
124
|
+
Replace `SampleHandler.swift` with `MembraneBroadcastSampleHandler.swift` and
|
|
125
|
+
this code:
|
|
126
|
+
|
|
127
|
+
```swift
|
|
128
|
+
import Foundation
|
|
129
|
+
import MembraneRTC
|
|
130
|
+
import os.log
|
|
131
|
+
import ReplayKit
|
|
132
|
+
import WebRTC
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
/// App Group used by the extension to exchange buffers with the target application
|
|
136
|
+
let appGroup = "{{GROUP_IDENTIFIER}}"
|
|
137
|
+
|
|
138
|
+
let logger = OSLog(subsystem: "{{BUNDLE_IDENTIFIER}}.MembraneBroadcastSampleHandler", category: "Broadcaster")
|
|
139
|
+
|
|
140
|
+
/// An example `SampleHandler` utilizing `BroadcastSampleSource` from `MembraneRTC` sending broadcast samples and necessary notification enabling device's screencast.
|
|
141
|
+
class MembraneBroadcastSampleHandler: RPBroadcastSampleHandler {
|
|
142
|
+
let broadcastSource = BroadcastSampleSource(appGroup: appGroup)
|
|
143
|
+
var started: Bool = false
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
override func broadcastStarted(withSetupInfo _: [String: NSObject]?) {
|
|
147
|
+
started = broadcastSource.connect()
|
|
148
|
+
|
|
149
|
+
guard started else {
|
|
150
|
+
os_log("failed to connect with ipc server", log: logger, type: .debug)
|
|
151
|
+
|
|
152
|
+
super.finishBroadcastWithError(NSError(domain: "", code: 0, userInfo: nil))
|
|
153
|
+
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
broadcastSource.started()
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
override func broadcastPaused() {
|
|
161
|
+
broadcastSource.paused()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
override func broadcastResumed() {
|
|
165
|
+
broadcastSource.resumed()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
override func broadcastFinished() {
|
|
169
|
+
broadcastSource.finished()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
|
|
173
|
+
guard started else {
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
broadcastSource.processFrame(sampleBuffer: sampleBuffer, ofType: sampleBufferType)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Replace `{{GROUP_IDENTIFIER}}` and `{{BUNDLE_IDENTIFIER}}` with your group
|
|
183
|
+
identifier and bundle identifier respectively.
|
|
184
|
+
|
|
185
|
+
6. In project's Podfile add the following code:
|
|
186
|
+
```rb
|
|
187
|
+
target 'MembraneScreenBroadcastExtension' do
|
|
188
|
+
pod 'MembraneRTC/Broadcast'
|
|
189
|
+
end
|
|
190
|
+
```
|
|
191
|
+
> This new dependency should be added outside of your application target.
|
|
192
|
+
> Example
|
|
193
|
+
>
|
|
194
|
+
> ```rb
|
|
195
|
+
> target 'ReactNativeMembraneExample' do
|
|
196
|
+
> ...
|
|
197
|
+
> end
|
|
198
|
+
>
|
|
199
|
+
> target 'MembraneScreenBroadcastExtension' do
|
|
200
|
+
> pod 'MembraneRTC/Broadcast'
|
|
201
|
+
> end
|
|
202
|
+
> ```
|
|
203
|
+
7. Run `pod install` in your `ios/` directory
|
|
204
|
+
8. Add the following constants in your Info.plist:
|
|
205
|
+
```xml
|
|
206
|
+
<key>AppGroupName</key>
|
|
207
|
+
<string>{{GROUP_IDENTIFIER}}</string>
|
|
208
|
+
<key>ScreencastExtensionBundleId</key>
|
|
209
|
+
<string>{{BUNDLE_IDENTIFIER}}.MembraneBroadcastSampleHandler</string>
|
|
210
|
+
```
|
|
211
|
+
Replace `{{GROUP_IDENTIFIER}}` and `{{BUNDLE_IDENTIFIER}}` with your group
|
|
212
|
+
identifier and bundle identifier respectively.
|
|
213
|
+
9. Rebuild the app and enjoy!
|
|
214
|
+
|
|
215
|
+
# Example
|
|
216
|
+
|
|
217
|
+
We strongly recommend checking out our example app that implements a basic video
|
|
218
|
+
room client. To run the app:
|
|
219
|
+
|
|
220
|
+
1. Go to Membrane's server demo repo: https://fishjam.io/app/login Follow
|
|
221
|
+
instructions there to setup and run demo server.
|
|
222
|
+
2. Clone the repo
|
|
223
|
+
3. ```
|
|
224
|
+
cd `examples/fishjam-chat`
|
|
225
|
+
yarn
|
|
226
|
+
```
|
|
227
|
+
4. In App.ts replace server url with your server's url.
|
|
228
|
+
5. `yarn run android` or `yarn run ios` or run project from Android Studio /
|
|
229
|
+
Xcode just like every RN project. Note that simulators won't work, you have
|
|
230
|
+
to test on real device for camera and screensharing to run.
|
|
231
|
+
|
|
232
|
+
# Usage
|
|
233
|
+
|
|
234
|
+
> [!CAUTION]
|
|
235
|
+
> This part of documentation is out of date. It will be updated soon.
|
|
236
|
+
|
|
237
|
+
Connect to the server and join the room using the `connect` function. Use user
|
|
238
|
+
metadata to pass things like usernames etc. to the server.
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
const startServerConnection = () => {
|
|
242
|
+
try {
|
|
243
|
+
await connect('http://server_address:5002', 'peer_token', {
|
|
244
|
+
displayName: 'Annie',
|
|
245
|
+
});
|
|
246
|
+
} catch (e) {
|
|
247
|
+
console.log('error!');
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Remember to gracefully disconnect from the server using the `leaveRoom()`
|
|
253
|
+
function:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
const stopServerConnection = () => {
|
|
257
|
+
await leaveRoom();
|
|
258
|
+
};
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Start the device's camera and microphone using `useCamera()` and
|
|
262
|
+
`useMicrophone()` hooks. Use `videoTrackMetadata` and `audioTrackMetadata`
|
|
263
|
+
options to send metadata about the tracks (for example whether it's a camera or
|
|
264
|
+
screencast track).
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const { startCamera } = useCamera();
|
|
268
|
+
const { startMicrophone } = useMicrophone();
|
|
269
|
+
|
|
270
|
+
await startCamera({
|
|
271
|
+
quality: VideoQuality.HD_169,
|
|
272
|
+
videoTrackMetadata: { active: true, type: 'camera' },
|
|
273
|
+
});
|
|
274
|
+
await startMicrophone({ audioTrackMetadata: { active: true, type: 'audio' } });
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
For more options and functions to control the camera and microphone see the API
|
|
278
|
+
documentation.
|
|
279
|
+
|
|
280
|
+
If you have the connection set up, then use `useParticipants()` hook to track
|
|
281
|
+
the other participants in the room. One of the participants will be a local
|
|
282
|
+
participant (the one who's using the device). When participants is added or
|
|
283
|
+
removed because an user joins or leaves the room, the participants will be
|
|
284
|
+
updated automatically. Simply call the hook like this:
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
const participants = useParticipants();
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
When you have the participants all that's left is to render their video tracks.
|
|
291
|
+
Use `<VideoRendererView />` component like this:
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
{
|
|
295
|
+
endpoint.videoTracks.map((track) => (
|
|
296
|
+
<VideoRendererView trackId={track.id} />
|
|
297
|
+
));
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
You can style the views to lay out them however you'd like, basic animations
|
|
302
|
+
should work too.
|
|
303
|
+
|
|
304
|
+
There are also some simple hooks for toggling camera, microphone and
|
|
305
|
+
screensharing. Use them like this:
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
const { isCameraOn, toggleCamera } = useCameraState();
|
|
309
|
+
const { isMicrophoneOn, toggleMicrophone } = useMicrophoneState();
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
For screencasting use `useScreencast()` hook. The local endpoint will have a new
|
|
313
|
+
video track which you can render just like an ordinary video track with
|
|
314
|
+
<VideoRendererView />:
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
const { isScreencastOn, toggleScreencast } = useScreencast();
|
|
318
|
+
...
|
|
319
|
+
toggleScreencast({screencastMetadata: { displayName: "Annie's desktop" }});
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Use track metadata to differentiate between video and screencast tracks.
|
|
323
|
+
|
|
324
|
+
### Android foreground service
|
|
325
|
+
|
|
326
|
+
In order for the call to continue running when app is in background, you need to
|
|
327
|
+
set up and start a foreground service. You can use a 3rd party library for this,
|
|
328
|
+
for example [notifee](https://notifee.app/).
|
|
329
|
+
|
|
330
|
+
In `AndroidManifest.xml` specify necessary permissions:
|
|
331
|
+
|
|
332
|
+
```xml
|
|
333
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
|
|
334
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
|
|
335
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
And add foreground service:
|
|
339
|
+
|
|
340
|
+
```xml
|
|
341
|
+
<application
|
|
342
|
+
...
|
|
343
|
+
>
|
|
344
|
+
...
|
|
345
|
+
<service
|
|
346
|
+
android:name="app.notifee.core.ForegroundService"
|
|
347
|
+
android:foregroundServiceType="mediaProjection|camera|microphone" />
|
|
348
|
+
</application>
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Then to start the foreground service:
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
import notifee, { AndroidImportance } from '@notifee/react-native';
|
|
355
|
+
|
|
356
|
+
const startForegroundService = async () => {
|
|
357
|
+
if (Platform.OS === 'android') {
|
|
358
|
+
const channelId = await notifee.createChannel({
|
|
359
|
+
id: 'video_call',
|
|
360
|
+
name: 'Video call',
|
|
361
|
+
lights: false,
|
|
362
|
+
vibration: false,
|
|
363
|
+
importance: AndroidImportance.DEFAULT,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
await notifee.displayNotification({
|
|
367
|
+
title: 'Your video call is ongoing',
|
|
368
|
+
body: 'Tap to return to the call.',
|
|
369
|
+
android: {
|
|
370
|
+
channelId,
|
|
371
|
+
asForegroundService: true,
|
|
372
|
+
ongoing: true,
|
|
373
|
+
pressAction: {
|
|
374
|
+
id: 'default',
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Don't forget to also stop the service when the call has ended:
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
notifee.stopForegroundService();
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Also add this code in your `index.js` to register the service:
|
|
389
|
+
|
|
390
|
+
```js
|
|
391
|
+
notifee.registerForegroundService((notification) => {
|
|
392
|
+
return new Promise(() => {});
|
|
393
|
+
});
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Copyright and License
|
|
397
|
+
|
|
398
|
+
Copyright 2024,
|
|
399
|
+
[Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=react-client)
|
|
400
|
+
|
|
401
|
+
[](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=react-client)
|
|
402
|
+
|
|
403
|
+
Licensed under the [Apache License, Version 2.0](LICENSE)
|
package/android/build.gradle
CHANGED
|
@@ -2,8 +2,8 @@ apply plugin: 'com.android.library'
|
|
|
2
2
|
apply plugin: 'kotlin-android'
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
|
-
group = '
|
|
6
|
-
version = '0.
|
|
5
|
+
group = 'io.fishjam.reactnative'
|
|
6
|
+
version = '0.2.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -52,14 +52,14 @@ afterEvaluate {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
android {
|
|
55
|
-
namespace = "
|
|
55
|
+
namespace = "io.fishjam.reactnative"
|
|
56
56
|
compileSdk(31)
|
|
57
57
|
|
|
58
58
|
defaultConfig {
|
|
59
59
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
60
60
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
61
61
|
versionCode 1
|
|
62
|
-
versionName "0.
|
|
62
|
+
versionName "0.2.0"
|
|
63
63
|
}
|
|
64
64
|
lintOptions {
|
|
65
65
|
abortOnError false
|
|
@@ -81,8 +81,8 @@ dependencies {
|
|
|
81
81
|
if (findProject(':fishjam-cloud-android-client')) {
|
|
82
82
|
implementation project(':fishjam-cloud-android-client')
|
|
83
83
|
} else {
|
|
84
|
-
//
|
|
85
|
-
implementation 'com.github.fishjam-cloud:mobile-client-sdk:0.
|
|
84
|
+
// update version number when releasing
|
|
85
|
+
implementation 'com.github.fishjam-cloud:mobile-client-sdk:0.2.0'
|
|
86
86
|
}
|
|
87
87
|
api 'com.github.davidliu:audioswitch:8edf84ee46cdbc84c2b7725aa8f8d66363e19876'
|
|
88
88
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
package/app.plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./plugin/build/
|
|
1
|
+
module.exports = require('./plugin/build/withFishjam');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NativeModule } from 'react-native';
|
|
2
2
|
import type { RTCStats } from './stats/types';
|
|
3
|
-
import type { SimulcastConfig } from './types';
|
|
4
|
-
import type { CameraConfigInternal,
|
|
3
|
+
import type { ForegroundServiceOptions, SimulcastConfig } from './types';
|
|
4
|
+
import type { CameraConfigInternal, Camera } from './hooks/useCamera';
|
|
5
5
|
import type { Participant } from './hooks/useParticipants';
|
|
6
6
|
import type { ScreencastOptionsInternal } from './hooks/useScreencast';
|
|
7
7
|
import type { ConnectionConfig } from './common/client';
|
|
@@ -9,7 +9,7 @@ type Metadata = {
|
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
11
|
type RNFishjamClient = {
|
|
12
|
-
|
|
12
|
+
joinRoom: (url: string, participantToken: string, participantMetadata: Metadata, config: ConnectionConfig) => Promise<void>;
|
|
13
13
|
leaveRoom: () => Promise<void>;
|
|
14
14
|
startCamera: (config: CameraConfigInternal) => Promise<void>;
|
|
15
15
|
isMicrophoneOn: boolean;
|
|
@@ -17,8 +17,8 @@ type RNFishjamClient = {
|
|
|
17
17
|
isCameraOn: boolean;
|
|
18
18
|
toggleCamera: () => Promise<boolean>;
|
|
19
19
|
flipCamera: () => Promise<void>;
|
|
20
|
-
switchCamera: (
|
|
21
|
-
|
|
20
|
+
switchCamera: (cameraId: string) => Promise<void>;
|
|
21
|
+
cameras: ReadonlyArray<Camera>;
|
|
22
22
|
handleScreencastPermission: () => Promise<'granted' | 'denied'>;
|
|
23
23
|
toggleScreencast: (screencastOptions: Partial<ScreencastOptionsInternal>) => Promise<void>;
|
|
24
24
|
isScreencastOn: boolean;
|
|
@@ -41,6 +41,8 @@ type RNFishjamClient = {
|
|
|
41
41
|
setVideoTrackBandwidth: (bandwidth: number) => Promise<void>;
|
|
42
42
|
changeWebRTCLoggingSeverity: (severity: string) => Promise<void>;
|
|
43
43
|
getStatistics: () => Promise<RTCStats>;
|
|
44
|
+
startForegroundService: (options: ForegroundServiceOptions) => void;
|
|
45
|
+
stopForegroundService: () => void;
|
|
44
46
|
};
|
|
45
47
|
declare const _default: RNFishjamClient & NativeModule;
|
|
46
48
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNFishjamClientModule.js","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.js","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAwExD,MAAM,YAAY,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;AAE5D,eAAe,YAA8C,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\nimport { NativeModule } from 'react-native';\n\nimport type { RTCStats } from './stats/types';\nimport type { ForegroundServiceOptions, SimulcastConfig } from './types';\nimport type { CameraConfigInternal, Camera } from './hooks/useCamera';\nimport type { Participant } from './hooks/useParticipants';\nimport type { ScreencastOptionsInternal } from './hooks/useScreencast';\nimport type { ConnectionConfig } from './common/client';\n\ntype Metadata = { [key: string]: any };\n\ntype RNFishjamClient = {\n joinRoom: (\n url: string,\n participantToken: string,\n participantMetadata: Metadata,\n config: ConnectionConfig,\n ) => Promise<void>;\n leaveRoom: () => Promise<void>;\n startCamera: (config: CameraConfigInternal) => Promise<void>;\n isMicrophoneOn: boolean;\n toggleMicrophone: () => Promise<boolean>;\n isCameraOn: boolean;\n toggleCamera: () => Promise<boolean>;\n flipCamera: () => Promise<void>;\n switchCamera: (cameraId: string) => Promise<void>;\n cameras: ReadonlyArray<Camera>;\n handleScreencastPermission: () => Promise<'granted' | 'denied'>;\n toggleScreencast: (\n screencastOptions: Partial<ScreencastOptionsInternal>,\n ) => Promise<void>;\n isScreencastOn: boolean;\n getPeers: <PeerMetadataType extends Metadata>() => Promise<\n Participant<PeerMetadataType>[]\n >;\n updatePeerMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateVideoTrackMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateAudioTrackMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateScreencastTrackMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n setOutputAudioDevice: (audioDevice: string) => Promise<void>;\n startAudioSwitcher: () => Promise<void>;\n stopAudioSwitcher: () => Promise<void>;\n selectAudioSessionMode: (sessionMode: string) => Promise<void>;\n showAudioRoutePicker: () => Promise<void>;\n toggleScreencastTrackEncoding: (encoding: string) => Promise<SimulcastConfig>;\n setScreencastTrackBandwidth: (bandwidth: number) => Promise<void>;\n setScreencastTrackEncodingBandwidth: (\n encoding: string,\n bandwidth: number,\n ) => Promise<void>;\n setTargetTrackEncoding: (trackId: string, encoding: string) => Promise<void>;\n toggleVideoTrackEncoding: (encoding: string) => Promise<SimulcastConfig>;\n setVideoTrackEncodingBandwidth: (\n encoding: string,\n bandwidth: number,\n ) => Promise<void>;\n setVideoTrackBandwidth: (bandwidth: number) => Promise<void>;\n changeWebRTCLoggingSeverity: (severity: string) => Promise<void>;\n getStatistics: () => Promise<RTCStats>;\n startForegroundService: (options: ForegroundServiceOptions) => void;\n stopForegroundService: () => void;\n};\n\nconst nativeModule = requireNativeModule('RNFishjamClient');\n\nexport default nativeModule as RNFishjamClient & NativeModule;\n"]}
|
package/build/common/client.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export type ConnectionConfig = {
|
|
|
14
14
|
delayMs?: number;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param url fishjam Url
|
|
20
|
+
* @param participantToken
|
|
21
|
+
* @param participantMetadata
|
|
22
|
+
* @param config
|
|
23
|
+
*/
|
|
24
|
+
export declare function joinRoom<ParticipantMetadata extends GenericMetadata = GenericMetadata>(url: string, participantToken: string, participantMetadata: ParticipantMetadata, config?: ConnectionConfig): Promise<void>;
|
|
18
25
|
export declare function leaveRoom(): Promise<void>;
|
|
19
26
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,wBAAsB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,mBAAmB,SAAS,eAAe,GAAG,eAAe,EAE7D,GAAG,EAAE,MAAM,EACX,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,GAAE,gBAAqB,iBAQ9B;AAED,wBAAsB,SAAS,kBAE9B"}
|
package/build/common/client.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param url fishjam Url
|
|
5
|
+
* @param participantToken
|
|
6
|
+
* @param participantMetadata
|
|
7
|
+
* @param config
|
|
8
|
+
*/
|
|
9
|
+
export async function joinRoom(url, participantToken, participantMetadata, config = {}) {
|
|
10
|
+
await RNFishjamClientModule.joinRoom(url, participantToken, participantMetadata, config);
|
|
4
11
|
}
|
|
5
12
|
export async function leaveRoom() {
|
|
6
13
|
await RNFishjamClientModule.leaveRoom();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/common/client.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAkB7D,MAAM,CAAC,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/common/client.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAkB7D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAG5B,GAAW,EACX,gBAAwB,EACxB,mBAAwC,EACxC,SAA2B,EAAE;IAE7B,MAAM,qBAAqB,CAAC,QAAQ,CAClC,GAAG,EACH,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,qBAAqB,CAAC,SAAS,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import { GenericMetadata } from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\nexport type ConnectionConfig = {\n /**\n * Configuration for automatic reconnection\n * sdk uses a linear backoff algorithm, that is the formula\n * for the delay of the nth attempt is\n * n * delayMs + initialDelayMs\n *\n * Pass 0 for maxAttempts to disable automatic reconnection\n */\n reconnectConfig?: {\n maxAttempts?: number;\n initialDelayMs?: number;\n delayMs?: number;\n };\n};\n\n/**\n *\n * @param url fishjam Url\n * @param participantToken\n * @param participantMetadata\n * @param config\n */\nexport async function joinRoom<\n ParticipantMetadata extends GenericMetadata = GenericMetadata,\n>(\n url: string,\n participantToken: string,\n participantMetadata: ParticipantMetadata,\n config: ConnectionConfig = {},\n) {\n await RNFishjamClientModule.joinRoom(\n url,\n participantToken,\n participantMetadata,\n config,\n );\n}\n\nexport async function leaveRoom() {\n await RNFishjamClientModule.leaveRoom();\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ViewStyle } from 'react-native';
|
|
3
3
|
import { VideoLayout } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import { CameraId } from '../hooks/useCamera';
|
|
5
5
|
export type VideoPreviewViewProps = {
|
|
6
6
|
/**
|
|
7
7
|
* `FILL` or `FIT` - it works just like RN Image component. `FILL` fills the whole view
|
|
@@ -12,10 +12,10 @@ export type VideoPreviewViewProps = {
|
|
|
12
12
|
videoLayout?: VideoLayout;
|
|
13
13
|
style?: ViewStyle;
|
|
14
14
|
/**
|
|
15
|
-
* Id of the camera used for preview. Get available cameras with `
|
|
15
|
+
* Id of the camera used for preview. Get available cameras with `cameras` property.
|
|
16
16
|
* @default the first front camera
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
cameraId?: CameraId;
|
|
19
19
|
};
|
|
20
20
|
export declare const VideoPreviewView: React.ForwardRefExoticComponent<VideoPreviewViewProps & React.RefAttributes<React.ComponentType<VideoPreviewViewProps>>>;
|
|
21
21
|
//# sourceMappingURL=VideoPreviewView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPreviewView.d.ts","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"VideoPreviewView.d.ts","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAKF,eAAO,MAAM,gBAAgB,0HAM3B,CAAC"}
|
|
@@ -3,5 +3,5 @@ import * as React from 'react';
|
|
|
3
3
|
const NativeView = requireNativeViewManager('VideoPreviewViewModule');
|
|
4
4
|
export const VideoPreviewView = React.forwardRef((props, ref) => (
|
|
5
5
|
// @ts-expect-error ref prop needs to be updated
|
|
6
|
-
<NativeView {...props} ref={ref}/>));
|
|
6
|
+
<NativeView {...props} captureDeviceId={props.cameraId} ref={ref}/>));
|
|
7
7
|
//# sourceMappingURL=VideoPreviewView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPreviewView.js","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAG9C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,
|
|
1
|
+
{"version":3,"file":"VideoPreviewView.js","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAG9C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACrE,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport { CameraId } from '../hooks/useCamera';\n\nexport type VideoPreviewViewProps = {\n /**\n * `FILL` or `FIT` - it works just like RN Image component. `FILL` fills the whole view\n * with video and it may cut some parts of the video. `FIT` scales the video so the whole\n * video is visible, but it may leave some empty space in the view.\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n style?: ViewStyle;\n /**\n * Id of the camera used for preview. Get available cameras with `cameras` property.\n * @default the first front camera\n */\n cameraId?: CameraId;\n};\n\nconst NativeView: React.ComponentType<VideoPreviewViewProps> =\n requireNativeViewManager('VideoPreviewViewModule');\n\nexport const VideoPreviewView = React.forwardRef<\n React.ComponentType<VideoPreviewViewProps>,\n VideoPreviewViewProps\n>((props, ref) => (\n // @ts-expect-error ref prop needs to be updated\n <NativeView {...props} captureDeviceId={props.cameraId} ref={ref} />\n));\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;
|
|
1
|
+
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAOF;;GAEG;AACH,wBAAgB,gBAAgB;IAsE5B;;OAEG;;IAEH;;OAEG;;sCAhDY,qBAAqB;+CAkBX,gBAAgB;;EAoC5C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
4
|
-
import { ReceivableEvents,
|
|
4
|
+
import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
|
|
5
5
|
/**
|
|
6
6
|
* This hook manages audio settings.
|
|
7
7
|
*/
|
|
@@ -9,14 +9,13 @@ export function useAudioSettings() {
|
|
|
9
9
|
const [selectedAudioOutputDevice, setSelectedAudioOutputDevice] = useState(null);
|
|
10
10
|
const [availableDevices, setAvailableDevices] = useState([]);
|
|
11
11
|
const onAudioDevice = useCallback((event) => {
|
|
12
|
-
setSelectedAudioOutputDevice(event.
|
|
13
|
-
setAvailableDevices(event.
|
|
12
|
+
setSelectedAudioOutputDevice(event.selectedDevice);
|
|
13
|
+
setAvailableDevices(event.availableDevices);
|
|
14
14
|
}, []);
|
|
15
|
+
useFishjamEvent(ReceivableEvents.AudioDeviceUpdate, onAudioDevice);
|
|
15
16
|
useEffect(() => {
|
|
16
|
-
const eventListener = eventEmitter.addListener(ReceivableEvents.AudioDeviceUpdate, onAudioDevice);
|
|
17
17
|
RNFishjamClientModule.startAudioSwitcher();
|
|
18
18
|
return () => {
|
|
19
|
-
eventListener.remove();
|
|
20
19
|
if (Platform.OS === 'android') {
|
|
21
20
|
RNFishjamClientModule.stopAudioSwitcher();
|
|
22
21
|
}
|