@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,381 @@
1
+ import React, { useRef } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import Animated, {
4
+ Easing,
5
+ Extrapolation,
6
+ interpolate,
7
+ runOnJS,
8
+ useAnimatedStyle,
9
+ useDerivedValue,
10
+ useSharedValue,
11
+ withTiming,
12
+ } from 'react-native-reanimated';
13
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
14
+ import {
15
+ HMSHLSPlayerPlaybackState,
16
+ HMSHLSPlaylistType,
17
+ useHMSHLSPlayerPlaybackState,
18
+ useHMSHLSPlayerStat,
19
+ } from '@100mslive/react-native-hms';
20
+ import type {
21
+ HLSPlayerDurationDetails,
22
+ HMSHLSPlayer,
23
+ } from '@100mslive/react-native-hms';
24
+ import { useSelector } from 'react-redux';
25
+
26
+ import {
27
+ useHLSStreamResumePause,
28
+ useHLSViewsConstraints,
29
+ useHMSRoomStyle,
30
+ } from '../hooks-util';
31
+ import { useIsHLSStreamingOn } from '../hooks-sdk';
32
+ import type { RootState } from '../redux';
33
+
34
+ interface HLSSeekbarProps {
35
+ playerRef: React.RefObject<React.ElementRef<typeof HMSHLSPlayer>>;
36
+ onStart: () => void;
37
+ onEnd: () => void;
38
+ }
39
+
40
+ export const _HLSSeekbar: React.FC<HLSSeekbarProps> = (props) => {
41
+ const isHLSStreamingOn = useIsHLSStreamingOn();
42
+ const isDVRStream = useSelector((state: RootState) => {
43
+ return (
44
+ state.hmsStates.room?.hlsStreamingState.variants?.[0]?.playlistType ===
45
+ HMSHLSPlaylistType.DVR
46
+ );
47
+ });
48
+
49
+ if (!isHLSStreamingOn || !isDVRStream) return null;
50
+
51
+ return <_Seekbar {...props} />;
52
+ };
53
+
54
+ const _Seekbar: React.FC<HLSSeekbarProps> = React.memo(
55
+ ({ playerRef, onStart, onEnd }) => {
56
+ const { playerWrapperConstraints } = useHLSViewsConstraints();
57
+ const hlsPlayerDurationDetails = useRef<null | HLSPlayerDurationDetails>(
58
+ null
59
+ );
60
+ const prevSeekbarPositionValue = useSharedValue(0);
61
+ const seekbarPositionValue = useSharedValue(0);
62
+ const seekbarHeightValue = useSharedValue(4);
63
+ const streamStartedAt = useSelector((state: RootState) => {
64
+ return state.hmsStates.room?.hlsStreamingState.variants?.[0]?.startedAt;
65
+ });
66
+ const distanceFromLiveEdge = useHMSHLSPlayerStat('distanceFromLive');
67
+ const distanceFromLiveEdgeValue = useDerivedValue(
68
+ () => distanceFromLiveEdge,
69
+ [distanceFromLiveEdge]
70
+ );
71
+
72
+ const seekbarRoomStyle = useHMSRoomStyle((theme) => ({
73
+ backgroundColor: theme.palette.primary_default,
74
+ }));
75
+
76
+ const { isPaused, pauseStream, resumeStream } =
77
+ useHLSStreamResumePause(playerRef);
78
+
79
+ const seekToBarPosition = () => {
80
+ if (!streamStartedAt) return;
81
+ const liveStreamDuration = Date.now() - streamStartedAt.getTime();
82
+ const rollingWindowTime =
83
+ hlsPlayerDurationDetails.current?.rollingWindowTime;
84
+ const durationOfStream =
85
+ rollingWindowTime && liveStreamDuration >= rollingWindowTime
86
+ ? rollingWindowTime
87
+ : liveStreamDuration;
88
+
89
+ // console.log(
90
+ // '$$$ rolling window time > ',
91
+ // hlsPlayerDurationDetails.current?.rollingWindowTime
92
+ // );
93
+ // console.log('$$$ live stream duration > ', liveStreamDuration);
94
+ // console.log('$$$ current stream duration > ', durationOfStream);
95
+
96
+ const prevPosition = prevSeekbarPositionValue.value;
97
+ const currPosition = seekbarPositionValue.value;
98
+ const diff = currPosition - prevPosition;
99
+ const seekByMillis = (durationOfStream / 100) * Math.abs(diff);
100
+
101
+ const seekBySecs = seekByMillis / 1000;
102
+ if (diff >= 0) {
103
+ playerRef.current?.seekForward(seekBySecs);
104
+ } else {
105
+ playerRef.current?.seekBackward(seekBySecs);
106
+ }
107
+ resumeStream();
108
+ };
109
+
110
+ const activeSeekbarStyle = useAnimatedStyle(
111
+ () => ({
112
+ width: interpolate(
113
+ seekbarPositionValue.value,
114
+ [0, 100],
115
+ [0, playerWrapperConstraints.width],
116
+ {
117
+ extrapolateLeft: Extrapolation.CLAMP,
118
+ extrapolateRight: Extrapolation.CLAMP,
119
+ }
120
+ ),
121
+ height: seekbarHeightValue.value,
122
+ }),
123
+ [playerWrapperConstraints.width]
124
+ );
125
+
126
+ const activeSeekbarThumbStyle = useAnimatedStyle(
127
+ () => ({
128
+ width: seekbarHeightValue.value * 3,
129
+ height: seekbarHeightValue.value * 3,
130
+ borderRadius: (seekbarHeightValue.value * 3) / 2,
131
+ bottom: -seekbarHeightValue.value,
132
+ left: -(seekbarHeightValue.value * 3) / 2,
133
+ transform: [
134
+ {
135
+ translateX: interpolate(
136
+ seekbarPositionValue.value,
137
+ [0, 100],
138
+ [0, playerWrapperConstraints.width],
139
+ {
140
+ extrapolateLeft: Extrapolation.CLAMP,
141
+ extrapolateRight: Extrapolation.CLAMP,
142
+ }
143
+ ),
144
+ },
145
+ ],
146
+ }),
147
+ [playerWrapperConstraints.width]
148
+ );
149
+
150
+ const panGesture = Gesture.Pan()
151
+ .maxPointers(1)
152
+ .minPointers(1)
153
+ .hitSlop({ top: 12, bottom: 12 })
154
+ .onStart((e) => {
155
+ 'worklet';
156
+ onStart();
157
+ runOnJS(pauseStream)();
158
+ prevSeekbarPositionValue.value = seekbarPositionValue.value;
159
+ seekbarPositionValue.value = interpolate(
160
+ e.x,
161
+ [0, playerWrapperConstraints.width],
162
+ [0, 100],
163
+ {
164
+ extrapolateLeft: Extrapolation.CLAMP,
165
+ extrapolateRight: Extrapolation.CLAMP,
166
+ }
167
+ );
168
+ seekbarHeightValue.value = withTiming(6, {
169
+ duration: 160,
170
+ easing: Easing.linear,
171
+ });
172
+ })
173
+ .onUpdate((e) => {
174
+ 'worklet';
175
+ seekbarPositionValue.value = interpolate(
176
+ e.x,
177
+ [0, playerWrapperConstraints.width],
178
+ [0, 100],
179
+ {
180
+ extrapolateLeft: Extrapolation.CLAMP,
181
+ extrapolateRight: Extrapolation.CLAMP,
182
+ }
183
+ );
184
+ })
185
+ .onEnd(() => {
186
+ 'worklet';
187
+ onEnd();
188
+ seekbarHeightValue.value = withTiming(4, {
189
+ duration: 160,
190
+ easing: Easing.linear,
191
+ });
192
+ runOnJS(seekToBarPosition)();
193
+ });
194
+
195
+ React.useEffect(() => {
196
+ if (streamStartedAt && !isPaused) {
197
+ const intervalId = setInterval(() => {
198
+ const liveStreamDuration = Date.now() - streamStartedAt.getTime();
199
+
200
+ const rollingWindowTime =
201
+ hlsPlayerDurationDetails.current?.rollingWindowTime;
202
+
203
+ const durationOfStream =
204
+ rollingWindowTime && liveStreamDuration >= rollingWindowTime
205
+ ? rollingWindowTime
206
+ : liveStreamDuration;
207
+
208
+ // console.log(
209
+ // '$$$ rolling window time > ',
210
+ // hlsPlayerDurationDetails.current?.rollingWindowTime
211
+ // );
212
+ // console.log('$$$ live stream duration > ', liveStreamDuration);
213
+ // console.log('$$$ current stream duration > ', durationOfStream);
214
+
215
+ const currentPosition =
216
+ durationOfStream - distanceFromLiveEdgeValue.value;
217
+
218
+ // console.log('currentPosition > ', currentPosition);
219
+
220
+ seekbarPositionValue.value = interpolate(
221
+ currentPosition,
222
+ [0, durationOfStream],
223
+ [0, 100],
224
+ {
225
+ extrapolateLeft: Extrapolation.CLAMP,
226
+ extrapolateRight: Extrapolation.CLAMP,
227
+ }
228
+ );
229
+ }, 1000);
230
+
231
+ return () => {
232
+ clearInterval(intervalId);
233
+ };
234
+ }
235
+ }, [isPaused, streamStartedAt]);
236
+
237
+ let startedPlayingFirstTime = false;
238
+ let prevPlaybackState = HMSHLSPlayerPlaybackState.UNKNOWN;
239
+ const playbackState = useHMSHLSPlayerPlaybackState();
240
+
241
+ if (
242
+ prevPlaybackState === HMSHLSPlayerPlaybackState.UNKNOWN &&
243
+ playbackState === HMSHLSPlayerPlaybackState.PLAYING
244
+ ) {
245
+ prevPlaybackState = playbackState;
246
+ startedPlayingFirstTime = true;
247
+ }
248
+
249
+ React.useEffect(() => {
250
+ if (startedPlayingFirstTime && playerRef.current) {
251
+ let mounted = true;
252
+
253
+ playerRef.current
254
+ .getPlayerDurationDetails()
255
+ .then((data) => {
256
+ if (mounted) {
257
+ console.log('$$$ getPlayerDurationDetails > ', data);
258
+ hlsPlayerDurationDetails.current = data;
259
+ if (
260
+ typeof data.rollingWindowTime === 'number' &&
261
+ data.rollingWindowTime < 300000
262
+ ) {
263
+ hlsPlayerDurationDetails.current.rollingWindowTime = 300000;
264
+ }
265
+ }
266
+ })
267
+ .catch(() => {});
268
+
269
+ return () => {
270
+ mounted = false;
271
+ };
272
+ }
273
+ }, [startedPlayingFirstTime]);
274
+
275
+ return (
276
+ <GestureDetector gesture={panGesture}>
277
+ <View
278
+ collapsable={false}
279
+ hitSlop={{ top: 12, bottom: 12 }}
280
+ style={[styles.container, { width: playerWrapperConstraints.width }]}
281
+ >
282
+ <Animated.View
283
+ style={[
284
+ styles.inactiveSeekbar,
285
+ { width: playerWrapperConstraints.width },
286
+ ]}
287
+ >
288
+ <Animated.View
289
+ style={[styles.seekbar, seekbarRoomStyle, activeSeekbarStyle]}
290
+ />
291
+ <Animated.View
292
+ style={[
293
+ styles.seekbarThumb,
294
+ seekbarRoomStyle,
295
+ activeSeekbarThumbStyle,
296
+ ]}
297
+ />
298
+ </Animated.View>
299
+ </View>
300
+ </GestureDetector>
301
+ );
302
+ }
303
+ );
304
+
305
+ export const HLSSeekbar = React.memo(_HLSSeekbar);
306
+
307
+ const styles = StyleSheet.create({
308
+ container: {
309
+ height: 6,
310
+ justifyContent: 'flex-end',
311
+ },
312
+ inactiveSeekbar: {
313
+ position: 'relative',
314
+ backgroundColor: 'rgba(255, 255, 255, 0.25)',
315
+ },
316
+ seekbar: {
317
+ height: 4,
318
+ },
319
+ seekbarThumb: {
320
+ position: 'absolute',
321
+ bottom: -4,
322
+ right: 0,
323
+ zIndex: 100,
324
+ },
325
+ });
326
+
327
+ /**
328
+ *
329
+ *
330
+ *
331
+ *
332
+ *
333
+ *
334
+ *
335
+ *
336
+ *
337
+ * 200 -> 200 * 40%
338
+ *
339
+ * 180 - 33.33% = 60;
340
+ *
341
+ * currentStreamDuration * (diff in current and prev) * 100 / prev
342
+ *
343
+ * 0 |----------| 150
344
+ * prev = 135
345
+ *
346
+ * curr = 90
347
+ *
348
+ *
349
+ *
350
+ *
351
+ *
352
+ *
353
+ *
354
+ *
355
+ *
356
+ * //// 2 * 30 = 60
357
+ * 1.5 * 30 = 45
358
+ *
359
+ * 180
360
+ *
361
+ * 120
362
+ *
363
+ * 0 |------____| 100
364
+ *
365
+ *
366
+ * 200 * 40% = 80
367
+ *
368
+ * 200 * 30% = 60
369
+ *
370
+ *
371
+ * 30*90
372
+ *
373
+ * 0 |---------_| 100
374
+ * Prev = 90
375
+ * |------|
376
+ * Curr = 60
377
+ *
378
+ * 90 - 60 = 30
379
+ *
380
+ * seekbackward(80)
381
+ */
@@ -0,0 +1,97 @@
1
+ import {
2
+ HMSHLSPlaylistType,
3
+ useIsHLSStreamLive,
4
+ } from '@100mslive/react-native-hms';
5
+ import type { HMSHLSPlayer } from '@100mslive/react-native-hms';
6
+ import * as React from 'react';
7
+ import { useSelector } from 'react-redux';
8
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
9
+
10
+ import { useIsHLSStreamingOn } from '../hooks-sdk';
11
+ import type { RootState } from '../redux';
12
+ import { SeekArrowIcon } from '../Icons';
13
+ import Animated, {
14
+ Easing,
15
+ cancelAnimation,
16
+ interpolate,
17
+ runOnJS,
18
+ useAnimatedStyle,
19
+ useSharedValue,
20
+ withTiming,
21
+ } from 'react-native-reanimated';
22
+
23
+ export interface HLSSeekforwardControlProps {
24
+ playerRef: React.RefObject<React.ElementRef<typeof HMSHLSPlayer>>;
25
+ onPress?: () => void;
26
+ }
27
+
28
+ const _HLSSeekforwardControl: React.FC<HLSSeekforwardControlProps> = ({
29
+ playerRef,
30
+ onPress,
31
+ }) => {
32
+ const animatedValue = useSharedValue(0);
33
+ const isHLSStreamingOn = useIsHLSStreamingOn();
34
+ const isDVRStream = useSelector((state: RootState) => {
35
+ return (
36
+ state.hmsStates.room?.hlsStreamingState.variants?.[0]?.playlistType ===
37
+ HMSHLSPlaylistType.DVR
38
+ );
39
+ });
40
+ const isStreamLive = useIsHLSStreamLive();
41
+
42
+ const handdleSeekForward = () => {
43
+ onPress?.();
44
+ playerRef.current?.seekForward(10);
45
+ };
46
+
47
+ const tapGestureHandler = React.useMemo(() => {
48
+ return Gesture.Tap()
49
+ .enabled(!isStreamLive)
50
+ .onStart(() => {
51
+ cancelAnimation(animatedValue);
52
+ animatedValue.value = withTiming(
53
+ 1,
54
+ { duration: 200, easing: Easing.ease },
55
+ (finished) => {
56
+ if (finished) {
57
+ animatedValue.value = withTiming(0, {
58
+ duration: 100,
59
+ easing: Easing.ease,
60
+ });
61
+ }
62
+ }
63
+ );
64
+ runOnJS(handdleSeekForward)();
65
+ });
66
+ }, [isStreamLive]);
67
+
68
+ const animatedStyle = useAnimatedStyle(
69
+ () => ({
70
+ opacity: interpolate(animatedValue.value, [0, 1], [1, 0.8]),
71
+ transform: [
72
+ {
73
+ rotateZ: `${interpolate(animatedValue.value, [0, 1], [0, 17])} deg`,
74
+ },
75
+ ],
76
+ }),
77
+ []
78
+ );
79
+
80
+ if (!isHLSStreamingOn || !isDVRStream) return null;
81
+
82
+ return (
83
+ <GestureDetector gesture={tapGestureHandler}>
84
+ <Animated.View
85
+ collapsable={false}
86
+ style={[{ marginLeft: 24 }, animatedStyle]}
87
+ >
88
+ <SeekArrowIcon
89
+ style={{ opacity: isStreamLive ? 0.2 : 1 }}
90
+ type="forward"
91
+ />
92
+ </Animated.View>
93
+ </GestureDetector>
94
+ );
95
+ };
96
+
97
+ export const HLSSeekforwardControl = React.memo(_HLSSeekforwardControl);
@@ -8,7 +8,6 @@ import {
8
8
  TouchableOpacity,
9
9
  } from 'react-native';
