@100mslive/react-native-hms 1.7.0 → 1.7.2
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 +30 -39
- package/android/.gradle/6.7.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.7.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.7.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.7.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.7.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.7.1/gc.properties +0 -0
- package/android/.gradle/6.9/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +16 -9
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradlew +103 -104
- package/android/gradlew.bat +3 -18
- package/android/local.properties +0 -7
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +37 -9
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +2 -1
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +7 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +39 -10
- package/ios/HMSDecoder.swift +9 -10
- package/ios/HMSHelper.swift +6 -2
- package/ios/HMSManager.m +4 -0
- package/ios/HMSManager.swift +8 -0
- package/ios/HMSRNSDK.swift +54 -24
- package/lib/commonjs/classes/HMSAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSBrowserRecordingState.js +2 -0
- package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSCameraControl.js +3 -5
- package/lib/commonjs/classes/HMSCameraControl.js.map +1 -1
- package/lib/commonjs/classes/HMSEncoder.js +42 -40
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSEventEmitter.js +10 -0
- package/lib/commonjs/classes/HMSEventEmitter.js.map +1 -0
- package/lib/commonjs/classes/HMSHelper.js +1 -1
- package/lib/commonjs/classes/HMSHelper.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalAudioTrack.js +2 -2
- package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoTrack.js +2 -2
- package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLogger.js +4 -4
- package/lib/commonjs/classes/HMSLogger.js.map +1 -1
- package/lib/commonjs/classes/HMSManagerModule.js +18 -0
- package/lib/commonjs/classes/HMSManagerModule.js.map +1 -0
- package/lib/commonjs/classes/HMSMessage.js.map +1 -1
- package/lib/commonjs/classes/HMSNativeEventEmitter.js +6 -6
- package/lib/commonjs/classes/HMSNativeEventEmitter.js.map +1 -1
- package/lib/commonjs/classes/HMSNativeEventListener.js +13 -0
- package/lib/commonjs/classes/HMSNativeEventListener.js.map +1 -0
- package/lib/commonjs/classes/HMSPeer.js +2 -15
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPeersCache.js +3 -5
- package/lib/commonjs/classes/HMSPeersCache.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js +2 -2
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js +5 -5
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomCache.js +10 -5
- package/lib/commonjs/classes/HMSRoomCache.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +165 -170
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSSessionStore.js +9 -10
- package/lib/commonjs/classes/HMSSessionStore.js.map +1 -1
- package/lib/commonjs/classes/HMSTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +1 -1
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js +8 -8
- package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
- package/lib/commonjs/components/HMSHLSPlayer/RCTHMSHLSPlayer.js.map +1 -1
- package/lib/commonjs/components/HMSHLSPlayer/hooks.js.map +1 -1
- package/lib/commonjs/hooks/useHMSPeerUpdates.js +77 -0
- package/lib/commonjs/hooks/useHMSPeerUpdates.js.map +1 -0
- package/lib/commonjs/index.js +25 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSBrowserRecordingState.js +2 -0
- package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/module/classes/HMSCameraControl.js +1 -4
- package/lib/module/classes/HMSCameraControl.js.map +1 -1
- package/lib/module/classes/HMSEncoder.js +40 -39
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSEventEmitter.js +3 -0
- package/lib/module/classes/HMSEventEmitter.js.map +1 -0
- package/lib/module/classes/HMSHelper.js +1 -1
- package/lib/module/classes/HMSHelper.js.map +1 -1
- package/lib/module/classes/HMSLocalAudioTrack.js +2 -2
- package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSLocalPeer.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoTrack.js +2 -2
- package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSLogger.js +4 -4
- package/lib/module/classes/HMSLogger.js.map +1 -1
- package/lib/module/classes/HMSManagerModule.js +11 -0
- package/lib/module/classes/HMSManagerModule.js.map +1 -0
- package/lib/module/classes/HMSMessage.js.map +1 -1
- package/lib/module/classes/HMSNativeEventEmitter.js +6 -6
- package/lib/module/classes/HMSNativeEventEmitter.js.map +1 -1
- package/lib/module/classes/HMSNativeEventListener.js +5 -0
- package/lib/module/classes/HMSNativeEventListener.js.map +1 -0
- package/lib/module/classes/HMSPeer.js +2 -15
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPeersCache.js +1 -4
- package/lib/module/classes/HMSPeersCache.js.map +1 -1
- package/lib/module/classes/HMSRemoteAudioTrack.js +2 -2
- package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSRemotePeer.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js +5 -5
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomCache.js +8 -4
- package/lib/module/classes/HMSRoomCache.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +113 -118
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSSessionStore.js +5 -7
- package/lib/module/classes/HMSSessionStore.js.map +1 -1
- package/lib/module/classes/HMSTrack.js.map +1 -1
- package/lib/module/classes/HMSVideoTrack.js.map +1 -1
- package/lib/module/classes/HmsView.js +1 -1
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js +8 -8
- package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
- package/lib/module/components/HMSHLSPlayer/RCTHMSHLSPlayer.js.map +1 -1
- package/lib/module/components/HMSHLSPlayer/hooks.js.map +1 -1
- package/lib/module/hooks/useHMSPeerUpdates.js +67 -0
- package/lib/module/hooks/useHMSPeerUpdates.js.map +1 -0
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSAudioTrack.d.ts +2 -1
- package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +2 -0
- package/lib/typescript/classes/HMSEventEmitter.d.ts +2 -0
- package/lib/typescript/classes/HMSLocalAudioTrack.d.ts +2 -1
- package/lib/typescript/classes/HMSLocalPeer.d.ts +4 -2
- package/lib/typescript/classes/HMSLocalVideoTrack.d.ts +2 -1
- package/lib/typescript/classes/HMSManagerModule.d.ts +3 -0
- package/lib/typescript/classes/HMSMessage.d.ts +2 -3
- package/lib/typescript/classes/HMSNativeEventListener.d.ts +4 -0
- package/lib/typescript/classes/HMSPeer.d.ts +2 -3
- package/lib/typescript/classes/HMSRemoteAudioTrack.d.ts +2 -1
- package/lib/typescript/classes/HMSRemotePeer.d.ts +4 -2
- package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +2 -1
- package/lib/typescript/classes/HMSRoom.d.ts +1 -1
- package/lib/typescript/classes/HMSSDK.d.ts +8 -7
- package/lib/typescript/classes/HMSTrack.d.ts +3 -2
- package/lib/typescript/classes/HMSVideoTrack.d.ts +2 -1
- package/lib/typescript/classes/HmsView.d.ts +1 -1
- package/lib/typescript/components/HMSHLSPlayer/RCTHMSHLSPlayer.d.ts +1 -1
- package/lib/typescript/components/HMSHLSPlayer/hooks.d.ts +1 -1
- package/lib/typescript/hooks/useHMSPeerUpdates.d.ts +7 -0
- package/lib/typescript/index.d.ts +2 -1
- package/package.json +2 -2
- package/sdk-versions.json +2 -2
- package/src/classes/HMSAudioTrack.ts +2 -1
- package/src/classes/HMSBrowserRecordingState.ts +3 -0
- package/src/classes/HMSCameraControl.ts +1 -2
- package/src/classes/HMSEncoder.ts +7 -5
- package/src/classes/HMSEventEmitter.ts +3 -0
- package/src/classes/HMSLocalAudioTrack.ts +2 -1
- package/src/classes/HMSLocalPeer.ts +4 -2
- package/src/classes/HMSLocalVideoTrack.ts +2 -1
- package/src/classes/HMSManagerModule.ts +18 -0
- package/src/classes/HMSMessage.ts +2 -3
- package/src/classes/HMSNativeEventEmitter.ts +2 -1
- package/src/classes/HMSNativeEventListener.ts +8 -0
- package/src/classes/HMSPeer.ts +3 -26
- package/src/classes/HMSPeersCache.ts +2 -3
- package/src/classes/HMSRemoteAudioTrack.ts +2 -1
- package/src/classes/HMSRemotePeer.ts +4 -2
- package/src/classes/HMSRemoteVideoTrack.ts +2 -1
- package/src/classes/HMSRoom.ts +1 -1
- package/src/classes/HMSRoomCache.ts +11 -3
- package/src/classes/HMSSDK.tsx +47 -52
- package/src/classes/HMSSessionStore.ts +6 -8
- package/src/classes/HMSTrack.ts +3 -2
- package/src/classes/HMSVideoTrack.ts +2 -1
- package/src/classes/HmsView.tsx +4 -2
- package/src/components/HMSHLSPlayer/HMSHLSPlayer.tsx +36 -10
- package/src/components/HMSHLSPlayer/RCTHMSHLSPlayer.ts +2 -3
- package/src/components/HMSHLSPlayer/hooks.ts +3 -2
- package/src/hooks/useHMSPeerUpdates.ts +85 -0
- package/src/index.ts +6 -1
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/yogesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Hmssdk.xcodeproj/xcuserdata/yogesh.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/lib/commonjs/classes/HMSMessageType.js +0 -13
- package/lib/commonjs/classes/HMSMessageType.js.map +0 -1
- package/lib/module/classes/HMSMessageType.js +0 -6
- package/lib/module/classes/HMSMessageType.js.map +0 -1
- package/lib/typescript/classes/HMSMessageType.d.ts +0 -4
- package/src/classes/HMSMessageType.ts +0 -4
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import HMSManager from './HMSManagerModule';
|
|
2
|
+
|
|
2
3
|
import type { HMSRoom } from './HMSRoom';
|
|
3
4
|
import { HMSEncoder } from './HMSEncoder';
|
|
4
5
|
import { HMSRoomUpdate } from './HMSRoomUpdate';
|
|
5
6
|
|
|
6
|
-
const { HMSManager } = NativeModules;
|
|
7
|
-
|
|
8
7
|
export let hmsRoomCache: HMSRoomCache | undefined;
|
|
9
8
|
|
|
10
9
|
export const getHmsRoomCache = () => hmsRoomCache;
|
|
@@ -93,6 +92,13 @@ export class HMSRoomCache {
|
|
|
93
92
|
);
|
|
94
93
|
break;
|
|
95
94
|
}
|
|
95
|
+
case HMSRoomUpdate.ROOM_PEER_COUNT_UPDATED: {
|
|
96
|
+
this._data.set(
|
|
97
|
+
'peerCount',
|
|
98
|
+
encodeHMSRoomProperty(this.id, 'peerCount', data)
|
|
99
|
+
);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
96
102
|
default: {
|
|
97
103
|
for (const key in data) {
|
|
98
104
|
const property = key as keyof HMSRoomCacheProps;
|
|
@@ -149,6 +155,8 @@ function encodeHMSRoomProperty<T extends keyof HMSRoomCacheProps>(
|
|
|
149
155
|
value = HMSEncoder.encodeHLSRecordingState(data.hlsRecordingState);
|
|
150
156
|
} else if (property === 'localPeer') {
|
|
151
157
|
value = HMSEncoder.encodeHmsLocalPeer(data.localPeer, id);
|
|
158
|
+
} else if (property === 'peerCount') {
|
|
159
|
+
value = typeof data[property] === 'number' ? data[property] : null;
|
|
152
160
|
} else {
|
|
153
161
|
value = data[property];
|
|
154
162
|
}
|
package/src/classes/HMSSDK.tsx
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AppState,
|
|
2
|
+
import { AppState, Platform } from 'react-native';
|
|
3
3
|
import { HMSEncoder } from './HMSEncoder';
|
|
4
4
|
import { HMSHelper } from './HMSHelper';
|
|
5
5
|
import { getLogger, logger, setLogger } from './HMSLogger';
|
|
6
6
|
import { HMSTrackType } from './HMSTrackType';
|
|
7
7
|
import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
|
|
8
|
-
import { HmsViewComponent
|
|
8
|
+
import { HmsViewComponent } from './HmsView';
|
|
9
|
+
import type { HmsComponentProps } from './HmsView';
|
|
10
|
+
|
|
11
|
+
import HMSManager from './HMSManagerModule';
|
|
9
12
|
|
|
10
13
|
import type { HMSConfig } from './HMSConfig';
|
|
11
14
|
import type { HMSLocalPeer } from './HMSLocalPeer';
|
|
@@ -23,10 +26,9 @@ import type { HMSAudioDevice } from './HMSAudioDevice';
|
|
|
23
26
|
import type { HMSAudioMode } from './HMSAudioMode';
|
|
24
27
|
import type { HMSAudioMixingMode } from './HMSAudioMixingMode';
|
|
25
28
|
import type { HMSLogSettings } from './HMSLogSettings';
|
|
26
|
-
import { HMSMessageType } from './HMSMessageType';
|
|
27
29
|
import { HMSPIPListenerActions } from './HMSPIPListenerActions';
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
30
|
+
import HMSNativeEventListener from './HMSNativeEventListener';
|
|
31
|
+
import type { HMSNativeEventSubscription } from './HMSNativeEventListener';
|
|
30
32
|
import {
|
|
31
33
|
clearHmsPeersCache,
|
|
32
34
|
getHmsPeersCache,
|
|
@@ -52,17 +54,8 @@ interface PIPConfig {
|
|
|
52
54
|
videoButton?: boolean;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
const {
|
|
56
|
-
/**
|
|
57
|
-
* @ignore
|
|
58
|
-
*/
|
|
59
|
-
HMSManager,
|
|
60
|
-
} = NativeModules;
|
|
61
|
-
|
|
62
57
|
const ReactNativeVersion = require('react-native/Libraries/Core/ReactNativeVersion');
|
|
63
58
|
|
|
64
|
-
const HmsEventEmitter = new HMSNativeEventEmitter(HMSManager);
|
|
65
|
-
|
|
66
59
|
let HmsSdk: HMSSDK | undefined;
|
|
67
60
|
|
|
68
61
|
export class HMSSDK {
|
|
@@ -94,7 +87,7 @@ export class HMSSDK {
|
|
|
94
87
|
private emitterSubscriptions: Partial<
|
|
95
88
|
Record<
|
|
96
89
|
HMSUpdateListenerActions | HMSPIPListenerActions,
|
|
97
|
-
|
|
90
|
+
HMSNativeEventSubscription
|
|
98
91
|
>
|
|
99
92
|
> = {};
|
|
100
93
|
|
|
@@ -124,6 +117,7 @@ export class HMSSDK {
|
|
|
124
117
|
appGroup?: String;
|
|
125
118
|
preferredExtension?: String;
|
|
126
119
|
logSettings?: HMSLogSettings;
|
|
120
|
+
isPrebuilt?: boolean;
|
|
127
121
|
}) {
|
|
128
122
|
const { version } = require('../../package.json');
|
|
129
123
|
const { major, minor, patch } = ReactNativeVersion.version;
|
|
@@ -134,6 +128,7 @@ export class HMSSDK {
|
|
|
134
128
|
frameworkInfo: {
|
|
135
129
|
version: major + '.' + minor + '.' + patch,
|
|
136
130
|
sdkVersion: version,
|
|
131
|
+
isPrebuilt: params?.isPrebuilt || false,
|
|
137
132
|
},
|
|
138
133
|
logSettings: params?.logSettings,
|
|
139
134
|
});
|
|
@@ -302,13 +297,11 @@ export class HMSSDK {
|
|
|
302
297
|
*
|
|
303
298
|
* checkout {@link https://www.100ms.live/docs/react-native/v2/features/chat} for more info
|
|
304
299
|
*
|
|
305
|
-
* @param {message: string} and @param {type: string}
|
|
306
300
|
* @memberof HMSSDK
|
|
301
|
+
* @param message the message that is to be sent
|
|
302
|
+
* @param type the default type is set to CHAT. You can pass a custom type here for sending events like Emoji Reactions, Notifications, etc
|
|
307
303
|
*/
|
|
308
|
-
sendBroadcastMessage = async (
|
|
309
|
-
message: string,
|
|
310
|
-
type: HMSMessageType = HMSMessageType.CHAT
|
|
311
|
-
) => {
|
|
304
|
+
sendBroadcastMessage = async (message: string, type: string = 'chat') => {
|
|
312
305
|
logger?.verbose('#Function sendBroadcastMessage', {
|
|
313
306
|
message,
|
|
314
307
|
type: type || null,
|
|
@@ -335,7 +328,7 @@ export class HMSSDK {
|
|
|
335
328
|
sendGroupMessage = async (
|
|
336
329
|
message: string,
|
|
337
330
|
roles: HMSRole[],
|
|
338
|
-
type:
|
|
331
|
+
type: string = 'chat'
|
|
339
332
|
) => {
|
|
340
333
|
logger?.verbose('#Function sendGroupMessage', {
|
|
341
334
|
message,
|
|
@@ -365,7 +358,7 @@ export class HMSSDK {
|
|
|
365
358
|
sendDirectMessage = async (
|
|
366
359
|
message: string,
|
|
367
360
|
peer: HMSPeer,
|
|
368
|
-
type:
|
|
361
|
+
type: string = 'chat'
|
|
369
362
|
) => {
|
|
370
363
|
logger?.verbose('#Function sendDirectMessage', {
|
|
371
364
|
message,
|
|
@@ -1007,8 +1000,8 @@ export class HMSSDK {
|
|
|
1007
1000
|
*
|
|
1008
1001
|
* checkout {@link https://www.100ms.live/docs/react-native/v2/features/audio-output-routing#switch-audio-focus-to-another-device} for more info
|
|
1009
1002
|
*
|
|
1010
|
-
* @param {HMSAudioDevice}
|
|
1011
1003
|
* @memberof HMSSDK
|
|
1004
|
+
* @param audioDevice
|
|
1012
1005
|
*/
|
|
1013
1006
|
switchAudioOutput = (audioDevice: HMSAudioDevice) => {
|
|
1014
1007
|
logger?.verbose('#Function switchAudioOutput', {
|
|
@@ -1148,7 +1141,7 @@ export class HMSSDK {
|
|
|
1148
1141
|
// Checking if we already have ON_PREVIEW subscription
|
|
1149
1142
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_PREVIEW]) {
|
|
1150
1143
|
// Adding ON_PREVIEW native listener
|
|
1151
|
-
const previewSubscription =
|
|
1144
|
+
const previewSubscription = HMSNativeEventListener.addListener(
|
|
1152
1145
|
this.id,
|
|
1153
1146
|
HMSUpdateListenerActions.ON_PREVIEW,
|
|
1154
1147
|
this.onPreviewListener
|
|
@@ -1164,7 +1157,7 @@ export class HMSSDK {
|
|
|
1164
1157
|
// Checking if we already have ON_JOIN subscription
|
|
1165
1158
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_JOIN]) {
|
|
1166
1159
|
// Adding ON_JOIN native listener
|
|
1167
|
-
const joinSubscription =
|
|
1160
|
+
const joinSubscription = HMSNativeEventListener.addListener(
|
|
1168
1161
|
this.id,
|
|
1169
1162
|
HMSUpdateListenerActions.ON_JOIN,
|
|
1170
1163
|
this.onJoinListener
|
|
@@ -1182,7 +1175,7 @@ export class HMSSDK {
|
|
|
1182
1175
|
!this.emitterSubscriptions[HMSUpdateListenerActions.ON_ROOM_UPDATE]
|
|
1183
1176
|
) {
|
|
1184
1177
|
// Adding ON_ROOM_UPDATE native listener
|
|
1185
|
-
const roomSubscription =
|
|
1178
|
+
const roomSubscription = HMSNativeEventListener.addListener(
|
|
1186
1179
|
this.id,
|
|
1187
1180
|
HMSUpdateListenerActions.ON_ROOM_UPDATE,
|
|
1188
1181
|
this.onRoomListener
|
|
@@ -1200,7 +1193,7 @@ export class HMSSDK {
|
|
|
1200
1193
|
!this.emitterSubscriptions[HMSUpdateListenerActions.ON_PEER_UPDATE]
|
|
1201
1194
|
) {
|
|
1202
1195
|
// Adding ON_PEER_UPDATE native listener
|
|
1203
|
-
const peerSubscription =
|
|
1196
|
+
const peerSubscription = HMSNativeEventListener.addListener(
|
|
1204
1197
|
this.id,
|
|
1205
1198
|
HMSUpdateListenerActions.ON_PEER_UPDATE,
|
|
1206
1199
|
this.onPeerListener
|
|
@@ -1218,7 +1211,7 @@ export class HMSSDK {
|
|
|
1218
1211
|
!this.emitterSubscriptions[HMSUpdateListenerActions.ON_TRACK_UPDATE]
|
|
1219
1212
|
) {
|
|
1220
1213
|
// Adding ON_TRACK_UPDATE native listener
|
|
1221
|
-
const trackSubscription =
|
|
1214
|
+
const trackSubscription = HMSNativeEventListener.addListener(
|
|
1222
1215
|
this.id,
|
|
1223
1216
|
HMSUpdateListenerActions.ON_TRACK_UPDATE,
|
|
1224
1217
|
this.onTrackListener
|
|
@@ -1234,7 +1227,7 @@ export class HMSSDK {
|
|
|
1234
1227
|
// Checking if we already have ON_ERROR subscription
|
|
1235
1228
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_ERROR]) {
|
|
1236
1229
|
// Adding ON_ERROR native listener
|
|
1237
|
-
const errorSubscription =
|
|
1230
|
+
const errorSubscription = HMSNativeEventListener.addListener(
|
|
1238
1231
|
this.id,
|
|
1239
1232
|
HMSUpdateListenerActions.ON_ERROR,
|
|
1240
1233
|
this.onErrorListener
|
|
@@ -1250,7 +1243,7 @@ export class HMSSDK {
|
|
|
1250
1243
|
// Checking if we already have ON_MESSAGE subscription
|
|
1251
1244
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_MESSAGE]) {
|
|
1252
1245
|
// Adding ON_MESSAGE native listener
|
|
1253
|
-
const messageSubscription =
|
|
1246
|
+
const messageSubscription = HMSNativeEventListener.addListener(
|
|
1254
1247
|
this.id,
|
|
1255
1248
|
HMSUpdateListenerActions.ON_MESSAGE,
|
|
1256
1249
|
this.onMessageListener
|
|
@@ -1266,7 +1259,7 @@ export class HMSSDK {
|
|
|
1266
1259
|
// Checking if we already have ON_SPEAKER subscription
|
|
1267
1260
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_SPEAKER]) {
|
|
1268
1261
|
// Adding ON_SPEAKER native listener
|
|
1269
|
-
const speakerSubscription =
|
|
1262
|
+
const speakerSubscription = HMSNativeEventListener.addListener(
|
|
1270
1263
|
this.id,
|
|
1271
1264
|
HMSUpdateListenerActions.ON_SPEAKER,
|
|
1272
1265
|
this.onSpeakerListener
|
|
@@ -1282,7 +1275,7 @@ export class HMSSDK {
|
|
|
1282
1275
|
// Checking if we already have RECONNECTING subscription
|
|
1283
1276
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.RECONNECTING]) {
|
|
1284
1277
|
// Adding RECONNECTING native listener
|
|
1285
|
-
const reconnectingSubscription =
|
|
1278
|
+
const reconnectingSubscription = HMSNativeEventListener.addListener(
|
|
1286
1279
|
this.id,
|
|
1287
1280
|
HMSUpdateListenerActions.RECONNECTING,
|
|
1288
1281
|
this.reconnectingListener
|
|
@@ -1298,7 +1291,7 @@ export class HMSSDK {
|
|
|
1298
1291
|
// Checking if we already have RECONNECTED subscription
|
|
1299
1292
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.RECONNECTED]) {
|
|
1300
1293
|
// Adding RECONNECTED native listener
|
|
1301
|
-
const reconnectedSubscription =
|
|
1294
|
+
const reconnectedSubscription = HMSNativeEventListener.addListener(
|
|
1302
1295
|
this.id,
|
|
1303
1296
|
HMSUpdateListenerActions.RECONNECTED,
|
|
1304
1297
|
this.reconnectedListener
|
|
@@ -1318,7 +1311,7 @@ export class HMSSDK {
|
|
|
1318
1311
|
]
|
|
1319
1312
|
) {
|
|
1320
1313
|
// Adding ON_ROLE_CHANGE_REQUEST native listener
|
|
1321
|
-
const roleChangeReqSubscription =
|
|
1314
|
+
const roleChangeReqSubscription = HMSNativeEventListener.addListener(
|
|
1322
1315
|
this.id,
|
|
1323
1316
|
HMSUpdateListenerActions.ON_ROLE_CHANGE_REQUEST,
|
|
1324
1317
|
this.onRoleChangeRequestListener
|
|
@@ -1339,7 +1332,7 @@ export class HMSSDK {
|
|
|
1339
1332
|
]
|
|
1340
1333
|
) {
|
|
1341
1334
|
// Adding ON_CHANGE_TRACK_STATE_REQUEST native listener
|
|
1342
|
-
const changeTrackReqSubscription =
|
|
1335
|
+
const changeTrackReqSubscription = HMSNativeEventListener.addListener(
|
|
1343
1336
|
this.id,
|
|
1344
1337
|
HMSUpdateListenerActions.ON_CHANGE_TRACK_STATE_REQUEST,
|
|
1345
1338
|
this.onChangeTrackStateRequestListener
|
|
@@ -1360,11 +1353,12 @@ export class HMSSDK {
|
|
|
1360
1353
|
]
|
|
1361
1354
|
) {
|
|
1362
1355
|
// Adding ON_REMOVED_FROM_ROOM native listener
|
|
1363
|
-
const removedFromRoomSubscription =
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1356
|
+
const removedFromRoomSubscription =
|
|
1357
|
+
HMSNativeEventListener.addListener(
|
|
1358
|
+
this.id,
|
|
1359
|
+
HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
|
|
1360
|
+
this.onRemovedFromRoomListener
|
|
1361
|
+
);
|
|
1368
1362
|
this.emitterSubscriptions[
|
|
1369
1363
|
HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM
|
|
1370
1364
|
] = removedFromRoomSubscription;
|
|
@@ -1377,7 +1371,7 @@ export class HMSSDK {
|
|
|
1377
1371
|
// Checking if we already have ON_RTC_STATS subscription
|
|
1378
1372
|
if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_RTC_STATS]) {
|
|
1379
1373
|
// Adding ON_RTC_STATS native listener
|
|
1380
|
-
const rtcStatsSubscription =
|
|
1374
|
+
const rtcStatsSubscription = HMSNativeEventListener.addListener(
|
|
1381
1375
|
this.id,
|
|
1382
1376
|
HMSUpdateListenerActions.ON_RTC_STATS,
|
|
1383
1377
|
this.RTCStatsListener
|
|
@@ -1397,7 +1391,7 @@ export class HMSSDK {
|
|
|
1397
1391
|
]
|
|
1398
1392
|
) {
|
|
1399
1393
|
// Adding ON_LOCAL_AUDIO_STATS native listener
|
|
1400
|
-
const lclAudioStatsSubscription =
|
|
1394
|
+
const lclAudioStatsSubscription = HMSNativeEventListener.addListener(
|
|
1401
1395
|
this.id,
|
|
1402
1396
|
HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS,
|
|
1403
1397
|
this.onLocalAudioStatsListener
|
|
@@ -1418,7 +1412,7 @@ export class HMSSDK {
|
|
|
1418
1412
|
]
|
|
1419
1413
|
) {
|
|
1420
1414
|
// Adding ON_LOCAL_VIDEO_STATS native listener
|
|
1421
|
-
const lclVideoStatsSubscription =
|
|
1415
|
+
const lclVideoStatsSubscription = HMSNativeEventListener.addListener(
|
|
1422
1416
|
this.id,
|
|
1423
1417
|
HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS,
|
|
1424
1418
|
this.onLocalVideoStatsListener
|
|
@@ -1439,7 +1433,7 @@ export class HMSSDK {
|
|
|
1439
1433
|
]
|
|
1440
1434
|
) {
|
|
1441
1435
|
// Adding ON_REMOTE_AUDIO_STATS native listener
|
|
1442
|
-
const rmAudioStatsSubscription =
|
|
1436
|
+
const rmAudioStatsSubscription = HMSNativeEventListener.addListener(
|
|
1443
1437
|
this.id,
|
|
1444
1438
|
HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS,
|
|
1445
1439
|
this.onRemoteAudioStatsListener
|
|
@@ -1460,7 +1454,7 @@ export class HMSSDK {
|
|
|
1460
1454
|
]
|
|
1461
1455
|
) {
|
|
1462
1456
|
// Adding ON_REMOTE_VIDEO_STATS native listener
|
|
1463
|
-
const rmVideoStatsSubscription =
|
|
1457
|
+
const rmVideoStatsSubscription = HMSNativeEventListener.addListener(
|
|
1464
1458
|
this.id,
|
|
1465
1459
|
HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
|
|
1466
1460
|
this.onRemoteVideoStatsListener
|
|
@@ -1481,7 +1475,7 @@ export class HMSSDK {
|
|
|
1481
1475
|
]
|
|
1482
1476
|
) {
|
|
1483
1477
|
// Adding ON_AUDIO_DEVICE_CHANGED native listener
|
|
1484
|
-
const audDeviceChgSubscription =
|
|
1478
|
+
const audDeviceChgSubscription = HMSNativeEventListener.addListener(
|
|
1485
1479
|
this.id,
|
|
1486
1480
|
HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED,
|
|
1487
1481
|
this.onAudioDeviceChangedListener
|
|
@@ -1502,11 +1496,12 @@ export class HMSSDK {
|
|
|
1502
1496
|
]
|
|
1503
1497
|
) {
|
|
1504
1498
|
// Adding ON_SESSION_STORE_AVAILABLE native listener
|
|
1505
|
-
const sessionStoreAvailableSubscription =
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1499
|
+
const sessionStoreAvailableSubscription =
|
|
1500
|
+
HMSNativeEventListener.addListener(
|
|
1501
|
+
this.id,
|
|
1502
|
+
HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE,
|
|
1503
|
+
this.onSessionStoreAvailableListener
|
|
1504
|
+
);
|
|
1510
1505
|
this.emitterSubscriptions[
|
|
1511
1506
|
HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
|
|
1512
1507
|
] = sessionStoreAvailableSubscription;
|
|
@@ -1522,7 +1517,7 @@ export class HMSSDK {
|
|
|
1522
1517
|
!this.emitterSubscriptions[HMSPIPListenerActions.ON_PIP_ROOM_LEAVE]
|
|
1523
1518
|
) {
|
|
1524
1519
|
// Adding ON_PIP_ROOM_LEAVE native listener
|
|
1525
|
-
const pipRoomLeaveSubscription =
|
|
1520
|
+
const pipRoomLeaveSubscription = HMSNativeEventListener.addListener(
|
|
1526
1521
|
this.id,
|
|
1527
1522
|
HMSPIPListenerActions.ON_PIP_ROOM_LEAVE,
|
|
1528
1523
|
this.onPIPRoomLeaveListener
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { DeviceEventEmitter } from 'react-native';
|
|
2
|
+
import type { EmitterSubscription as RNEmitterSubscription } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import HMSManager from './HMSManagerModule';
|
|
5
|
+
|
|
6
6
|
import { HMSConstants } from './HMSConstants';
|
|
7
7
|
import { getLogger } from './HMSLogger';
|
|
8
8
|
import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
|
|
9
9
|
import { EventEmitter } from '../utils';
|
|
10
10
|
import type { EmitterSubscription } from '../utils';
|
|
11
11
|
|
|
12
|
-
const { HMSManager } = NativeModules;
|
|
13
|
-
|
|
14
12
|
type Nullable<T> = T | null | undefined;
|
|
15
13
|
|
|
16
14
|
export type HMSSessionStoreValue = Nullable<string>;
|
|
@@ -148,7 +146,7 @@ export class HMSSessionStore {
|
|
|
148
146
|
// this `uniqueId` will be used to remove 'KeyChangeListener' from native side
|
|
149
147
|
const uniqueId =
|
|
150
148
|
subscriptionsToRemove.length > 0
|
|
151
|
-
? (subscriptionsToRemove[0]
|
|
149
|
+
? (subscriptionsToRemove[0]!.context as { uniqueId: string }).uniqueId
|
|
152
150
|
: null;
|
|
153
151
|
|
|
154
152
|
// Removing required subscriptions from 'eventEmitter'
|
package/src/classes/HMSTrack.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { HMSTrackSource } from './HMSTrackSource';
|
|
1
2
|
import type { HMSTrackType } from './HMSTrackType';
|
|
2
3
|
|
|
3
4
|
export class HMSTrack {
|
|
4
5
|
trackId: string;
|
|
5
|
-
source?:
|
|
6
|
+
source?: HMSTrackSource;
|
|
6
7
|
trackDescription?: string;
|
|
7
8
|
mute?: boolean;
|
|
8
9
|
id: string;
|
|
@@ -14,7 +15,7 @@ export class HMSTrack {
|
|
|
14
15
|
|
|
15
16
|
constructor(params: {
|
|
16
17
|
trackId: string;
|
|
17
|
-
source?:
|
|
18
|
+
source?: HMSTrackSource;
|
|
18
19
|
trackDescription?: string;
|
|
19
20
|
isMute?: boolean;
|
|
20
21
|
id: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HMSTrack } from './HMSTrack';
|
|
2
|
+
import type { HMSTrackSource } from './HMSTrackSource';
|
|
2
3
|
import type { HMSTrackType } from './HMSTrackType';
|
|
3
4
|
|
|
4
5
|
export class HMSVideoTrack extends HMSTrack {
|
|
@@ -6,7 +7,7 @@ export class HMSVideoTrack extends HMSTrack {
|
|
|
6
7
|
|
|
7
8
|
constructor(params: {
|
|
8
9
|
trackId: string;
|
|
9
|
-
source?:
|
|
10
|
+
source?: HMSTrackSource;
|
|
10
11
|
trackDescription?: string;
|
|
11
12
|
isMute?: boolean;
|
|
12
13
|
id: string;
|
package/src/classes/HmsView.tsx
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
requireNativeComponent,
|
|
5
5
|
StyleSheet,
|
|
6
6
|
UIManager,
|
|
7
|
-
ViewStyle,
|
|
8
7
|
Platform,
|
|
9
8
|
} from 'react-native';
|
|
9
|
+
import type { ViewStyle } from 'react-native';
|
|
10
10
|
import { HMSConstants } from './HMSConstants';
|
|
11
11
|
import { HMSVideoViewMode } from './HMSVideoViewMode';
|
|
12
12
|
|
|
@@ -89,6 +89,8 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
const capture = async () => {
|
|
92
|
+
const viewManagerConfig = UIManager.getViewManagerConfig('HMSView');
|
|
93
|
+
|
|
92
94
|
let requestId = _nextRequestId++;
|
|
93
95
|
let requestMap = _requestMap;
|
|
94
96
|
|
|
@@ -97,7 +99,7 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
|
|
|
97
99
|
let promise = new Promise(function (resolve, reject) {
|
|
98
100
|
requestMap.set(requestId, { resolve, reject });
|
|
99
101
|
});
|
|
100
|
-
|
|
102
|
+
|
|
101
103
|
UIManager.dispatchViewManagerCommand(
|
|
102
104
|
findNodeHandle(hmsViewRef.current),
|
|
103
105
|
viewManagerConfig.Commands.capture,
|
|
@@ -10,11 +10,13 @@ import {
|
|
|
10
10
|
setHMSHLSPlayerStatsError,
|
|
11
11
|
} from './hooks';
|
|
12
12
|
import {
|
|
13
|
+
RCTHMSHLSPlayer,
|
|
14
|
+
RCTHMSHLSPlayerViewManagerConfig,
|
|
15
|
+
} from './RCTHMSHLSPlayer';
|
|
16
|
+
import type {
|
|
13
17
|
HmsHlsPlaybackEventHandler,
|
|
14
18
|
HmsHlsStatsEventHandler,
|
|
15
|
-
RCTHMSHLSPlayer,
|
|
16
19
|
RCTHMSHLSPlayerRef,
|
|
17
|
-
RCTHMSHLSPlayerViewManagerConfig,
|
|
18
20
|
} from './RCTHMSHLSPlayer';
|
|
19
21
|
import {
|
|
20
22
|
HMSHLSPlayerPlaybackEventTypes,
|
|
@@ -64,7 +66,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
64
66
|
ref,
|
|
65
67
|
() => ({
|
|
66
68
|
play: (url?: string) => {
|
|
67
|
-
if (
|
|
69
|
+
if (
|
|
70
|
+
hmsHlsPlayerRef.current &&
|
|
71
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.play
|
|
72
|
+
) {
|
|
68
73
|
UIManager.dispatchViewManagerCommand(
|
|
69
74
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
70
75
|
RCTHMSHLSPlayerViewManagerConfig.Commands.play,
|
|
@@ -73,7 +78,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
73
78
|
}
|
|
74
79
|
},
|
|
75
80
|
stop: () => {
|
|
76
|
-
if (
|
|
81
|
+
if (
|
|
82
|
+
hmsHlsPlayerRef.current &&
|
|
83
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.stop
|
|
84
|
+
) {
|
|
77
85
|
UIManager.dispatchViewManagerCommand(
|
|
78
86
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
79
87
|
RCTHMSHLSPlayerViewManagerConfig.Commands.stop,
|
|
@@ -82,7 +90,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
82
90
|
}
|
|
83
91
|
},
|
|
84
92
|
pause: () => {
|
|
85
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
hmsHlsPlayerRef.current &&
|
|
95
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.pause
|
|
96
|
+
) {
|
|
86
97
|
UIManager.dispatchViewManagerCommand(
|
|
87
98
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
88
99
|
RCTHMSHLSPlayerViewManagerConfig.Commands.pause,
|
|
@@ -91,7 +102,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
91
102
|
}
|
|
92
103
|
},
|
|
93
104
|
resume: () => {
|
|
94
|
-
if (
|
|
105
|
+
if (
|
|
106
|
+
hmsHlsPlayerRef.current &&
|
|
107
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.resume
|
|
108
|
+
) {
|
|
95
109
|
UIManager.dispatchViewManagerCommand(
|
|
96
110
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
97
111
|
RCTHMSHLSPlayerViewManagerConfig.Commands.resume,
|
|
@@ -108,7 +122,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
108
122
|
);
|
|
109
123
|
}
|
|
110
124
|
|
|
111
|
-
if (
|
|
125
|
+
if (
|
|
126
|
+
hmsHlsPlayerRef.current &&
|
|
127
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.seekForward
|
|
128
|
+
) {
|
|
112
129
|
UIManager.dispatchViewManagerCommand(
|
|
113
130
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
114
131
|
RCTHMSHLSPlayerViewManagerConfig.Commands.seekForward,
|
|
@@ -125,7 +142,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
125
142
|
);
|
|
126
143
|
}
|
|
127
144
|
|
|
128
|
-
if (
|
|
145
|
+
if (
|
|
146
|
+
hmsHlsPlayerRef.current &&
|
|
147
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.seekBackward
|
|
148
|
+
) {
|
|
129
149
|
UIManager.dispatchViewManagerCommand(
|
|
130
150
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
131
151
|
RCTHMSHLSPlayerViewManagerConfig.Commands.seekBackward,
|
|
@@ -134,7 +154,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
134
154
|
}
|
|
135
155
|
},
|
|
136
156
|
seekToLivePosition: () => {
|
|
137
|
-
if (
|
|
157
|
+
if (
|
|
158
|
+
hmsHlsPlayerRef.current &&
|
|
159
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.seekToLivePosition
|
|
160
|
+
) {
|
|
138
161
|
UIManager.dispatchViewManagerCommand(
|
|
139
162
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
140
163
|
RCTHMSHLSPlayerViewManagerConfig.Commands.seekToLivePosition,
|
|
@@ -149,7 +172,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
|
|
|
149
172
|
);
|
|
150
173
|
}
|
|
151
174
|
|
|
152
|
-
if (
|
|
175
|
+
if (
|
|
176
|
+
hmsHlsPlayerRef.current &&
|
|
177
|
+
RCTHMSHLSPlayerViewManagerConfig.Commands.setVolume
|
|
178
|
+
) {
|
|
153
179
|
UIManager.dispatchViewManagerCommand(
|
|
154
180
|
findNodeHandle(hmsHlsPlayerRef.current),
|
|
155
181
|
RCTHMSHLSPlayerViewManagerConfig.Commands.setVolume,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import type { DependencyList } from 'react';
|
|
2
3
|
import { shallow } from 'zustand/shallow';
|
|
3
4
|
|
|
4
5
|
import { useHMSHLSPlayerStatsStore } from '../../stores/hls-player-stats-store';
|
|
@@ -27,7 +28,7 @@ export const useHMSHLSPlayerStats = () => {
|
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export const useHMSHLSPlayerStat = <
|
|
30
|
-
T extends keyof HMSHLSPlayerStatsUpdateEventData
|
|
31
|
+
T extends keyof HMSHLSPlayerStatsUpdateEventData,
|
|
31
32
|
>(
|
|
32
33
|
stat: T
|
|
33
34
|
) => {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { HMSConstants } from '../classes/HMSConstants';
|
|
4
|
+
import { HMSEncoder } from '../classes/HMSEncoder';
|
|
5
|
+
import { HMSEventEmitter } from '../classes/HMSEventEmitter';
|
|
6
|
+
import { getLogger } from '../classes/HMSLogger';
|
|
7
|
+
import HMSNativeEventListener from '../classes/HMSNativeEventListener';
|
|
8
|
+
import type { HMSNativeEventSubscription } from '../classes/HMSNativeEventListener';
|
|
9
|
+
import type { HMSPeer } from '../classes/HMSPeer';
|
|
10
|
+
import { HMSPeerUpdate, HMSPeerUpdateOrdinals } from '../classes/HMSPeerUpdate';
|
|
11
|
+
import { getHmsPeersCache } from '../classes/HMSPeersCache';
|
|
12
|
+
import { HMSUpdateListenerActions } from '../classes/HMSUpdateListenerActions';
|
|
13
|
+
|
|
14
|
+
const eventType = HMSUpdateListenerActions.ON_PEER_UPDATE;
|
|
15
|
+
|
|
16
|
+
// TODO: How to handle events which have already been received?
|
|
17
|
+
// TODO(DOUBT): add HMSInstance as dependency because of actions enabling/disabling events on HMSInstance?
|
|
18
|
+
export const useHMSPeerUpdates = (
|
|
19
|
+
effect: (data: { peer: HMSPeer; type: HMSPeerUpdate }) => void,
|
|
20
|
+
deps: React.DependencyList | undefined = []
|
|
21
|
+
) => {
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (HMSEventEmitter.listenerCount(eventType) <= 0) {
|
|
24
|
+
addPeerUpdateSubscription();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const subscription = HMSEventEmitter.addListener(eventType, effect, null);
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
subscription.remove();
|
|
31
|
+
|
|
32
|
+
if (HMSEventEmitter.listenerCount(eventType) <= 0) {
|
|
33
|
+
removePeerUpdateSubscription();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, deps);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let peerUpdateSubscription: HMSNativeEventSubscription | null = null;
|
|
40
|
+
|
|
41
|
+
function addPeerUpdateSubscription() {
|
|
42
|
+
if (peerUpdateSubscription !== null) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
peerUpdateSubscription = HMSNativeEventListener.addListener(
|
|
47
|
+
HMSConstants.DEFAULT_SDK_ID,
|
|
48
|
+
HMSUpdateListenerActions.ON_PEER_UPDATE,
|
|
49
|
+
(peerData: any) => {
|
|
50
|
+
const data: { peer: any; type: any } = {
|
|
51
|
+
peer: peerData,
|
|
52
|
+
type: null,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
for (const ordinal of HMSPeerUpdateOrdinals.keys()) {
|
|
56
|
+
if (ordinal in peerData) {
|
|
57
|
+
data.peer.peerID = peerData[ordinal];
|
|
58
|
+
data.type = ordinal;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const peer: HMSPeer = HMSEncoder.encodeHmsPeer(data.peer);
|
|
64
|
+
const type = HMSEncoder.encodeHmsPeerUpdate(data.type) || data.type;
|
|
65
|
+
|
|
66
|
+
getHmsPeersCache()?.updatePeerCache(data.peer.peerID, data.peer, type);
|
|
67
|
+
|
|
68
|
+
getLogger()?.verbose('#Listener ON_PEER_LISTENER_CALL', {
|
|
69
|
+
peer,
|
|
70
|
+
type,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
HMSEventEmitter.emit(eventType, { peer, type });
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function removePeerUpdateSubscription() {
|
|
79
|
+
if (peerUpdateSubscription === null) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
peerUpdateSubscription.remove();
|
|
84
|
+
peerUpdateSubscription = null;
|
|
85
|
+
}
|