@100mslive/react-native-room-kit 1.1.6 → 1.1.7

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 (222) hide show
  1. package/lib/commonjs/Icons/Pause/assets/pause-med.png +0 -0
  2. package/lib/commonjs/Icons/Pause/assets/pause-med@2x.png +0 -0
  3. package/lib/commonjs/Icons/Pause/assets/pause-med@3x.png +0 -0
  4. package/lib/commonjs/Icons/Pause/index.js +35 -0
  5. package/lib/commonjs/Icons/Pause/index.js.map +1 -0
  6. package/lib/commonjs/Icons/Play/assets/play-med.png +0 -0
  7. package/lib/commonjs/Icons/Play/assets/play-med@2x.png +0 -0
  8. package/lib/commonjs/Icons/Play/assets/play-med@3x.png +0 -0
  9. package/lib/commonjs/Icons/Play/index.js +35 -0
  10. package/lib/commonjs/Icons/Play/index.js.map +1 -0
  11. package/lib/commonjs/Icons/SeekArrow/assets/seek-backward-arrow.png +0 -0
  12. package/lib/commonjs/Icons/SeekArrow/assets/seek-backward-arrow@2x.png +0 -0
  13. package/lib/commonjs/Icons/SeekArrow/assets/seek-backward-arrow@3x.png +0 -0
  14. package/lib/commonjs/Icons/SeekArrow/assets/seek-forward-arrow.png +0 -0
  15. package/lib/commonjs/Icons/SeekArrow/assets/seek-forward-arrow@2x.png +0 -0
  16. package/lib/commonjs/Icons/SeekArrow/assets/seek-forward-arrow@3x.png +0 -0
  17. package/lib/commonjs/Icons/SeekArrow/index.js +34 -0
  18. package/lib/commonjs/Icons/SeekArrow/index.js.map +1 -0
  19. package/lib/commonjs/Icons/index.js +33 -0
  20. package/lib/commonjs/Icons/index.js.map +1 -1
  21. package/lib/commonjs/components/HLSChatMessages.js +4 -5
  22. package/lib/commonjs/components/HLSChatMessages.js.map +1 -1
  23. package/lib/commonjs/components/HLSCloseMeetingControl.js +41 -0
  24. package/lib/commonjs/components/HLSCloseMeetingControl.js.map +1 -0
  25. package/lib/commonjs/components/HLSClosedCaptionControl.js +109 -0
  26. package/lib/commonjs/components/HLSClosedCaptionControl.js.map +1 -0
  27. package/lib/commonjs/components/HLSDistanceFromLive.js +56 -0
  28. package/lib/commonjs/components/HLSDistanceFromLive.js.map +1 -0
  29. package/lib/commonjs/components/HLSFullScreenControl.js +42 -0
  30. package/lib/commonjs/components/HLSFullScreenControl.js.map +1 -0
  31. package/lib/commonjs/components/HLSGoLiveControl.js +78 -0
  32. package/lib/commonjs/components/HLSGoLiveControl.js.map +1 -0
  33. package/lib/commonjs/components/HLSPlayPauseControl.js +62 -0
  34. package/lib/commonjs/components/HLSPlayPauseControl.js.map +1 -0
  35. package/lib/commonjs/components/HLSPlayer.js +82 -81
  36. package/lib/commonjs/components/HLSPlayer.js.map +1 -1
  37. package/lib/commonjs/components/HLSPlayerContainer.js +62 -3
  38. package/lib/commonjs/components/HLSPlayerContainer.js.map +1 -1
  39. package/lib/commonjs/components/HLSPlayerControls.js +89 -46
  40. package/lib/commonjs/components/HLSPlayerControls.js.map +1 -1
  41. package/lib/commonjs/components/HLSSeekbackwardControl.js +67 -0
  42. package/lib/commonjs/components/HLSSeekbackwardControl.js.map +1 -0
  43. package/lib/commonjs/components/HLSSeekbar.js +285 -0
  44. package/lib/commonjs/components/HLSSeekbar.js.map +1 -0
  45. package/lib/commonjs/components/HLSSeekforwardControl.js +71 -0
  46. package/lib/commonjs/components/HLSSeekforwardControl.js.map +1 -0
  47. package/lib/commonjs/components/HMSHLSMessage.js +19 -41
  48. package/lib/commonjs/components/HMSHLSMessage.js.map +1 -1
  49. package/lib/commonjs/components/HMSHLSMessageList.js +2 -2
  50. package/lib/commonjs/components/HMSHLSMessageList.js.map +1 -1
  51. package/lib/commonjs/components/HMSOverlayMessageView.js +150 -0
  52. package/lib/commonjs/components/HMSOverlayMessageView.js.map +1 -0
  53. package/lib/commonjs/components/Participants/ParticipantsList.js +4 -4
  54. package/lib/commonjs/components/Participants/ParticipantsList.js.map +1 -1
  55. package/lib/commonjs/hooks-util.js +30 -2
  56. package/lib/commonjs/hooks-util.js.map +1 -1
  57. package/lib/commonjs/redux/actionTypes.js +2 -0
  58. package/lib/commonjs/redux/actionTypes.js.map +1 -1
  59. package/lib/commonjs/redux/actions/index.js +10 -3
  60. package/lib/commonjs/redux/actions/index.js.map +1 -1
  61. package/lib/commonjs/redux/reducers/appState.js +9 -1
  62. package/lib/commonjs/redux/reducers/appState.js.map +1 -1
  63. package/lib/module/Icons/Pause/assets/pause-med.png +0 -0
  64. package/lib/module/Icons/Pause/assets/pause-med@2x.png +0 -0
  65. package/lib/module/Icons/Pause/assets/pause-med@3x.png +0 -0
  66. package/lib/module/Icons/Pause/index.js +27 -0
  67. package/lib/module/Icons/Pause/index.js.map +1 -0
  68. package/lib/module/Icons/Play/assets/play-med.png +0 -0
  69. package/lib/module/Icons/Play/assets/play-med@2x.png +0 -0
  70. package/lib/module/Icons/Play/assets/play-med@3x.png +0 -0
  71. package/lib/module/Icons/Play/index.js +27 -0
  72. package/lib/module/Icons/Play/index.js.map +1 -0
  73. package/lib/module/Icons/SeekArrow/assets/seek-backward-arrow.png +0 -0
  74. package/lib/module/Icons/SeekArrow/assets/seek-backward-arrow@2x.png +0 -0
  75. package/lib/module/Icons/SeekArrow/assets/seek-backward-arrow@3x.png +0 -0
  76. package/lib/module/Icons/SeekArrow/assets/seek-forward-arrow.png +0 -0
  77. package/lib/module/Icons/SeekArrow/assets/seek-forward-arrow@2x.png +0 -0
  78. package/lib/module/Icons/SeekArrow/assets/seek-forward-arrow@3x.png +0 -0
  79. package/lib/module/Icons/SeekArrow/index.js +26 -0
  80. package/lib/module/Icons/SeekArrow/index.js.map +1 -0
  81. package/lib/module/Icons/index.js +3 -0
  82. package/lib/module/Icons/index.js.map +1 -1
  83. package/lib/module/components/HLSChatMessages.js +5 -6
  84. package/lib/module/components/HLSChatMessages.js.map +1 -1
  85. package/lib/module/components/HLSCloseMeetingControl.js +33 -0
  86. package/lib/module/components/HLSCloseMeetingControl.js.map +1 -0
  87. package/lib/module/components/HLSClosedCaptionControl.js +100 -0
  88. package/lib/module/components/HLSClosedCaptionControl.js.map +1 -0
  89. package/lib/module/components/HLSDistanceFromLive.js +48 -0
  90. package/lib/module/components/HLSDistanceFromLive.js.map +1 -0
  91. package/lib/module/components/HLSFullScreenControl.js +34 -0
  92. package/lib/module/components/HLSFullScreenControl.js.map +1 -0
  93. package/lib/module/components/HLSGoLiveControl.js +70 -0
  94. package/lib/module/components/HLSGoLiveControl.js.map +1 -0
  95. package/lib/module/components/HLSPlayPauseControl.js +54 -0
  96. package/lib/module/components/HLSPlayPauseControl.js.map +1 -0
  97. package/lib/module/components/HLSPlayer.js +83 -81
  98. package/lib/module/components/HLSPlayer.js.map +1 -1
  99. package/lib/module/components/HLSPlayerContainer.js +62 -3
  100. package/lib/module/components/HLSPlayerContainer.js.map +1 -1
  101. package/lib/module/components/HLSPlayerControls.js +89 -50
  102. package/lib/module/components/HLSPlayerControls.js.map +1 -1
  103. package/lib/module/components/HLSSeekbackwardControl.js +59 -0
  104. package/lib/module/components/HLSSeekbackwardControl.js.map +1 -0
  105. package/lib/module/components/HLSSeekbar.js +276 -0
  106. package/lib/module/components/HLSSeekbar.js.map +1 -0
  107. package/lib/module/components/HLSSeekforwardControl.js +63 -0
  108. package/lib/module/components/HLSSeekforwardControl.js.map +1 -0
  109. package/lib/module/components/HMSHLSMessage.js +19 -41
  110. package/lib/module/components/HMSHLSMessage.js.map +1 -1
  111. package/lib/module/components/HMSHLSMessageList.js +2 -2
  112. package/lib/module/components/HMSHLSMessageList.js.map +1 -1
  113. package/lib/module/components/HMSOverlayMessageView.js +142 -0
  114. package/lib/module/components/HMSOverlayMessageView.js.map +1 -0
  115. package/lib/module/components/Participants/ParticipantsList.js +4 -4
  116. package/lib/module/components/Participants/ParticipantsList.js.map +1 -1
  117. package/lib/module/hooks-util.js +30 -3
  118. package/lib/module/hooks-util.js.map +1 -1
  119. package/lib/module/redux/actionTypes.js +2 -0
  120. package/lib/module/redux/actionTypes.js.map +1 -1
  121. package/lib/module/redux/actions/index.js +6 -0
  122. package/lib/module/redux/actions/index.js.map +1 -1
  123. package/lib/module/redux/reducers/appState.js +9 -1
  124. package/lib/module/redux/reducers/appState.js.map +1 -1
  125. package/lib/typescript/Icons/Pause/index.d.ts +8 -0
  126. package/lib/typescript/Icons/Pause/index.d.ts.map +1 -0
  127. package/lib/typescript/Icons/Play/index.d.ts +8 -0
  128. package/lib/typescript/Icons/Play/index.d.ts.map +1 -0
  129. package/lib/typescript/Icons/SeekArrow/index.d.ts +8 -0
  130. package/lib/typescript/Icons/SeekArrow/index.d.ts.map +1 -0
  131. package/lib/typescript/Icons/index.d.ts +3 -0
  132. package/lib/typescript/Icons/index.d.ts.map +1 -1
  133. package/lib/typescript/components/CustomButton.d.ts +5 -5
  134. package/lib/typescript/components/CustomButton.d.ts.map +1 -1
  135. package/lib/typescript/components/HLSChatMessages.d.ts.map +1 -1
  136. package/lib/typescript/components/HLSCloseMeetingControl.d.ts +8 -0
  137. package/lib/typescript/components/HLSCloseMeetingControl.d.ts.map +1 -0
  138. package/lib/typescript/components/HLSClosedCaptionControl.d.ts +10 -0
  139. package/lib/typescript/components/HLSClosedCaptionControl.d.ts.map +1 -0
  140. package/lib/typescript/components/HLSDistanceFromLive.d.ts +8 -0
  141. package/lib/typescript/components/HLSDistanceFromLive.d.ts.map +1 -0
  142. package/lib/typescript/components/HLSFullScreenControl.d.ts +8 -0
  143. package/lib/typescript/components/HLSFullScreenControl.d.ts.map +1 -0
  144. package/lib/typescript/components/HLSGoLiveControl.d.ts +10 -0
  145. package/lib/typescript/components/HLSGoLiveControl.d.ts.map +1 -0
  146. package/lib/typescript/components/HLSPlayPauseControl.d.ts +8 -0
  147. package/lib/typescript/components/HLSPlayPauseControl.d.ts.map +1 -0
  148. package/lib/typescript/components/HLSPlayer.d.ts +4 -2
  149. package/lib/typescript/components/HLSPlayer.d.ts.map +1 -1
  150. package/lib/typescript/components/HLSPlayerContainer.d.ts.map +1 -1
  151. package/lib/typescript/components/HLSPlayerControls.d.ts +12 -2
  152. package/lib/typescript/components/HLSPlayerControls.d.ts.map +1 -1
  153. package/lib/typescript/components/HLSSeekbackwardControl.d.ts +8 -0
  154. package/lib/typescript/components/HLSSeekbackwardControl.d.ts.map +1 -0
  155. package/lib/typescript/components/HLSSeekbar.d.ts +66 -0
  156. package/lib/typescript/components/HLSSeekbar.d.ts.map +1 -0
  157. package/lib/typescript/components/HLSSeekforwardControl.d.ts +8 -0
  158. package/lib/typescript/components/HLSSeekforwardControl.d.ts.map +1 -0
  159. package/lib/typescript/components/HMSHLSMessage.d.ts.map +1 -1
  160. package/lib/typescript/components/HMSOverlayMessageView.d.ts +8 -0
  161. package/lib/typescript/components/HMSOverlayMessageView.d.ts.map +1 -0
  162. package/lib/typescript/components/Modals.d.ts +3 -3
  163. package/lib/typescript/components/Modals.d.ts.map +1 -1
  164. package/lib/typescript/components/Participants/ParticipantsList.d.ts.map +1 -1
  165. package/lib/typescript/components/Preview.d.ts.map +1 -1
  166. package/lib/typescript/hooks-util.d.ts +12 -7
  167. package/lib/typescript/hooks-util.d.ts.map +1 -1
  168. package/lib/typescript/redux/actionTypes.d.ts +1 -0
  169. package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
  170. package/lib/typescript/redux/actions/index.d.ts +6 -0
  171. package/lib/typescript/redux/actions/index.d.ts.map +1 -1
  172. package/lib/typescript/redux/index.d.ts +17 -16
  173. package/lib/typescript/redux/index.d.ts.map +1 -1
  174. package/lib/typescript/redux/reducers/appState.d.ts +1 -0
  175. package/lib/typescript/redux/reducers/appState.d.ts.map +1 -1
  176. package/lib/typescript/redux/reducers/index.d.ts +17 -16
  177. package/lib/typescript/redux/reducers/index.d.ts.map +1 -1
  178. package/package.json +2 -2
  179. package/src/Icons/Pause/assets/pause-med.png +0 -0
  180. package/src/Icons/Pause/assets/pause-med@2x.png +0 -0
  181. package/src/Icons/Pause/assets/pause-med@3x.png +0 -0
  182. package/src/Icons/Pause/index.tsx +36 -0
  183. package/src/Icons/Play/assets/play-med.png +0 -0
  184. package/src/Icons/Play/assets/play-med@2x.png +0 -0
  185. package/src/Icons/Play/assets/play-med@3x.png +0 -0
  186. package/src/Icons/Play/index.tsx +36 -0
  187. package/src/Icons/SeekArrow/assets/seek-backward-arrow.png +0 -0
  188. package/src/Icons/SeekArrow/assets/seek-backward-arrow@2x.png +0 -0
  189. package/src/Icons/SeekArrow/assets/seek-backward-arrow@3x.png +0 -0
  190. package/src/Icons/SeekArrow/assets/seek-forward-arrow.png +0 -0
  191. package/src/Icons/SeekArrow/assets/seek-forward-arrow@2x.png +0 -0
  192. package/src/Icons/SeekArrow/assets/seek-forward-arrow@3x.png +0 -0
  193. package/src/Icons/SeekArrow/index.tsx +40 -0
  194. package/src/Icons/index.ts +3 -0
  195. package/src/components/HLSChatMessages.tsx +4 -6
  196. package/src/components/HLSCloseMeetingControl.tsx +39 -0
  197. package/src/components/HLSClosedCaptionControl.tsx +140 -0
  198. package/src/components/HLSDistanceFromLive.tsx +69 -0
  199. package/src/components/HLSFullScreenControl.tsx +46 -0
  200. package/src/components/HLSGoLiveControl.tsx +104 -0
  201. package/src/components/HLSPlayPauseControl.tsx +69 -0
  202. package/src/components/HLSPlayer.tsx +98 -88
  203. package/src/components/HLSPlayerContainer.tsx +81 -14
  204. package/src/components/HLSPlayerControls.tsx +137 -58
  205. package/src/components/HLSSeekbackwardControl.tsx +88 -0
  206. package/src/components/HLSSeekbar.tsx +381 -0
  207. package/src/components/HLSSeekforwardControl.tsx +97 -0
  208. package/src/components/HMSHLSMessage.tsx +32 -49
  209. package/src/components/HMSHLSMessageList.tsx +2 -2
  210. package/src/components/HMSOverlayMessageView.tsx +189 -0
  211. package/src/components/Participants/ParticipantsList.tsx +12 -10
  212. package/src/hooks-util.ts +39 -1
  213. package/src/redux/actionTypes.ts +3 -0
  214. package/src/redux/actions/index.ts +5 -0
  215. package/src/redux/reducers/appState.ts +8 -0
  216. package/lib/commonjs/components/CustomHLSPlayerControls.js +0 -80
  217. package/lib/commonjs/components/CustomHLSPlayerControls.js.map +0 -1
  218. package/lib/module/components/CustomHLSPlayerControls.js +0 -72
  219. package/lib/module/components/CustomHLSPlayerControls.js.map +0 -1
  220. package/lib/typescript/components/CustomHLSPlayerControls.d.ts +0 -7
  221. package/lib/typescript/components/CustomHLSPlayerControls.d.ts.map +0 -1
  222. package/src/components/CustomHLSPlayerControls.tsx +0 -92