10
10
  import type { HMSMessage } from '@100mslive/react-native-hms';
11
- import { Gesture, GestureDetector } from 'react-native-gesture-handler';
12
11
 
13
12
  import {
14
13
  useAllowBlockingPeerFromChat,
@@ -49,16 +48,14 @@ const _HMSHLSMessage: React.FC<HMSHLSMessageProps> = ({ message }) => {
49
48
  const messageSender = message.sender;
50
49
 
51
50
  const hmsRoomStyles = useHMSRoomStyleSheet(
52
- (_theme, typography) => ({
53
- senderName: {
54
- color: '#ffffff',
55
- fontFamily: `${typography.font_family}-SemiBold`,
56
- textShadowColor: 'rgba(0, 0, 0, 0.5)',
57
- },
58
- message: {
59
- color: '#ffffff',
51
+ (theme, typography) => ({
52
+ regularSurfaceHigh: {
60
53
  fontFamily: `${typography.font_family}-Regular`,
61
- textShadowColor: 'rgba(0, 0, 0, 0.5)',
54
+ color: theme.palette.on_surface_high,
55
+ },
56
+ semiBoldSurfaceLow: {
57
+ fontFamily: `${typography.font_family}-SemiBold`,
58
+ color: theme.palette.on_surface_low,
62
59
  },
63
60
  threeDots: {
64
61
  tintColor: '#ffffff',
@@ -98,36 +95,32 @@ const _HMSHLSMessage: React.FC<HMSHLSMessageProps> = ({ message }) => {
98
95
  </View>
99
96
  ) : null}
100
97
 
101
- <View style={styles.nameWrapper}>
102
- <Text
103
- style={[styles.senderName, hmsRoomStyles.senderName]}
104
- numberOfLines={1}
105
- >
106
- {messageSender
107
- ? messageSender.isLocal
108
- ? 'You'
109
- : messageSender.name
110
- : 'Anonymous'}
98
+ <View style={styles.messageWrapper}>
99
+ <Text style={[styles.message, hmsRoomStyles.regularSurfaceHigh]}>
100
+ <Text style={hmsRoomStyles.semiBoldSurfaceLow}>
101
+ {messageSender
102
+ ? messageSender.isLocal
103
+ ? 'You'
104
+ : messageSender.name
105
+ : 'Anonymous'}
106
+ {' '}
107
+ </Text>
108
+
109
+ {message.message}
111
110
  </Text>
112
111
 
113
112
  {canTakeAction ? (
114
- <GestureDetector gesture={Gesture.Tap()}>
115
- <TouchableOpacity
116
- hitSlop={styles.threeDotsHitSlop}
117
- onPress={onThreeDotsPress}
118
- >
119
- <ThreeDotsIcon
120
- stack="vertical"
121
- style={[styles.threeDots, hmsRoomStyles.threeDots]}
122
- />
123
- </TouchableOpacity>
124
- </GestureDetector>
113
+ <TouchableOpacity
114
+ hitSlop={styles.threeDotsHitSlop}
115
+ onPress={onThreeDotsPress}
116
+ >
117
+ <ThreeDotsIcon
118
+ stack="vertical"
119
+ style={[styles.threeDots, hmsRoomStyles.threeDots]}
120
+ />
121
+ </TouchableOpacity>
125
122
  ) : null}
126
123
  </View>
127
-
128
- <Text style={[styles.message, hmsRoomStyles.message]}>
129
- {message.message}
130
- </Text>
131
124
  </View>
132
125
  );
133
126
  };
@@ -136,28 +129,18 @@ export const HMSHLSMessage = React.memo(_HMSHLSMessage);
136
129
 
137
130
  const styles = StyleSheet.create({
138
131
  container: {
139
- marginTop: 8,
132
+ marginTop: 16,
140
133
  width: '100%',
141
134
  },
142
- nameWrapper: {
135
+ messageWrapper: {
136
+ flex: 1,
143
137
  flexDirection: 'row',
144
- alignItems: 'center',
145
- },
146
- senderName: {
147
- flexGrow: 1,
148
- fontSize: 14,
149
- lineHeight: Platform.OS === 'android' ? 20 : undefined,
150
- letterSpacing: 0.1,
151
- textShadowOffset: { height: 1, width: 1 },
152
- textShadowRadius: 2,
153
138
  },
154
139
  message: {
140
+ flexShrink: 1,
155
141
  fontSize: 14,
156
142
  lineHeight: Platform.OS === 'android' ? 20 : undefined,
157
143
  letterSpacing: 0.25,
158
- marginTop: 2,
159
- textShadowOffset: { height: 0.5, width: 0.5 },
160
- textShadowRadius: 2,
161
144
  },
162
145
  threeDots: {
163
146
  width: 20,
@@ -5,8 +5,8 @@ import { FlashList } from '@shopify/flash-list';
5
5
  import type { HMSMessage } from '@100mslive/react-native-hms';
6
6
 
7
7
  import type { RootState } from '../redux';
8
- import { HMSHLSMessage } from './HMSHLSMessage';
9
8
  import { useIsLandscapeOrientation } from '../utils/dimension';
9
+ import { HMSOverlayMessageView } from './HMSOverlayMessageView';
10
10
 
11
11
  export const HMSHLSMessageList: React.FC = () => {
12
12
  const { height: windowHeight } = useWindowDimensions();
@@ -19,7 +19,7 @@ export const HMSHLSMessageList: React.FC = () => {
19
19
  );
20
20
 
21
21
  const _renderItem = React.useCallback((data: { item: HMSMessage }) => {
22
- return <HMSHLSMessage message={data.item} />;
22
+ return <HMSOverlayMessageView message={data.item} />;
23
23
  }, []);
24
24
 
25
25
  if (messages.length <= 0) {