@100mslive/react-native-hms 1.7.2 → 1.8.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.
Files changed (47) hide show
  1. package/android/src/main/java/com/reactnativehmssdk/HMSAudioshareActivity.kt +1 -0
  2. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +28 -10
  3. package/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayer.kt +113 -68
  4. package/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt +17 -4
  5. package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +34 -18
  6. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +363 -159
  7. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +367 -151
  8. package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +26 -7
  9. package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +32 -12
  10. package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +1 -0
  11. package/android/src/main/java/com/reactnativehmssdk/PipActionReceiver.kt +10 -6
  12. package/android/src/main/res/layout/player_view.xml +3 -2
  13. package/ios/HMSDecoder.swift +2 -2
  14. package/ios/HMSHLSPlayerManager.swift +18 -2
  15. package/ios/HMSManager.m +227 -70
  16. package/ios/HMSManager.swift +2 -2
  17. package/ios/HMSRNSDK.swift +67 -126
  18. package/ios/HMSView.swift +17 -3
  19. package/lib/commonjs/classes/HMSEncoder.js +6 -0
  20. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  21. package/lib/commonjs/classes/HMSSDK.js +40 -26
  22. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  23. package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js +10 -5
  24. package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/types.js +1 -0
  27. package/lib/commonjs/types.js.map +1 -1
  28. package/lib/module/classes/HMSEncoder.js +6 -0
  29. package/lib/module/classes/HMSEncoder.js.map +1 -1
  30. package/lib/module/classes/HMSSDK.js +40 -26
  31. package/lib/module/classes/HMSSDK.js.map +1 -1
  32. package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js +11 -6
  33. package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/types.js +1 -0
  36. package/lib/module/types.js.map +1 -1
  37. package/lib/typescript/classes/HMSEncoder.d.ts +1 -0
  38. package/lib/typescript/classes/HMSSDK.d.ts +23 -12
  39. package/lib/typescript/index.d.ts +1 -1
  40. package/lib/typescript/types.d.ts +3 -1
  41. package/package.json +1 -1
  42. package/sdk-versions.json +2 -2
  43. package/src/classes/HMSEncoder.ts +9 -0
  44. package/src/classes/HMSSDK.tsx +48 -24
  45. package/src/components/HMSHLSPlayer/HMSHLSPlayer.tsx +15 -13
  46. package/src/index.ts +4 -1
  47. package/src/types.ts +2 -0
@@ -34,7 +34,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
34
34
  // Example method
35
35
  // See https://reactnative.dev/docs/native-modules-android
36
36
  @ReactMethod