@@ -0,0 +1,140 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import { StyleSheet, TouchableOpacity } from 'react-native';
3
+ import { useSelector } from 'react-redux';
4
+ import {
5
+ useHMSHLSPlayerPlaybackState,
6
+ HMSHLSPlayerPlaybackState,
7
+ } from '@100mslive/react-native-hms';
8
+ import type { HMSHLSPlayer } from '@100mslive/react-native-hms';
9
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
10
+
11
+ import { CCIcon } from '../Icons';
12
+ import type { RootState } from '../redux';
13
+ import { useIsHLSStreamingOn } from '../hooks-sdk';
14
+
15
+ interface HLSClosedCaptionControlProps {
16
+ playerRef: React.RefObject<React.ElementRef<typeof HMSHLSPlayer>>;
17
+ onPress?: () => void;
18
+ }
19
+
20
+ export const _HLSClosedCaptionControl: React.FC<
21
+ HLSClosedCaptionControlProps
22
+ > = ({ playerRef, onPress }) => {
23
+ const isHLSStreamingOn = useIsHLSStreamingOn();
24
+ const isStreamUrlPresent = useSelector(
25
+ (state: RootState) =>
26
+ !!state.hmsStates.room?.hlsStreamingState.variants?.[0]?.hlsStreamUrl
27
+ );
28
+
29
+ let startedPlayingFirstTimeRef = useRef(false);
30
+ let prevPlaybackStateRef = useRef(HMSHLSPlayerPlaybackState.UNKNOWN);
31
+ const playbackState = useHMSHLSPlayerPlaybackState();
32
+
33
+ if (
34
+ prevPlaybackStateRef.current === HMSHLSPlayerPlaybackState.UNKNOWN &&
35
+ playbackState === HMSHLSPlayerPlaybackState.PLAYING
36
+ ) {
37
+ prevPlaybackStateRef.current = playbackState;
38
+ startedPlayingFirstTimeRef.current = true;
39
+ }
40
+
41
+ const [isCCSupported, setIsCCSupported] = useState(false);
42
+ const [isCCEnabled, setIsCCEnabled] = useState(true);
43
+
44
+ const handleCCBtnPress = () => {
45
+ if (!isCCSupported || !playerRef.current) {
46
+ return;
47
+ }
48
+ onPress?.();
49
+ if (isCCEnabled) {
50
+ playerRef.current.disableClosedCaption();
51
+ setIsCCEnabled(false);
52
+ } else {
53
+ playerRef.current.enableClosedCaption();
54
+ setIsCCEnabled(true);
55
+ }
56
+ };
57
+
58
+ React.useEffect(() => {
59
+ if (
60
+ isHLSStreamingOn &&
61
+ isStreamUrlPresent &&
62
+ startedPlayingFirstTimeRef.current &&
63
+ playerRef.current
64
+ ) {
65
+ let mounted = true;
66
+
67
+ playerRef.current
68
+ .isClosedCaptionSupported()
69
+ .then((supported) => {
70
+ if (mounted) {
71
+ setIsCCSupported(supported);
72
+ }
73
+ })
74
+ .catch(() => {});
75
+ playerRef.current
76
+ .isClosedCaptionEnabled()
77
+ .then((enabled) => {
78
+ if (mounted) {
79
+ setIsCCEnabled(enabled);
80
+ }
81
+ })
82
+ .catch(() => {});
83
+
84
+ return () => {
85
+ mounted = false;
86
+ };
87
+ }
88
+ }, [
89
+ isHLSStreamingOn,
90
+ isStreamUrlPresent,
91
+ startedPlayingFirstTimeRef.current,
92
+ ]);
93
+
94
+ if (!isCCSupported) {
95
+ return null;
96
+ }
97
+
98
+ return (
99
+ <GestureDetector gesture={Gesture.Tap()}>
100
+ <TouchableOpacity
101
+ onPress={handleCCBtnPress}
102
+ style={[styles.icon, styles.gap]}
103
+ >
104
+ <CCIcon size="medium" enabled={isCCEnabled} />
105
+ </TouchableOpacity>
106
+ </GestureDetector>
107
+ );
108
+ };
109
+
110
+ export const HLSClosedCaptionControl = React.memo(_HLSClosedCaptionControl);
111
+
112
+ const styles = StyleSheet.create({
113
+ detectorContainer: {
114
+ position: 'absolute',
115
+ width: '100%',
116
+ height: '100%',
117
+ zIndex: 5,
118
+ },
119
+ container: {
120
+ flex: 1,
121
+ justifyContent: 'space-between',
122
+ },
123
+ controlsRow: {
124
+ flexDirection: 'row',
125
+ alignItems: 'center',
126
+ justifyContent: 'space-between',
127
+ marginHorizontal: 8,
128
+ },
129
+ normalRow: {
130
+ flexDirection: 'row',
131
+ alignItems: 'center',
132
+ },
133
+ icon: {
134
+ padding: 4,
135
+ alignSelf: 'flex-start',
136
+ },
137
+ gap: {
138
+ marginLeft: 16,
139
+ },
140
+ });
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { Platform, StyleSheet, Text } from 'react-native';
3
+ import {
4
+ HMSHLSPlaylistType,
5
+ useHMSHLSPlayerStat,
6
+ useIsHLSStreamLive,
7
+ } from '@100mslive/react-native-hms';
8
+ import { useSelector } from 'react-redux';
9
+
10
+ import { useHMSRoomStyle } from '../hooks-util';
11
+ import { useIsHLSStreamingOn } from '../hooks-sdk';
12
+ import type { RootState } from '../redux';
13
+
14
+ interface HLSDistanceFromLiveProps {}
15
+
16
+ export const _HLSDistanceFromLive: React.FC<HLSDistanceFromLiveProps> = () => {
17
+ const isHLSStreamingOn = useIsHLSStreamingOn();
18
+ const isDVRStream = useSelector(
19
+ (state: RootState) =>
20
+ state.hmsStates.room?.hlsStreamingState.variants?.[0]?.playlistType ===
21
+ HMSHLSPlaylistType.DVR
22
+ );
23
+ const isStreamLive = useIsHLSStreamLive();
24
+
25
+ if (!isHLSStreamingOn || !isDVRStream || isStreamLive) return null;
26
+
27
+ return <HLSDistanceFromLiveText />;
28
+ };
29
+
30
+ export const HLSDistanceFromLiveText = React.memo(() => {
31
+ const distanceFromLiveEdge = useHMSHLSPlayerStat('distanceFromLive');
32
+
33
+ const textStyle = useHMSRoomStyle((_, typography) => ({
34
+ fontFamily: `${typography.font_family}-Regular`,
35
+ color: '#ffffff',
36
+ }));
37
+
38
+ const hhmmss = msToHMS(
39
+ distanceFromLiveEdge - Platform.select({ default: 10000, ios: 1000 })
40
+ );
41
+
42
+ return <Text style={[styles.text, textStyle]}>-{hhmmss}</Text>;
43
+ });
44
+
45
+ export const HLSDistanceFromLive = React.memo(_HLSDistanceFromLive);
46
+
47
+ const styles = StyleSheet.create({
48
+ text: {
49
+ fontSize: 16,
50
+ lineHeight: 24,
51
+ letterSpacing: 0.5,
52
+ marginLeft: 8,
53
+ },
54
+ });
55
+
56
+ function msToHMS(ms: number) {
57
+ const seconds = Math.floor((ms / 1000) % 60);
58
+ const minutes = Math.floor((ms / 1000 / 60) % 60);
59
+ const hours = Math.floor((ms / 1000 / 3600) % 24);
60
+
61
+ const humanized = [
62
+ minutes > 0 ? minutes.toString().padStart(2, '0') : '0',
63
+ seconds.toString().padStart(2, '0'),
64
+ ];
65
+
66
+ if (hours > 0) humanized.unshift(hours.toString().padStart(2, '0'));
67
+
68
+ return humanized.join(':');
69
+ }
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { StyleSheet, TouchableOpacity } from 'react-native';
3
+ import { useDispatch, useSelector } from 'react-redux';
4
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
5
+
6
+ import { MaximizeIcon, MinimizeIcon } from '../Icons';
7
+ import type { RootState } from '../redux';
8
+ import { setHlsFullScreen } from '../redux/actions';
9
+
10
+ interface HLSFullScreenControlProps {
11
+ onPress?: () => void;
12
+ }
13
+
14
+ export const _HLSFullScreenControl: React.FC<HLSFullScreenControlProps> = ({
15
+ onPress,
16
+ }) => {
17
+ const dispatch = useDispatch();
18
+ const hlsFullScreen = useSelector(
19
+ (state: RootState) => state.app.hlsFullScreen
20
+ );
21
+ const toggleFullScreen = () => {
22
+ onPress?.();
23
+ dispatch(setHlsFullScreen(!hlsFullScreen));
24
+ };
25
+
26
+ return (
27
+ <GestureDetector gesture={Gesture.Tap()}>
28
+ <TouchableOpacity onPress={toggleFullScreen} style={styles.icon}>
29
+ {hlsFullScreen ? (
30
+ <MinimizeIcon size="medium" />
31
+ ) : (
32
+ <MaximizeIcon size="medium" />
33
+ )}
34
+ </TouchableOpacity>
35
+ </GestureDetector>
36
+ );
37
+ };
38
+
39
+ export const HLSFullScreenControl = React.memo(_HLSFullScreenControl);
40
+
41
+ const styles = StyleSheet.create({
42
+ icon: {
43
+ padding: 4,
44
+ alignSelf: 'flex-start',
45
+ },
46
+ });
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';
3
+ import { useSelector } from 'react-redux';
4
+ import {
5
+ HMSHLSPlaylistType,
6
+ useIsHLSStreamLive,
7
+ } from '@100mslive/react-native-hms';
8
+ import type { HMSHLSPlayer } from '@100mslive/react-native-hms';
9
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
10
+
11
+ import { useHMSRoomStyleSheet } from '../hooks-util';
12
+ import { useIsHLSStreamingOn } from '../hooks-sdk';
13
+ import type { RootState } from '../redux';
14
+
15
+ interface HLSGoLiveControlProps {
16
+ playerRef: React.RefObject<React.ElementRef<typeof HMSHLSPlayer>>;
17
+ onPress?: () => void;
18
+ }
19
+
20
+ export const _HLSGoLiveControl: React.FC<HLSGoLiveControlProps> = ({
21
+ playerRef,
22
+ onPress,
23
+ }) => {
24
+ const isHLSStreamingOn = useIsHLSStreamingOn();
25
+ const isDVRStream = useSelector(
26
+ (state: RootState) =>
27
+ state.hmsStates.room?.hlsStreamingState.variants?.[0]?.playlistType ===
28
+ HMSHLSPlaylistType.DVR
29
+ );
30
+ const isStreamLive = useIsHLSStreamLive();
31
+
32
+ const handleGoLivePress = () => {
33
+ onPress?.();
34
+ playerRef.current?.seekToLivePosition();
35
+ };
36
+
37
+ const hmsRoomStyles = useHMSRoomStyleSheet(
38
+ (theme, typography) => ({
39
+ semiBoldSurfaceHigh: {
40
+ fontFamily: `${typography.font_family}-SemiBold`,
41
+ color: theme.palette.on_surface_high,
42
+ },
43
+ semiBoldSurfaceMedium: {
44
+ fontFamily: `${typography.font_family}-SemiBold`,
45
+ color: theme.palette.on_surface_medium,
46
+ },
47
+ liveIndicatorDot: {
48
+ backgroundColor: theme.palette.alert_error_default,
49
+ },
50
+ notLiveIndicatorDot: {
51
+ backgroundColor: theme.palette.on_surface_low,
52
+ },
53
+ }),
54
+ []
55
+ );
56
+
57
+ if (!isHLSStreamingOn || !isDVRStream) return null;
58
+
59
+ return (
60
+ <GestureDetector gesture={Gesture.Tap()}>
61
+ <TouchableOpacity onPress={handleGoLivePress} style={styles.liveButton}>
62
+ <View
63
+ style={[
64
+ styles.liveIndicatorDot,
65
+ isStreamLive
66
+ ? hmsRoomStyles.liveIndicatorDot
67
+ : hmsRoomStyles.notLiveIndicatorDot,
68
+ ]}
69
+ />
70
+ <Text
71
+ style={[
72
+ styles.liveText,
73
+ isStreamLive
74
+ ? hmsRoomStyles.semiBoldSurfaceHigh
75
+ : hmsRoomStyles.semiBoldSurfaceMedium,
76
+ ]}
77
+ >
78
+ {isStreamLive ? 'LIVE' : 'GO LIVE'}
79
+ </Text>
80
+ </TouchableOpacity>
81
+ </GestureDetector>
82
+ );
83
+ };
84
+
85
+ export const HLSGoLiveControl = React.memo(_HLSGoLiveControl);
86
+
87
+ const styles = StyleSheet.create({
88
+ liveButton: {
89
+ padding: 4,
90
+ alignItems: 'center',
91
+ flexDirection: 'row',
92
+ },
93
+ liveIndicatorDot: {
94
+ width: 8,
95
+ height: 8,
96
+ borderRadius: 4,
97
+ marginRight: 8,
98
+ },
99
+ liveText: {
100
+ fontSize: 16,
101
+ lineHeight: 24,
102
+ letterSpacing: 0.5,
103
+ },
104
+ });
@@ -0,0 +1,69 @@
1
+ import { HMSHLSPlaylistType } from '@100mslive/react-native-hms';
2
+ import type { HMSHLSPlayer } from '@100mslive/react-native-hms';
3
+ import * as React from 'react';
4
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
5
+ import { useSelector } from 'react-redux';
6
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
7
+
8
+ import { useIsHLSStreamingOn } from '../hooks-sdk';
9
+ import type { RootState } from '../redux';
10
+ import { PauseIcon, PlayIcon } from '../Icons';
11
+ import { useHLSStreamResumePause } from '../hooks-util';
12
+
13
+ export interface HLSPlayPauseControlProps {
14
+ playerRef: React.RefObject<React.ElementRef<typeof HMSHLSPlayer>>;
15
+ onPress?: () => void;
16
+ }
17
+
18
+ const _HLSPlayPauseControl: React.FC<HLSPlayPauseControlProps> = ({
19
+ playerRef,
20
+ onPress,
21
+ }) => {
22
+ const isHLSStreamingOn = useIsHLSStreamingOn();
23
+ const isDVRStream = useSelector((state: RootState) => {
24
+ return (
25
+ state.hmsStates.room?.hlsStreamingState.variants?.[0]?.playlistType ===
26
+ HMSHLSPlaylistType.DVR
27
+ );
28
+ });
29
+
30
+ const { isPaused, pauseStream, resumeStream } =
31
+ useHLSStreamResumePause(playerRef);
32
+
33
+ const togglePlayPause = () => {
34
+ onPress?.();
35
+ if (isPaused) {
36
+ resumeStream();
37
+ } else {
38
+ pauseStream();
39
+ }
40
+ };
41
+
42
+ if (!isHLSStreamingOn || !isDVRStream) return null;
43
+
44
+ return (
45
+ <GestureDetector gesture={Gesture.Tap()}>
46
+ <TouchableOpacity
47
+ onPress={togglePlayPause}
48
+ style={{ alignSelf: 'center' }}
49
+ >
50
+ <View style={styles.container}>
51
+ {isPaused ? <PlayIcon /> : <PauseIcon />}
52
+ </View>
53
+ </TouchableOpacity>
54
+ </GestureDetector>
55
+ );
56
+ };
57
+
58
+ export const HLSPlayPauseControl = React.memo(_HLSPlayPauseControl);
59
+
60
+ const styles = StyleSheet.create({
61
+ container: {
62
+ width: 64,
63
+ height: 64,
64
+ borderRadius: 32,
65
+ alignItems: 'center',
66
+ justifyContent: 'center',
67
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
68
+ },
69
+ });
@@ -1,6 +1,5 @@
1
- import React, { useRef } from 'react';
2
- import type { ComponentRef } from 'react';
3
- import { useDispatch, useSelector } from 'react-redux';
1
+ import React from 'react';
2
+ import { useSelector } from 'react-redux';
4
3
  import {
5
4
  View,
6
5
  Text,
@@ -12,96 +11,53 @@ import {
12
11
  HMSHLSPlayer,
13
12
  HMSHLSPlayerPlaybackState,
14
13
  useHMSHLSPlayerPlaybackState,
14
+ useHMSHLSPlayerSubtitles,
15
15
  } from '@100mslive/react-native-hms';
16
16
 
17
17
  import type { RootState } from '../redux';
18
- import { changeShowHLSStats } from '../redux/actions';
19
- import { HLSPlayerStatsView } from './HLSPlayerStatsView';
18
+ // import { changeShowHLSStats } from '../redux/actions';
19
+ // import { HLSPlayerStatsView } from './HLSPlayerStatsView';
20
20
  import { HLSPlayerEmoticons } from './HLSPlayerEmoticons';
21
- import { CustomControls } from './CustomHLSPlayerControls';
22
21
  import { COLORS, hexToRgbA } from '../utils/theme';
23
22
  import { HMSHLSNotStarted } from './HMSHLSNotStarted';
24
23
  import { CrossCircleIcon } from '../Icons';
25
24
  import {
26
25
  useHLSPlayerConstraints,
26
+ useHLSViewsConstraints,
27
27
  useHMSRoomColorPalette,
28
28
  useHMSRoomStyleSheet,
29
29
  } from '../hooks-util';
30
30
  import { useIsHLSStreamingOn } from '../hooks-sdk';
31
+ import { HMSPinchGesture } from './PeerVideoTile/HMSPinchGesture';
31
32
 
32
- export const _HLSPlayer: React.FC = () => {
33
- const dispatch = useDispatch();
33
+ export interface HLSPlayerProps {}
34
+
35
+ export const _HLSPlayer = React.forwardRef<
36
+ React.ElementRef<typeof HMSHLSPlayer>,
37
+ HLSPlayerProps
38
+ >((_props, hlsPlayerRef) => {
39
+ // const dispatch = useDispatch();
34
40
  const isHLSStreaming = useIsHLSStreamingOn();
35
41
  const isStreamUrlPresent = useSelector(
36
42
  (state: RootState) =>
37
43
  !!state.hmsStates.room?.hlsStreamingState.variants?.[0]?.hlsStreamUrl
38
44
  );
39
- const hmsHlsPlayerRef = useRef<ComponentRef<typeof HMSHLSPlayer>>(null);
40
- const showHLSStats = useSelector(
41
- (state: RootState) => state.app.joinConfig.showHLSStats
42
- );
43
- const showCustomHLSPlayerControls = useSelector(
44
- (state: RootState) => state.app.joinConfig.showCustomHLSPlayerControls
45
- );
45
+ // const showHLSStats = useSelector(
46
+ // (state: RootState) => state.app.joinConfig.showHLSStats
47
+ // );
48
+ // const showCustomHLSPlayerControls = useSelector(
49
+ // (state: RootState) => state.app.joinConfig.showCustomHLSPlayerControls
50
+ // );
46
51
  const enableHLSPlayerControls = useSelector(
47
52
  (state: RootState) => state.app.joinConfig.enableHLSPlayerControls
48
53
  );
49
54
 
50
- const handleClosePress = () => {
51
- dispatch(changeShowHLSStats(false));
52
- };
53
-
54
- const hlsPlayerActions = <
55
- T extends
56
- | 'play'
57
- | 'stop'
58
- | 'pause'
59
- | 'resume'
60
- | 'seekForward'
61
- | 'seekBackward'
62
- | 'seekToLive'
63
- | 'setVolume',
64
- >(
65
- action: T,
66
- ...args: any[]
67
- ) => {
68
- switch (action) {
69
- case 'play': {
70
- hmsHlsPlayerRef.current?.play(args[0]);
71
- break;
72
- }
73
- case 'stop': {
74
- hmsHlsPlayerRef.current?.stop();
75
- break;
76
- }
77
- case 'pause': {
78
- hmsHlsPlayerRef.current?.pause();
79
- break;
80
- }
81
- case 'resume': {
82
- hmsHlsPlayerRef.current?.resume();
83
- break;
84
- }
85
- case 'seekForward': {
86
- hmsHlsPlayerRef.current?.seekForward(args[0]);
87
- break;
88
- }
89
- case 'seekBackward': {
90
- hmsHlsPlayerRef.current?.seekBackward(args[0]);
91
- break;
92
- }
93
- case 'seekToLive': {
94
- hmsHlsPlayerRef.current?.seekToLivePosition();
95
- break;
96
- }
97
- case 'setVolume': {
98
- hmsHlsPlayerRef.current?.setVolume(args[0]);
99
- break;
100
- }
101
- }
102
- };
55
+ // const handleClosePress = () => {
56
+ // dispatch(changeShowHLSStats(false));
57
+ // };
103
58
 
104
59
  const hlsPlayerConstraints = useHLSPlayerConstraints();
60
+ const { playerWrapperConstraints } = useHLSViewsConstraints();
105
61
  const [playerKey, setPlayerKey] = React.useState(1);
106
62
 
107
63
  const prevReconnectingRef = React.useRef<null | boolean>(null);
@@ -111,6 +67,8 @@ export const _HLSPlayer: React.FC = () => {
111
67
 
112
68
  const hlsPlayerPlaybackState = useHMSHLSPlayerPlaybackState();
113
69
 
70
+ const subtitles = useHMSHLSPlayerSubtitles();
71
+
114
72
  const isPlaybackFailed =
115
73
  hlsPlayerPlaybackState === HMSHLSPlayerPlaybackState.FAILED;
116
74
 
@@ -147,6 +105,10 @@ export const _HLSPlayer: React.FC = () => {
147
105
  color: theme.palette.alert_warning,
148
106
  fontFamily: `${typography.font_family}-SemiBold`,
149
107
  },
108
+ semiboldWhite: {
109
+ fontFamily: `${typography.font_family}-SemiBold`,
110
+ color: '#ffffff',
111
+ },
150
112
  }));
151
113
 
152
114
  const { primary_bright: PrimaryBrightColor } = useHMSRoomColorPalette();
@@ -164,26 +126,50 @@ export const _HLSPlayer: React.FC = () => {
164
126
 
165
127
  return (
166
128
  <>
167
- <HMSHLSPlayer
168
- key={playerKey}
169
- ref={hmsHlsPlayerRef}
170
- enableStats={showHLSStats}
171
- enableControls={enableHLSPlayerControls}
172
- style={{
173
- width: hlsPlayerConstraints.width,
174
- height: hlsPlayerConstraints.height,
175
- }}
176
- />
129
+ <View style={styles.container}>
130
+ <View
131
+ style={[
132
+ styles.playerAndCaptionWrapper,
133
+ {
134
+ width: playerWrapperConstraints.width,
135
+ height: hlsPlayerConstraints.height,
136
+ },
137
+ ]}
138
+ >
139
+ <HMSPinchGesture>
140
+ <View pointerEvents="none" style={styles.playerContainer}>
141
+ <HMSHLSPlayer
142
+ key={playerKey}
143
+ ref={hlsPlayerRef}
144
+ enableStats={true}
145
+ enableControls={enableHLSPlayerControls}
146
+ containerStyle={styles.playerContainer}
147
+ style={{
148
+ width: hlsPlayerConstraints.width,
149
+ height: hlsPlayerConstraints.height,
150
+ }}
151
+ />
152
+ </View>
153
+ </HMSPinchGesture>
154
+
155
+ <View
156
+ style={[
157
+ { width: playerWrapperConstraints.width - 48, left: 24 },
158
+ styles.closedCaptionsContainer,
159
+ ]}
160
+ >
161
+ <Text style={[styles.closedCaptions, hmsRoomStyles.semiboldWhite]}>
162
+ {subtitles}
163
+ </Text>
164
+ </View>
165
+ </View>
166
+ </View>
177
167
 
178
168
  <HLSPlayerEmoticons />
179
169
 
180
- {showHLSStats ? (
170
+ {/* {showHLSStats ? (
181
171
  <HLSPlayerStatsView onClosePress={handleClosePress} />
182
- ) : null}
183
-
184
- {showCustomHLSPlayerControls ? (
185
- <CustomControls handleControlPress={hlsPlayerActions} />
186
- ) : null}
172
+ ) : null} */}
187
173
 
188
174
  {isPlayerBuffering ? (
189
175
  <View
@@ -212,17 +198,25 @@ export const _HLSPlayer: React.FC = () => {
212
198
  ) : null}
213
199
  </>
214
200
  );
215
- };
201
+ });
216
202
 
217
203
  export const HLSPlayer = React.memo(_HLSPlayer);
218
204
 
219
205
  const styles = StyleSheet.create({
220
- hlsView: {
206
+ container: {
221
207
  flex: 1,
208
+ alignItems: 'center',
209
+ justifyContent: 'center',
222
210
  },
223
- hlsPlayerContainer: {
224
- // flex: 1,
211
+ playerAndCaptionWrapper: {
225
212
  position: 'relative',
213
+ alignItems: 'center',
214
+ justifyContent: 'center',
215
+ },
216
+ playerContainer: {
217
+ flex: undefined,
218
+ alignItems: 'flex-start',
219
+ justifyContent: 'flex-start',
226
220
  },
227
221
  textContainer: {
228
222
  flex: 1,
@@ -236,6 +230,22 @@ const styles = StyleSheet.create({
236
230
  letterSpacing: 0.25,
237
231
  textAlign: 'center',
238
232
  },
233
+ closedCaptionsContainer: {
234
+ position: 'absolute',
235
+ bottom: 4,
236
+ paddingHorizontal: 8,
237
+ paddingVertical: 4,
238
+ alignItems: 'center',
239
+ justifyContent: 'center',
240
+ },
241
+ closedCaptions: {
242
+ fontSize: 14,
243
+ lineHeight: 16,
244
+ textAlign: 'center',
245
+ textShadowColor: 'rgba(0, 0, 0, 0.8)',
246
+ textShadowRadius: 3,
247
+ textShadowOffset: { width: 1, height: 1 },
248
+ },
239
249
  playbackFailedContainer: {
240
250
  flex: 1,
241
251
  width: '100%',