37
- fun build(data: ReadableMap?, callback: Promise?) {
37
+ fun build(
38
+ data: ReadableMap?,
39
+ callback: Promise?,
40
+ ) {
38
41
  val hasItem = hmsCollection.containsKey("12345")
39
42
  if (hasItem) {
40
43
  val uuid = UUID.randomUUID()
@@ -90,28 +93,40 @@ class HMSManager(reactContext: ReactApplicationContext) :
90
93
  }
91
94
 
92
95
  @ReactMethod
93
- fun leave(data: ReadableMap, callback: Promise?) {
96
+ fun leave(
97
+ data: ReadableMap,
98
+ callback: Promise?,
99
+ ) {
94
100
  val hms = HMSHelper.getHms(data, hmsCollection)
95
101
 
96
102
  hms?.leave(callback)
97
103
  }
98
104
 
99
105
  @ReactMethod
100
- fun sendBroadcastMessage(data: ReadableMap, callback: Promise?) {
106
+ fun sendBroadcastMessage(
107
+ data: ReadableMap,
108
+ callback: Promise?,
109
+ ) {
101
110
  val hms = HMSHelper.getHms(data, hmsCollection)
102
111
 
103
112
  hms?.sendBroadcastMessage(data, callback)
104
113
  }
105
114
 
106
115
  @ReactMethod
107
- fun sendGroupMessage(data: ReadableMap, callback: Promise?) {
116
+ fun sendGroupMessage(
117
+ data: ReadableMap,
118
+ callback: Promise?,
119
+ ) {
108
120
  val hms = HMSHelper.getHms(data, hmsCollection)
109
121
 
110
122
  hms?.sendGroupMessage(data, callback)
111
123
  }
112
124
 
113
125
  @ReactMethod
114
- fun sendDirectMessage(data: ReadableMap, callback: Promise?) {
126
+ fun sendDirectMessage(
127
+ data: ReadableMap,
128
+ callback: Promise?,
129
+ ) {
115
130
  val hms = HMSHelper.getHms(data, hmsCollection)
116
131
 
117
132
  hms?.sendDirectMessage(data, callback)
@@ -119,84 +134,120 @@ class HMSManager(reactContext: ReactApplicationContext) :
119
134
 
120
135
  @kotlin.Deprecated("Use #Function changeRoleOfPeer instead")
121
136
  @ReactMethod
122
- fun changeRole(data: ReadableMap, callback: Promise?) {
137
+ fun changeRole(
138
+ data: ReadableMap,
139
+ callback: Promise?,
140
+ ) {
123
141
  val hms = HMSHelper.getHms(data, hmsCollection)
124
142
 
125
143
  hms?.changeRole(data, callback)
126
144
  }
127
145
 
128
146
  @ReactMethod
129
- fun changeRoleOfPeer(data: ReadableMap, promise: Promise?) {
147
+ fun changeRoleOfPeer(
148
+ data: ReadableMap,
149
+ promise: Promise?,
150
+ ) {
130
151
  val hms = HMSHelper.getHms(data, hmsCollection)
131
152
 
132
153
  hms?.changeRoleOfPeer(data, promise)
133
154
  }
134
155
 
135
156
  @ReactMethod
136
- fun changeRoleOfPeersWithRoles(data: ReadableMap, promise: Promise?) {
157
+ fun changeRoleOfPeersWithRoles(
158
+ data: ReadableMap,
159
+ promise: Promise?,
160
+ ) {
137
161
  val hms = HMSHelper.getHms(data, hmsCollection)
138
162
 
139
163
  hms?.changeRoleOfPeersWithRoles(data, promise)
140
164
  }
141
165
 
142
166
  @ReactMethod
143
- fun changeTrackState(data: ReadableMap, callback: Promise?) {
167
+ fun changeTrackState(
168
+ data: ReadableMap,
169
+ callback: Promise?,
170
+ ) {
144
171
  val hms = HMSHelper.getHms(data, hmsCollection)
145
172
 
146
173
  hms?.changeTrackState(data, callback)
147
174
  }
148
175
 
149
176
  @ReactMethod
150
- fun changeTrackStateForRoles(data: ReadableMap, callback: Promise?) {
177
+ fun changeTrackStateForRoles(
178
+ data: ReadableMap,
179
+ callback: Promise?,
180
+ ) {
151
181
  val hms = HMSHelper.getHms(data, hmsCollection)
152
182
 
153
183
  hms?.changeTrackStateForRoles(data, callback)
154
184
  }
155
185
 
156
186
  @ReactMethod
157
- fun isMute(data: ReadableMap, callback: Promise?) {
187
+ fun isMute(
188
+ data: ReadableMap,
189
+ callback: Promise?,
190
+ ) {
158
191
  val hms = HMSHelper.getHms(data, hmsCollection)
159
192
 
160
193
  hms?.isMute(data, callback)
161
194
  }
162
195
 
163
196
  @ReactMethod
164
- fun removePeer(data: ReadableMap, callback: Promise?) {
197
+ fun removePeer(
198
+ data: ReadableMap,
199
+ callback: Promise?,
200
+ ) {
165
201
  val hms = HMSHelper.getHms(data, hmsCollection)
166
202
 
167
203
  hms?.removePeer(data, callback)
168
204
  }
169
205
 
170
206
  @ReactMethod
171
- fun isPlaybackAllowed(data: ReadableMap, callback: Promise?) {
207
+ fun isPlaybackAllowed(
208
+ data: ReadableMap,
209
+ callback: Promise?,
210
+ ) {
172
211
  val hms = HMSHelper.getHms(data, hmsCollection)
173
212
 
174
213
  hms?.isPlaybackAllowed(data, callback)
175
214
  }
176
215
 
177
216
  @ReactMethod
178
- fun getRoom(data: ReadableMap, callback: Promise?) {
217
+ fun getRoom(
218
+ data: ReadableMap,
219
+ callback: Promise?,
220
+ ) {
179
221
  val hms = HMSHelper.getHms(data, hmsCollection)
180
222
 
181
223
  hms?.getRoom(callback)
182
224
  }
183
225
 
184
226
  @ReactMethod
185
- fun getLocalPeer(data: ReadableMap, callback: Promise?) {
227
+ fun getLocalPeer(
228
+ data: ReadableMap,
229
+ callback: Promise?,
230
+ ) {
186
231
  val hms = HMSHelper.getHms(data, hmsCollection)
187
232
 
188
233
  hms?.getLocalPeer(callback)
189
234
  }
190
235
 
191
236
  @ReactMethod
192
- fun getRemotePeers(data: ReadableMap, callback: Promise?) {
237
+ fun getRemotePeers(
238
+ data: ReadableMap,
239
+ callback: Promise?,
240
+ ) {
193
241
  val hms = HMSHelper.getHms(data, hmsCollection)
194
242
 
195
243
  hms?.getRemotePeers(callback)
196
244
  }
197
245
 
198
246
  @ReactMethod
199
- fun getRoles(data: ReadableMap, callback: Promise?) {
247
+ fun getRoles(
248
+ data: ReadableMap,
249
+ callback: Promise?,
250
+ ) {
200
251
  val hms = HMSHelper.getHms(data, hmsCollection)
201
252
 
202
253
  hms?.getRoles(callback)
@@ -210,14 +261,40 @@ class HMSManager(reactContext: ReactApplicationContext) :
210
261
  }
211
262
 
212
263
  @ReactMethod
213
- fun endRoom(data: ReadableMap, callback: Promise?) {
264
+ fun endRoom(
265
+ data: ReadableMap,
266
+ callback: Promise?,
267
+ ) {
214
268
  val hms = HMSHelper.getHms(data, hmsCollection)
215
269
 
216
270
  hms?.endRoom(data, callback)
217
271
  }
218
272
 
219
273
  @ReactMethod
220
- fun acceptRoleChange(data: ReadableMap, callback: Promise?) {
274
+ fun previewForRole(
275
+ data: ReadableMap,
276
+ callback: Promise?,
277
+ ) {
278
+ val hms = HMSHelper.getHms(data, hmsCollection)
279
+
280
+ hms?.previewForRole(data, callback)
281
+ }
282
+
283
+ @ReactMethod
284
+ fun cancelPreview(
285
+ data: ReadableMap,
286
+ callback: Promise?,
287
+ ) {
288
+ val hms = HMSHelper.getHms(data, hmsCollection)
289
+
290
+ hms?.cancelPreview(callback)
291
+ }
292
+
293
+ @ReactMethod
294
+ fun acceptRoleChange(
295
+ data: ReadableMap,
296
+ callback: Promise?,
297
+ ) {
221
298
  val hms = HMSHelper.getHms(data, hmsCollection)
222
299
 
223
300
  hms?.acceptRoleChange(callback)
@@ -231,7 +308,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
231
308
  }
232
309
 
233
310
  @ReactMethod
234
- fun getVolume(data: ReadableMap, callback: Promise?) {
311
+ fun getVolume(
312
+ data: ReadableMap,
313
+ callback: Promise?,
314
+ ) {
235
315
  val hms = HMSHelper.getHms(data, hmsCollection)
236
316
 
237
317
  hms?.getVolume(data, callback)
@@ -245,21 +325,30 @@ class HMSManager(reactContext: ReactApplicationContext) :
245
325
  }
246
326
 
247
327
  @ReactMethod
248
- fun remoteMuteAllAudio(data: ReadableMap, callback: Promise?) {
328
+ fun remoteMuteAllAudio(
329
+ data: ReadableMap,
330
+ callback: Promise?,
331
+ ) {
249
332
  val hms = HMSHelper.getHms(data, hmsCollection)
250
333
 
251
334
  hms?.remoteMuteAllAudio(callback)
252
335
  }
253
336
 
254
337
  @ReactMethod
255
- fun changeMetadata(data: ReadableMap, callback: Promise?) {
338
+ fun changeMetadata(
339
+ data: ReadableMap,
340
+ callback: Promise?,
341
+ ) {
256
342
  val hms = HMSHelper.getHms(data, hmsCollection)
257
343
 
258
344
  hms?.changeMetadata(data, callback)
259
345
  }
260
346
 
261
347
  @ReactMethod
262
- fun startScreenshare(data: ReadableMap, callback: Promise?) {
348
+ fun startScreenshare(
349
+ data: ReadableMap,
350
+ callback: Promise?,
351
+ ) {
263
352
  currentActivity?.application?.registerActivityLifecycleCallbacks(this)
264
353
  val hms = HMSHelper.getHms(data, hmsCollection)
265
354
 
@@ -267,14 +356,20 @@ class HMSManager(reactContext: ReactApplicationContext) :
267
356
  }
268
357
 
269
358
  @ReactMethod
270
- fun isScreenShared(data: ReadableMap, callback: Promise?) {
359
+ fun isScreenShared(
360
+ data: ReadableMap,
361
+ callback: Promise?,
362
+ ) {
271
363
  val hms = HMSHelper.getHms(data, hmsCollection)
272
364
 
273
365
  hms?.isScreenShared(callback)
274
366
  }
275
367
 
276
368
  @ReactMethod
277
- fun stopScreenshare(data: ReadableMap, callback: Promise?) {
369
+ fun stopScreenshare(
370
+ data: ReadableMap,
371
+ callback: Promise?,
372
+ ) {
278
373
  val hms = HMSHelper.getHms(data, hmsCollection)
279
374
 
280
375
  currentActivity?.application?.unregisterActivityLifecycleCallbacks(this)
@@ -282,7 +377,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
282
377
  }
283
378
 
284
379
  @ReactMethod
285
- fun startAudioshare(data: ReadableMap, callback: Promise?) {
380
+ fun startAudioshare(
381
+ data: ReadableMap,
382
+ callback: Promise?,
383
+ ) {
286
384
  currentActivity?.application?.registerActivityLifecycleCallbacks(this)
287
385
  val hms = HMSHelper.getHms(data, hmsCollection)
288
386
 
@@ -290,14 +388,20 @@ class HMSManager(reactContext: ReactApplicationContext) :
290
388
  }
291
389
 
292
390
  @ReactMethod
293
- fun isAudioShared(data: ReadableMap, callback: Promise?) {
391
+ fun isAudioShared(
392
+ data: ReadableMap,
393
+ callback: Promise?,
394
+ ) {
294
395
  val hms = HMSHelper.getHms(data, hmsCollection)
295
396
 
296
397
  hms?.isAudioShared(callback)
297
398
  }
298
399
 
299
400
  @ReactMethod
300
- fun stopAudioshare(data: ReadableMap, callback: Promise?) {
401
+ fun stopAudioshare(
402
+ data: ReadableMap,
403
+ callback: Promise?,
404
+ ) {
301
405
  val hms = HMSHelper.getHms(data, hmsCollection)
302
406
 
303
407
  currentActivity?.application?.unregisterActivityLifecycleCallbacks(this)
@@ -305,42 +409,60 @@ class HMSManager(reactContext: ReactApplicationContext) :
305
409
  }
306
410
 
307
411
  @ReactMethod
308
- fun getAudioMixingMode(data: ReadableMap, callback: Promise?) {
412
+ fun getAudioMixingMode(
413
+ data: ReadableMap,
414
+ callback: Promise?,
415
+ ) {
309
416
  val hms = HMSHelper.getHms(data, hmsCollection)
310
417
 
311
418
  callback?.resolve(hms?.getAudioMixingMode()?.name)
312
419
  }
313
420
 
314
421
  @ReactMethod
315
- fun setAudioMixingMode(data: ReadableMap, callback: Promise?) {
422
+ fun setAudioMixingMode(
423
+ data: ReadableMap,
424
+ callback: Promise?,
425
+ ) {
316
426
  val hms = HMSHelper.getHms(data, hmsCollection)
317
427
 
318
428
  hms?.setAudioMixingMode(data, callback)
319
429
  }
320
430
 
321
431
  @ReactMethod
322
- fun startRTMPOrRecording(data: ReadableMap, callback: Promise?) {
432
+ fun startRTMPOrRecording(
433
+ data: ReadableMap,
434
+ callback: Promise?,
435
+ ) {
323
436
  val hms = HMSHelper.getHms(data, hmsCollection)
324
437
 
325
438
  hms?.startRTMPOrRecording(data, callback)
326
439
  }
327
440
 
328
441
  @ReactMethod
329
- fun stopRtmpAndRecording(data: ReadableMap, callback: Promise?) {
442
+ fun stopRtmpAndRecording(
443
+ data: ReadableMap,
444
+ callback: Promise?,
445
+ ) {
330
446
  val hms = HMSHelper.getHms(data, hmsCollection)
331
447
 
332
448
  hms?.stopRtmpAndRecording(callback)
333
449
  }
334
450
 
335
451
  @ReactMethod
336
- fun startHLSStreaming(data: ReadableMap, callback: Promise?) {
452
+ fun startHLSStreaming(
453
+ data: ReadableMap,
454
+ callback: Promise?,
455
+ ) {
337
456
  val hms = HMSHelper.getHms(data, hmsCollection)
338
457
 
339
458
  hms?.startHLSStreaming(data, callback)
340
459
  }
341
460
 
342
461
  @ReactMethod
343
- fun stopHLSStreaming(data: ReadableMap, callback: Promise?) {
462
+ fun stopHLSStreaming(
463
+ data: ReadableMap,
464
+ callback: Promise?,
465
+ ) {
344
466
  val hms = HMSHelper.getHms(data, hmsCollection)
345
467
 
346
468
  hms?.stopHLSStreaming(callback)
@@ -354,14 +476,20 @@ class HMSManager(reactContext: ReactApplicationContext) :
354
476
  }
355
477
 
356
478
  @ReactMethod
357
- fun changeName(data: ReadableMap, callback: Promise?) {
479
+ fun changeName(
480
+ data: ReadableMap,
481
+ callback: Promise?,
482
+ ) {
358
483
  val hms = HMSHelper.getHms(data, hmsCollection)
359
484
 
360
485
  hms?.changeName(data, callback)
361
486
  }
362
487
 
363
488
  @ReactMethod
364
- fun destroy(data: ReadableMap, callback: Promise?) {
489
+ fun destroy(
490
+ data: ReadableMap,
491
+ callback: Promise?,
492
+ ) {
365
493
  val id = data.getString("id")
366
494
  hmsCollection.remove(id)
367
495
  val result: WritableMap = Arguments.createMap()
@@ -385,14 +513,20 @@ class HMSManager(reactContext: ReactApplicationContext) :
385
513
  }
386
514
 
387
515
  @ReactMethod
388
- fun getAudioDevicesList(data: ReadableMap, callback: Promise?) {
516
+ fun getAudioDevicesList(
517
+ data: ReadableMap,
518
+ callback: Promise?,
519
+ ) {
389
520
  val hms = HMSHelper.getHms(data, hmsCollection)
390
521
 
391
522
  hms?.getAudioDevicesList(callback)
392
523
  }
393
524
 
394
525
  @ReactMethod
395
- fun getAudioOutputRouteType(data: ReadableMap, callback: Promise?) {
526
+ fun getAudioOutputRouteType(
527
+ data: ReadableMap,
528
+ callback: Promise?,
529
+ ) {
396
530
  val hms = HMSHelper.getHms(data, hmsCollection)
397
531
 
398
532
  hms?.getAudioOutputRouteType(callback)
@@ -434,28 +568,40 @@ class HMSManager(reactContext: ReactApplicationContext) :
434
568
  }
435
569
 
436
570
  @ReactMethod
437
- fun enableEvent(data: ReadableMap, promise: Promise?) {
571
+ fun enableEvent(
572
+ data: ReadableMap,
573
+ promise: Promise?,
574
+ ) {
438
575
  val hms = HMSHelper.getHms(data, hmsCollection)
439
576
 
440
577
  hms?.enableEvent(data, promise)
441
578
  }
442
579
 
443
580
  @ReactMethod
444
- fun disableEvent(data: ReadableMap, promise: Promise?) {
581
+ fun disableEvent(
582
+ data: ReadableMap,
583
+ promise: Promise?,
584
+ ) {
445
585
  val hms = HMSHelper.getHms(data, hmsCollection)
446
586
 
447
587
  hms?.disableEvent(data, promise)
448
588
  }
449
589
 
450
590
  @ReactMethod()
451
- fun restrictData(data: ReadableMap, promise: Promise?) {
591
+ fun restrictData(
592
+ data: ReadableMap,
593
+ promise: Promise?,
594
+ ) {
452
595
  val hms = HMSHelper.getHms(data, hmsCollection)
453
596
 
454
597
  hms?.restrictData(data, promise)
455
598
  }
456
599
 
457
600
  @ReactMethod()
458
- fun getAuthTokenByRoomCode(data: ReadableMap, promise: Promise) {
601
+ fun getAuthTokenByRoomCode(
602
+ data: ReadableMap,
603
+ promise: Promise,
604
+ ) {
459
605
  val hms = HMSHelper.getHms(data, hmsCollection)
460
606
 
461
607
  hms?.getAuthTokenByRoomCode(data, promise)
@@ -537,51 +683,60 @@ class HMSManager(reactContext: ReactApplicationContext) :
537
683
 
538
684
  when (code) {
539
685
  PipActionReceiver.PIPActions.localAudio.requestCode -> {
540
- val audioActionIdx = pipRemoteActionsList.indexOfFirst { it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localAudio.title }
686
+ val audioActionIdx =
687
+ pipRemoteActionsList.indexOfFirst {
688
+ it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localAudio.title
689
+ }
541
690
  if (audioActionIdx >= 0) {
542
- pipRemoteActionsList[audioActionIdx] = android.app.RemoteAction(
543
- android.graphics.drawable.Icon.createWithResource(
544
- reactApplicationContext,
545
- if (hmssdk?.getLocalPeer()?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24,
546
- ),
547
- PipActionReceiver.PIPActions.localAudio.title,
548
- PipActionReceiver.PIPActions.localAudio.description,
549
- PendingIntent.getBroadcast(
550
- reactApplicationContext,
551
- PipActionReceiver.PIPActions.localAudio.requestCode,
552
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
553
- PendingIntent.FLAG_IMMUTABLE,
554
- ),
555
- )
691
+ pipRemoteActionsList[audioActionIdx] =
692
+ android.app.RemoteAction(
693
+ android.graphics.drawable.Icon.createWithResource(
694
+ reactApplicationContext,
695
+ if (hmssdk?.getLocalPeer()?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24,
696
+ ),
697
+ PipActionReceiver.PIPActions.localAudio.title,
698
+ PipActionReceiver.PIPActions.localAudio.description,
699
+ PendingIntent.getBroadcast(
700
+ reactApplicationContext,
701
+ PipActionReceiver.PIPActions.localAudio.requestCode,
702
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
703
+ PendingIntent.FLAG_IMMUTABLE,
704
+ ),
705
+ )
556
706
  }
557
707
  }
558
708
  PipActionReceiver.PIPActions.localVideo.requestCode -> {
559
- val videoActionIdx = pipRemoteActionsList.indexOfFirst { it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localVideo.title }
709
+ val videoActionIdx =
710
+ pipRemoteActionsList.indexOfFirst {
711
+ it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localVideo.title
712
+ }
560
713
  if (videoActionIdx >= 0) {
561
714
  val isVideoMute = hmssdk?.getLocalPeer()?.videoTrack?.isMute
562
715
  val updatedIcon = if (isVideoMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
563
- pipRemoteActionsList[videoActionIdx] = android.app.RemoteAction(
564
- android.graphics.drawable.Icon.createWithResource(
565
- reactApplicationContext,
566
- updatedIcon,
567
- ),
568
- PipActionReceiver.PIPActions.localVideo.title,
569
- PipActionReceiver.PIPActions.localVideo.description,
570
- PendingIntent.getBroadcast(
571
- reactApplicationContext,
572
- PipActionReceiver.PIPActions.localVideo.requestCode,
573
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localVideo.title, PipActionReceiver.PIPActions.localVideo.requestCode),
574
- PendingIntent.FLAG_IMMUTABLE,
575
- ),
576
- )
716
+ pipRemoteActionsList[videoActionIdx] =
717
+ android.app.RemoteAction(
718
+ android.graphics.drawable.Icon.createWithResource(
719
+ reactApplicationContext,
720
+ updatedIcon,
721
+ ),
722
+ PipActionReceiver.PIPActions.localVideo.title,
723
+ PipActionReceiver.PIPActions.localVideo.description,
724
+ PendingIntent.getBroadcast(
725
+ reactApplicationContext,
726
+ PipActionReceiver.PIPActions.localVideo.requestCode,
727
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localVideo.title, PipActionReceiver.PIPActions.localVideo.requestCode),
728
+ PendingIntent.FLAG_IMMUTABLE,
729
+ ),
730
+ )
577
731
  }
578
732
  }
579
733
  }
580
734
 
581
- val pipParams = android.app.PictureInPictureParams.Builder().let {
582
- it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
583
- it.build()
584
- }
735
+ val pipParams =
736
+ android.app.PictureInPictureParams.Builder().let {
737
+ it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
738
+ it.build()
739
+ }
585
740
 
586
741
  activity.setPictureInPictureParams(pipParams)
587
742
  }
@@ -596,7 +751,11 @@ class HMSManager(reactContext: ReactApplicationContext) :
596
751
  )
597
752
 
598
753
  @ReactMethod
599
- fun handlePipActions(action: String, data: ReadableMap, promise: Promise?) {
754
+ fun handlePipActions(
755
+ action: String,
756
+ data: ReadableMap,
757
+ promise: Promise?,
758
+ ) {
600
759
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
601
760
  promise?.reject(Throwable("PIP mode is not supported!"))
602
761
  return
@@ -637,94 +796,97 @@ class HMSManager(reactContext: ReactApplicationContext) :
637
796
  return null
638
797
  }
639
798
 
640
- val pipParams = android.app.PictureInPictureParams.Builder().let {
641
- if (config.aspectRatio !== null) {
642
- it.setAspectRatio(
643
- Rational(
644
- config.aspectRatio.first,
645
- config.aspectRatio.second,
646
- ),
647
- )
648
- }
799
+ val pipParams =
800
+ android.app.PictureInPictureParams.Builder().let {
801
+ if (config.aspectRatio !== null) {
802
+ it.setAspectRatio(
803
+ Rational(
804
+ config.aspectRatio.first,
805
+ config.aspectRatio.second,
806
+ ),
807
+ )
808
+ }
649
809
 
650
810
  // TODO:= We need compileSdkVersion >= 31 for autoEnterEnabled
651
811
  // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && config.autoEnterEnabled !== null)
652
812
  // it.setAutoEnterEnabled(config.autoEnterEnabled)
653
813
  // }
654
814
 
655
- // region Setting RemoteActions on PictureInPictureParams
656
- val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
815
+ // region Setting RemoteActions on PictureInPictureParams
816
+ val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
657
817
 
658
- pipRemoteActionsList.clear()
818
+ pipRemoteActionsList.clear()
659
819
 
660
- val localPeer = hmssdk?.getLocalPeer()
661
- val allowedPublishing = localPeer?.hmsRole?.publishParams?.allowed
820
+ val localPeer = hmssdk?.getLocalPeer()
821
+ val allowedPublishing = localPeer?.hmsRole?.publishParams?.allowed
662
822
 
663
- if (config.showAudioButton && allowedPublishing?.contains("audio") === true) {
664
- pipRemoteActionsList.add(
665
- android.app.RemoteAction(
666
- android.graphics.drawable.Icon.createWithResource(
667
- reactApplicationContext,
668
- if (localPeer?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24,
669
- ),
670
- PipActionReceiver.PIPActions.localAudio.title,
671
- PipActionReceiver.PIPActions.localAudio.description,
672
- PendingIntent.getBroadcast(
673
- reactApplicationContext,
674
- PipActionReceiver.PIPActions.localAudio.requestCode,
675
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
676
- PendingIntent.FLAG_IMMUTABLE,
823
+ if (config.showAudioButton && allowedPublishing?.contains("audio") === true) {
824
+ pipRemoteActionsList.add(
825
+ android.app.RemoteAction(
826
+ android.graphics.drawable.Icon.createWithResource(
827
+ reactApplicationContext,
828
+ if (localPeer?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24,
829
+ ),
830
+ PipActionReceiver.PIPActions.localAudio.title,
831
+ PipActionReceiver.PIPActions.localAudio.description,
832
+ PendingIntent.getBroadcast(
833
+ reactApplicationContext,
834
+ PipActionReceiver.PIPActions.localAudio.requestCode,
835
+ Intent(
836
+ PipActionReceiver.PIP_INTENT_ACTION,
837
+ ).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
838
+ PendingIntent.FLAG_IMMUTABLE,
839
+ ),
677
840
  ),
678
- ),
679
- )
680
- }
841
+ )
842
+ }
681
843
 
682
- if (config.showEndButton) {
683
- pipRemoteActionsList.add(
684
- android.app.RemoteAction(
685
- android.graphics.drawable.Icon.createWithResource(reactApplicationContext, R.drawable.ic_call_end_24),
686
- PipActionReceiver.PIPActions.endMeet.title,
687
- PipActionReceiver.PIPActions.endMeet.description,
688
- PendingIntent.getBroadcast(
689
- reactApplicationContext,
690
- PipActionReceiver.PIPActions.endMeet.requestCode,
691
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
692
- PipActionReceiver.PIPActions.endMeet.title,
844
+ if (config.showEndButton) {
845
+ pipRemoteActionsList.add(
846
+ android.app.RemoteAction(
847
+ android.graphics.drawable.Icon.createWithResource(reactApplicationContext, R.drawable.ic_call_end_24),
848
+ PipActionReceiver.PIPActions.endMeet.title,
849
+ PipActionReceiver.PIPActions.endMeet.description,
850
+ PendingIntent.getBroadcast(
851
+ reactApplicationContext,
693
852
  PipActionReceiver.PIPActions.endMeet.requestCode,
853
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
854
+ PipActionReceiver.PIPActions.endMeet.title,
855
+ PipActionReceiver.PIPActions.endMeet.requestCode,
856
+ ),
857
+ PendingIntent.FLAG_IMMUTABLE,
694
858
  ),
695
- PendingIntent.FLAG_IMMUTABLE,
696
859
  ),
697
- ),
698
- )
699
- }
860
+ )
861
+ }
700
862
 
701
- if (config.showVideoButton && allowedPublishing?.contains("video") === true) {
702
- pipRemoteActionsList.add(
703
- android.app.RemoteAction(
704
- android.graphics.drawable.Icon.createWithResource(
705
- reactApplicationContext,
706
- if (localPeer?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on,
707
- ),
708
- PipActionReceiver.PIPActions.localVideo.title,
709
- PipActionReceiver.PIPActions.localVideo.description,
710
- PendingIntent.getBroadcast(
711
- reactApplicationContext,
712
- PipActionReceiver.PIPActions.localVideo.requestCode,
713
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
714
- PipActionReceiver.PIPActions.localVideo.title,
863
+ if (config.showVideoButton && allowedPublishing?.contains("video") === true) {
864
+ pipRemoteActionsList.add(
865
+ android.app.RemoteAction(
866
+ android.graphics.drawable.Icon.createWithResource(
867
+ reactApplicationContext,
868
+ if (localPeer?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on,
869
+ ),
870
+ PipActionReceiver.PIPActions.localVideo.title,
871
+ PipActionReceiver.PIPActions.localVideo.description,
872
+ PendingIntent.getBroadcast(
873
+ reactApplicationContext,
715
874
  PipActionReceiver.PIPActions.localVideo.requestCode,
875
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
876
+ PipActionReceiver.PIPActions.localVideo.title,
877
+ PipActionReceiver.PIPActions.localVideo.requestCode,
878
+ ),
879
+ PendingIntent.FLAG_IMMUTABLE,
716
880
  ),
717
- PendingIntent.FLAG_IMMUTABLE,
718
881
  ),
719
- ),
720
- )
721
- }
882
+ )
883
+ }
722
884
 
723
- it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
724
- // endregion
885
+ it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
886
+ // endregion
725
887
 
726
- it.build()
727
- }
888
+ it.build()
889
+ }
728
890
 
729
891
  return pipParams
730
892
  }
@@ -857,89 +1019,128 @@ class HMSManager(reactContext: ReactApplicationContext) :
857
1019
  }
858
1020
 
859
1021
  @ReactMethod
860
- fun getRemoteVideoTrackFromTrackId(data: ReadableMap, promise: Promise) {
1022
+ fun getRemoteVideoTrackFromTrackId(
1023
+ data: ReadableMap,
1024
+ promise: Promise,
1025
+ ) {
861
1026
  val hms = HMSHelper.getHms(data, hmsCollection)
862
1027
 
863
1028
  hms?.getRemoteVideoTrackFromTrackId(data, promise)
864
1029
  }
865
1030
 
866
1031
  @ReactMethod
867
- fun getRemoteAudioTrackFromTrackId(data: ReadableMap, promise: Promise) {
1032
+ fun getRemoteAudioTrackFromTrackId(
1033
+ data: ReadableMap,
1034
+ promise: Promise,
1035
+ ) {
868
1036
  val hms = HMSHelper.getHms(data, hmsCollection)
869
1037
 
870
1038
  hms?.getRemoteAudioTrackFromTrackId(data, promise)
871
1039
  }
872
1040
 
873
1041
  @ReactMethod
874
- fun getVideoTrackLayer(data: ReadableMap, promise: Promise) {
1042
+ fun getVideoTrackLayer(
1043
+ data: ReadableMap,
1044
+ promise: Promise,
1045
+ ) {
875
1046
  val hms = HMSHelper.getHms(data, hmsCollection)
876
1047
 
877
1048
  hms?.getVideoTrackLayer(data, promise)
878
1049
  }
879
1050
 
880
1051
  @ReactMethod
881
- fun getVideoTrackLayerDefinition(data: ReadableMap, promise: Promise) {
1052
+ fun getVideoTrackLayerDefinition(
1053
+ data: ReadableMap,
1054
+ promise: Promise,
1055
+ ) {
882
1056
  val hms = HMSHelper.getHms(data, hmsCollection)
883
1057
 
884
1058
  hms?.getVideoTrackLayerDefinition(data, promise)
885
1059
  }
886
1060
 
887
1061
  @ReactMethod
888
- fun setVideoTrackLayer(data: ReadableMap, promise: Promise?) {
1062
+ fun setVideoTrackLayer(
1063
+ data: ReadableMap,
1064
+ promise: Promise?,
1065
+ ) {
889
1066
  val hms = HMSHelper.getHms(data, hmsCollection)
890
1067
 
891
1068
  hms?.setVideoTrackLayer(data, promise)
892
1069
  }
893
1070
 
894
1071
  @ReactMethod
895
- fun captureImageAtMaxSupportedResolution(data: ReadableMap, promise: Promise?) {
1072
+ fun captureImageAtMaxSupportedResolution(
1073
+ data: ReadableMap,
1074
+ promise: Promise?,
1075
+ ) {
896
1076
  val hms = HMSHelper.getHms(data, hmsCollection)
897
1077
 
898
1078
  hms?.captureImageAtMaxSupportedResolution(data, promise)
899
1079
  }
900
1080
 
901
1081
  @ReactMethod
902
- fun setSessionMetadataForKey(data: ReadableMap, promise: Promise?) {
1082
+ fun setSessionMetadataForKey(
1083
+ data: ReadableMap,
1084
+ promise: Promise?,
1085
+ ) {
903
1086
  val hms = HMSHelper.getHms(data, hmsCollection)
904
1087
 
905
1088
  hms?.setSessionMetadataForKey(data, promise)
906
1089
  }
907
1090
 
908
1091
  @ReactMethod
909
- fun getSessionMetadataForKey(data: ReadableMap, promise: Promise?) {
1092
+ fun getSessionMetadataForKey(
1093
+ data: ReadableMap,
1094
+ promise: Promise?,
1095
+ ) {
910
1096
  val hms = HMSHelper.getHms(data, hmsCollection)
911
1097
 
912
1098
  hms?.getSessionMetadataForKey(data, promise)
913
1099
  }
914
1100
 
915
1101
  @ReactMethod
916
- fun addKeyChangeListener(data: ReadableMap, promise: Promise?) {
1102
+ fun addKeyChangeListener(
1103
+ data: ReadableMap,
1104
+ promise: Promise?,
1105
+ ) {
917
1106
  val hms = HMSHelper.getHms(data, hmsCollection)
918
1107
 
919
1108
  hms?.addKeyChangeListener(data, promise)
920
1109
  }
921
1110
 
922
1111
  @ReactMethod
923
- fun removeKeyChangeListener(data: ReadableMap, promise: Promise?) {
1112
+ fun removeKeyChangeListener(
1113
+ data: ReadableMap,
1114
+ promise: Promise?,
1115
+ ) {
924
1116
  val hms = HMSHelper.getHms(data, hmsCollection)
925
1117
 
926
1118
  hms?.removeKeyChangeListener(data, promise)
927
1119
  }
928
1120
 
929
1121
  @ReactMethod
930
- fun getRoomLayout(data: ReadableMap, promise: Promise?) {
1122
+ fun getRoomLayout(
1123
+ data: ReadableMap,
1124
+ promise: Promise?,
1125
+ ) {
931
1126
  val hms = HMSHelper.getHms(data, hmsCollection)
932
1127
 
933
1128
  hms?.getRoomLayout(data, promise)
934
1129
  }
935
1130
 
936
- fun emitEvent(event: String, data: WritableMap) {
1131
+ fun emitEvent(
1132
+ event: String,
1133
+ data: WritableMap,
1134
+ ) {
937
1135
  reactApplicationContext
938
1136
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
939
1137
  .emit(event, data)
940
1138
  }
941
1139
 
942
- override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
1140
+ override fun onActivityCreated(
1141
+ activity: Activity,
1142
+ savedInstanceState: Bundle?,
1143
+ ) {}
943
1144
 
944
1145
  override fun onActivityStarted(activity: Activity) {}
945
1146
 
@@ -949,7 +1150,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
949
1150
 
950
1151
  override fun onActivityStopped(activity: Activity) {}
951
1152
 
952
- override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
1153
+ override fun onActivitySaveInstanceState(
1154
+ activity: Activity,
1155
+ outState: Bundle,
1156
+ ) {}
953
1157
 
954
1158
  override fun onActivityDestroyed(activity: Activity) {
955
1159
  try {