@stream-io/video-react-native-sdk 0.1.9 → 0.1.11

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 (230) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +5 -4
  3. package/dist/commonjs/components/Call/CallContent/CallContent.js +1 -1
  4. package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
  5. package/dist/commonjs/components/Livestream/HostLivestream/HostLivestream.js +71 -0
  6. package/dist/commonjs/components/Livestream/HostLivestream/HostLivestream.js.map +1 -0
  7. package/dist/commonjs/components/Livestream/HostLivestream/index.js +17 -0
  8. package/dist/commonjs/components/Livestream/HostLivestream/index.js.map +1 -0
  9. package/dist/commonjs/components/Livestream/LivestreamControls/HostLivestreamControls.js +69 -0
  10. package/dist/commonjs/components/Livestream/LivestreamControls/HostLivestreamControls.js.map +1 -0
  11. package/dist/commonjs/components/Livestream/LivestreamControls/HostStartStreamButton.js +113 -0
  12. package/dist/commonjs/components/Livestream/LivestreamControls/HostStartStreamButton.js.map +1 -0
  13. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js +70 -0
  14. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js.map +1 -0
  15. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamMediaControls.js +38 -0
  16. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamMediaControls.js.map +1 -0
  17. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js +70 -0
  18. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js.map +1 -0
  19. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js +83 -0
  20. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js.map +1 -0
  21. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLivestreamControls.js +64 -0
  22. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLivestreamControls.js.map +1 -0
  23. package/dist/commonjs/components/Livestream/LivestreamControls/index.js +61 -0
  24. package/dist/commonjs/components/Livestream/LivestreamControls/index.js.map +1 -0
  25. package/dist/commonjs/components/Livestream/LivestreamLayout/LivestreamLayout.js +65 -0
  26. package/dist/commonjs/components/Livestream/LivestreamLayout/LivestreamLayout.js.map +1 -0
  27. package/dist/commonjs/components/Livestream/LivestreamLayout/index.js +17 -0
  28. package/dist/commonjs/components/Livestream/LivestreamLayout/index.js.map +1 -0
  29. package/dist/commonjs/components/Livestream/LivestreamTopView/DurationBadge.js +144 -0
  30. package/dist/commonjs/components/Livestream/LivestreamTopView/DurationBadge.js.map +1 -0
  31. package/dist/commonjs/components/Livestream/LivestreamTopView/FollowerCount.js +71 -0
  32. package/dist/commonjs/components/Livestream/LivestreamTopView/FollowerCount.js.map +1 -0
  33. package/dist/commonjs/components/Livestream/LivestreamTopView/HostLivestreamTopView.js +87 -0
  34. package/dist/commonjs/components/Livestream/LivestreamTopView/HostLivestreamTopView.js.map +1 -0
  35. package/dist/commonjs/components/Livestream/LivestreamTopView/LiveIndicator.js +55 -0
  36. package/dist/commonjs/components/Livestream/LivestreamTopView/LiveIndicator.js.map +1 -0
  37. package/dist/commonjs/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js +80 -0
  38. package/dist/commonjs/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js.map +1 -0
  39. package/dist/commonjs/components/Livestream/LivestreamTopView/index.js +50 -0
  40. package/dist/commonjs/components/Livestream/LivestreamTopView/index.js.map +1 -0
  41. package/dist/commonjs/components/Livestream/ViewerLivestream/ViewerLivestream.js +88 -0
  42. package/dist/commonjs/components/Livestream/ViewerLivestream/ViewerLivestream.js.map +1 -0
  43. package/dist/commonjs/components/Livestream/ViewerLivestream/index.js +17 -0
  44. package/dist/commonjs/components/Livestream/ViewerLivestream/index.js.map +1 -0
  45. package/dist/commonjs/components/Livestream/index.js +61 -0
  46. package/dist/commonjs/components/Livestream/index.js.map +1 -0
  47. package/dist/commonjs/components/index.js +11 -0
  48. package/dist/commonjs/components/index.js.map +1 -1
  49. package/dist/commonjs/hooks/usePaginatedLayoutSortPreset.js +26 -0
  50. package/dist/commonjs/hooks/usePaginatedLayoutSortPreset.js.map +1 -0
  51. package/dist/commonjs/icons/EndStreamIcon.js +20 -0
  52. package/dist/commonjs/icons/EndStreamIcon.js.map +1 -0
  53. package/dist/commonjs/icons/Eye.js +20 -0
  54. package/dist/commonjs/icons/Eye.js.map +1 -0
  55. package/dist/commonjs/icons/LeaveStreamIcon.js +20 -0
  56. package/dist/commonjs/icons/LeaveStreamIcon.js.map +1 -0
  57. package/dist/commonjs/icons/ShieldBadge.js +20 -0
  58. package/dist/commonjs/icons/ShieldBadge.js.map +1 -0
  59. package/dist/commonjs/icons/StartStreamIcon.js +20 -0
  60. package/dist/commonjs/icons/StartStreamIcon.js.map +1 -0
  61. package/dist/commonjs/icons/index.js +55 -0
  62. package/dist/commonjs/icons/index.js.map +1 -1
  63. package/dist/commonjs/theme/theme.js +70 -0
  64. package/dist/commonjs/theme/theme.js.map +1 -1
  65. package/dist/commonjs/translations/en.json +6 -1
  66. package/dist/commonjs/version.js +1 -1
  67. package/dist/commonjs/version.js.map +1 -1
  68. package/dist/module/components/Call/CallContent/CallContent.js +1 -1
  69. package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
  70. package/dist/module/components/Livestream/HostLivestream/HostLivestream.js +64 -0
  71. package/dist/module/components/Livestream/HostLivestream/HostLivestream.js.map +1 -0
  72. package/dist/module/components/Livestream/HostLivestream/index.js +2 -0
  73. package/dist/module/components/Livestream/HostLivestream/index.js.map +1 -0
  74. package/dist/module/components/Livestream/LivestreamControls/HostLivestreamControls.js +62 -0
  75. package/dist/module/components/Livestream/LivestreamControls/HostLivestreamControls.js.map +1 -0
  76. package/dist/module/components/Livestream/LivestreamControls/HostStartStreamButton.js +105 -0
  77. package/dist/module/components/Livestream/LivestreamControls/HostStartStreamButton.js.map +1 -0
  78. package/dist/module/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js +63 -0
  79. package/dist/module/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js.map +1 -0
  80. package/dist/module/components/Livestream/LivestreamControls/LivestreamMediaControls.js +31 -0
  81. package/dist/module/components/Livestream/LivestreamControls/LivestreamMediaControls.js.map +1 -0
  82. package/dist/module/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js +63 -0
  83. package/dist/module/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js.map +1 -0
  84. package/dist/module/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js +75 -0
  85. package/dist/module/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js.map +1 -0
  86. package/dist/module/components/Livestream/LivestreamControls/ViewerLivestreamControls.js +57 -0
  87. package/dist/module/components/Livestream/LivestreamControls/ViewerLivestreamControls.js.map +1 -0
  88. package/dist/module/components/Livestream/LivestreamControls/index.js +6 -0
  89. package/dist/module/components/Livestream/LivestreamControls/index.js.map +1 -0
  90. package/dist/module/components/Livestream/LivestreamLayout/LivestreamLayout.js +58 -0
  91. package/dist/module/components/Livestream/LivestreamLayout/LivestreamLayout.js.map +1 -0
  92. package/dist/module/components/Livestream/LivestreamLayout/index.js +2 -0
  93. package/dist/module/components/Livestream/LivestreamLayout/index.js.map +1 -0
  94. package/dist/module/components/Livestream/LivestreamTopView/DurationBadge.js +136 -0
  95. package/dist/module/components/Livestream/LivestreamTopView/DurationBadge.js.map +1 -0
  96. package/dist/module/components/Livestream/LivestreamTopView/FollowerCount.js +64 -0
  97. package/dist/module/components/Livestream/LivestreamTopView/FollowerCount.js.map +1 -0
  98. package/dist/module/components/Livestream/LivestreamTopView/HostLivestreamTopView.js +80 -0
  99. package/dist/module/components/Livestream/LivestreamTopView/HostLivestreamTopView.js.map +1 -0
  100. package/dist/module/components/Livestream/LivestreamTopView/LiveIndicator.js +48 -0
  101. package/dist/module/components/Livestream/LivestreamTopView/LiveIndicator.js.map +1 -0
  102. package/dist/module/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js +73 -0
  103. package/dist/module/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js.map +1 -0
  104. package/dist/module/components/Livestream/LivestreamTopView/index.js +5 -0
  105. package/dist/module/components/Livestream/LivestreamTopView/index.js.map +1 -0
  106. package/dist/module/components/Livestream/ViewerLivestream/ViewerLivestream.js +81 -0
  107. package/dist/module/components/Livestream/ViewerLivestream/ViewerLivestream.js.map +1 -0
  108. package/dist/module/components/Livestream/ViewerLivestream/index.js +2 -0
  109. package/dist/module/components/Livestream/ViewerLivestream/index.js.map +1 -0
  110. package/dist/module/components/Livestream/index.js +6 -0
  111. package/dist/module/components/Livestream/index.js.map +1 -0
  112. package/dist/module/components/index.js +1 -0
  113. package/dist/module/components/index.js.map +1 -1
  114. package/dist/module/hooks/usePaginatedLayoutSortPreset.js +19 -0
  115. package/dist/module/hooks/usePaginatedLayoutSortPreset.js.map +1 -0
  116. package/dist/module/icons/EndStreamIcon.js +12 -0
  117. package/dist/module/icons/EndStreamIcon.js.map +1 -0
  118. package/dist/module/icons/Eye.js +12 -0
  119. package/dist/module/icons/Eye.js.map +1 -0
  120. package/dist/module/icons/LeaveStreamIcon.js +12 -0
  121. package/dist/module/icons/LeaveStreamIcon.js.map +1 -0
  122. package/dist/module/icons/ShieldBadge.js +12 -0
  123. package/dist/module/icons/ShieldBadge.js.map +1 -0
  124. package/dist/module/icons/StartStreamIcon.js +12 -0
  125. package/dist/module/icons/StartStreamIcon.js.map +1 -0
  126. package/dist/module/icons/index.js +5 -0
  127. package/dist/module/icons/index.js.map +1 -1
  128. package/dist/module/theme/theme.js +70 -0
  129. package/dist/module/theme/theme.js.map +1 -1
  130. package/dist/module/translations/en.json +6 -1
  131. package/dist/module/version.js +1 -1
  132. package/dist/module/version.js.map +1 -1
  133. package/dist/typescript/components/Livestream/HostLivestream/HostLivestream.d.ts +30 -0
  134. package/dist/typescript/components/Livestream/HostLivestream/HostLivestream.d.ts.map +1 -0
  135. package/dist/typescript/components/Livestream/HostLivestream/index.d.ts +2 -0
  136. package/dist/typescript/components/Livestream/HostLivestream/index.d.ts.map +1 -0
  137. package/dist/typescript/components/Livestream/LivestreamControls/HostLivestreamControls.d.ts +25 -0
  138. package/dist/typescript/components/Livestream/LivestreamControls/HostLivestreamControls.d.ts.map +1 -0
  139. package/dist/typescript/components/Livestream/LivestreamControls/HostStartStreamButton.d.ts +25 -0
  140. package/dist/typescript/components/Livestream/LivestreamControls/HostStartStreamButton.d.ts.map +1 -0
  141. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamAudioControlButton.d.ts +6 -0
  142. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamAudioControlButton.d.ts.map +1 -0
  143. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamMediaControls.d.ts +10 -0
  144. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamMediaControls.d.ts.map +1 -0
  145. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamVideoControlButton.d.ts +6 -0
  146. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamVideoControlButton.d.ts.map +1 -0
  147. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.d.ts +16 -0
  148. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.d.ts.map +1 -0
  149. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLivestreamControls.d.ts +16 -0
  150. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLivestreamControls.d.ts.map +1 -0
  151. package/dist/typescript/components/Livestream/LivestreamControls/index.d.ts +6 -0
  152. package/dist/typescript/components/Livestream/LivestreamControls/index.d.ts.map +1 -0
  153. package/dist/typescript/components/Livestream/LivestreamLayout/LivestreamLayout.d.ts +17 -0
  154. package/dist/typescript/components/Livestream/LivestreamLayout/LivestreamLayout.d.ts.map +1 -0
  155. package/dist/typescript/components/Livestream/LivestreamLayout/index.d.ts +2 -0
  156. package/dist/typescript/components/Livestream/LivestreamLayout/index.d.ts.map +1 -0
  157. package/dist/typescript/components/Livestream/LivestreamTopView/DurationBadge.d.ts +12 -0
  158. package/dist/typescript/components/Livestream/LivestreamTopView/DurationBadge.d.ts.map +1 -0
  159. package/dist/typescript/components/Livestream/LivestreamTopView/FollowerCount.d.ts +10 -0
  160. package/dist/typescript/components/Livestream/LivestreamTopView/FollowerCount.d.ts.map +1 -0
  161. package/dist/typescript/components/Livestream/LivestreamTopView/HostLivestreamTopView.d.ts +26 -0
  162. package/dist/typescript/components/Livestream/LivestreamTopView/HostLivestreamTopView.d.ts.map +1 -0
  163. package/dist/typescript/components/Livestream/LivestreamTopView/LiveIndicator.d.ts +10 -0
  164. package/dist/typescript/components/Livestream/LivestreamTopView/LiveIndicator.d.ts.map +1 -0
  165. package/dist/typescript/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.d.ts +26 -0
  166. package/dist/typescript/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.d.ts.map +1 -0
  167. package/dist/typescript/components/Livestream/LivestreamTopView/index.d.ts +5 -0
  168. package/dist/typescript/components/Livestream/LivestreamTopView/index.d.ts.map +1 -0
  169. package/dist/typescript/components/Livestream/ViewerLivestream/ViewerLivestream.d.ts +32 -0
  170. package/dist/typescript/components/Livestream/ViewerLivestream/ViewerLivestream.d.ts.map +1 -0
  171. package/dist/typescript/components/Livestream/ViewerLivestream/index.d.ts +2 -0
  172. package/dist/typescript/components/Livestream/ViewerLivestream/index.d.ts.map +1 -0
  173. package/dist/typescript/components/Livestream/index.d.ts +6 -0
  174. package/dist/typescript/components/Livestream/index.d.ts.map +1 -0
  175. package/dist/typescript/components/index.d.ts +1 -0
  176. package/dist/typescript/components/index.d.ts.map +1 -1
  177. package/dist/typescript/hooks/usePaginatedLayoutSortPreset.d.ts +3 -0
  178. package/dist/typescript/hooks/usePaginatedLayoutSortPreset.d.ts.map +1 -0
  179. package/dist/typescript/icons/EndStreamIcon.d.ts +3 -0
  180. package/dist/typescript/icons/EndStreamIcon.d.ts.map +1 -0
  181. package/dist/typescript/icons/Eye.d.ts +3 -0
  182. package/dist/typescript/icons/Eye.d.ts.map +1 -0
  183. package/dist/typescript/icons/LeaveStreamIcon.d.ts +3 -0
  184. package/dist/typescript/icons/LeaveStreamIcon.d.ts.map +1 -0
  185. package/dist/typescript/icons/ShieldBadge.d.ts +3 -0
  186. package/dist/typescript/icons/ShieldBadge.d.ts.map +1 -0
  187. package/dist/typescript/icons/StartStreamIcon.d.ts +3 -0
  188. package/dist/typescript/icons/StartStreamIcon.d.ts.map +1 -0
  189. package/dist/typescript/icons/index.d.ts +5 -0
  190. package/dist/typescript/icons/index.d.ts.map +1 -1
  191. package/dist/typescript/theme/theme.d.ts +70 -0
  192. package/dist/typescript/theme/theme.d.ts.map +1 -1
  193. package/dist/typescript/translations/index.d.ts +6 -1
  194. package/dist/typescript/translations/index.d.ts.map +1 -1
  195. package/dist/typescript/version.d.ts +1 -1
  196. package/dist/typescript/version.d.ts.map +1 -1
  197. package/package.json +3 -3
  198. package/src/components/Call/CallContent/CallContent.tsx +1 -1
  199. package/src/components/Livestream/HostLivestream/HostLivestream.tsx +99 -0
  200. package/src/components/Livestream/HostLivestream/index.ts +1 -0
  201. package/src/components/Livestream/LivestreamControls/HostLivestreamControls.tsx +87 -0
  202. package/src/components/Livestream/LivestreamControls/HostStartStreamButton.tsx +163 -0
  203. package/src/components/Livestream/LivestreamControls/LivestreamAudioControlButton.tsx +78 -0
  204. package/src/components/Livestream/LivestreamControls/LivestreamMediaControls.tsx +32 -0
  205. package/src/components/Livestream/LivestreamControls/LivestreamVideoControlButton.tsx +78 -0
  206. package/src/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.tsx +102 -0
  207. package/src/components/Livestream/LivestreamControls/ViewerLivestreamControls.tsx +75 -0
  208. package/src/components/Livestream/LivestreamControls/index.ts +5 -0
  209. package/src/components/Livestream/LivestreamLayout/LivestreamLayout.tsx +77 -0
  210. package/src/components/Livestream/LivestreamLayout/index.ts +1 -0
  211. package/src/components/Livestream/LivestreamTopView/DurationBadge.tsx +170 -0
  212. package/src/components/Livestream/LivestreamTopView/FollowerCount.tsx +74 -0
  213. package/src/components/Livestream/LivestreamTopView/HostLivestreamTopView.tsx +105 -0
  214. package/src/components/Livestream/LivestreamTopView/LiveIndicator.tsx +53 -0
  215. package/src/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.tsx +102 -0
  216. package/src/components/Livestream/LivestreamTopView/index.ts +4 -0
  217. package/src/components/Livestream/ViewerLivestream/ViewerLivestream.tsx +126 -0
  218. package/src/components/Livestream/ViewerLivestream/index.ts +1 -0
  219. package/src/components/Livestream/index.ts +5 -0
  220. package/src/components/index.ts +1 -0
  221. package/src/hooks/usePaginatedLayoutSortPreset.ts +27 -0
  222. package/src/icons/EndStreamIcon.tsx +13 -0
  223. package/src/icons/Eye.tsx +13 -0
  224. package/src/icons/LeaveStreamIcon.tsx +13 -0
  225. package/src/icons/ShieldBadge.tsx +13 -0
  226. package/src/icons/StartStreamIcon.tsx +13 -0
  227. package/src/icons/index.tsx +5 -0
  228. package/src/theme/theme.ts +140 -0
  229. package/src/translations/en.json +6 -1
  230. package/src/version.ts +1 -1
@@ -0,0 +1,99 @@
1
+ import React from 'react';
2
+ import { StyleSheet, SafeAreaView } from 'react-native';
3
+ import { useTheme } from '../../../contexts';
4
+ import { useIncallManager } from '../../../hooks';
5
+ import {
6
+ HostLivestreamTopView as DefaultHostLivestreamTopView,
7
+ HostLivestreamTopViewProps,
8
+ } from '../LivestreamTopView/HostLivestreamTopView';
9
+ import {
10
+ HostLivestreamControls as DefaultHostLivestreamControls,
11
+ HostLivestreamControlsProps,
12
+ } from '../LivestreamControls/HostLivestreamControls';
13
+ import {
14
+ LivestreamLayout as DefaultLivestreamLayout,
15
+ LivestreamLayoutProps,
16
+ } from '../LivestreamLayout';
17
+
18
+ /**
19
+ * Props for the HostLivestream component.
20
+ */
21
+ export type HostLivestreamProps = HostLivestreamTopViewProps &
22
+ HostLivestreamControlsProps & {
23
+ /**
24
+ * Component to customize the top view at the host's live stream.
25
+ */
26
+ HostLivestreamTopView?: React.ComponentType<HostLivestreamTopViewProps> | null;
27
+ /**
28
+ * Component to customize the live stream video layout.
29
+ */
30
+ LivestreamLayout?: React.ComponentType<LivestreamLayoutProps> | null;
31
+ /**
32
+ * Component to customize the bottom view controls at the host's live stream.
33
+ */
34
+ HostLivestreamControls?: React.ComponentType<HostLivestreamControlsProps> | null;
35
+ /**
36
+ * Enable HTTP live streaming
37
+ */
38
+ hls?: boolean;
39
+ };
40
+
41
+ /**
42
+ * The HostLivestream component displays the UI for the Host's live stream.
43
+ */
44
+ export const HostLivestream = ({
45
+ HostLivestreamTopView = DefaultHostLivestreamTopView,
46
+ HostLivestreamControls = DefaultHostLivestreamControls,
47
+ LivestreamLayout = DefaultLivestreamLayout,
48
+ LiveIndicator,
49
+ FollowerCount,
50
+ DurationBadge,
51
+ HostStartStreamButton,
52
+ LivestreamMediaControls,
53
+ onEndStreamHandler,
54
+ onStartStreamHandler,
55
+ hls = false,
56
+ }: HostLivestreamProps) => {
57
+ const {
58
+ theme: { colors, hostLivestream },
59
+ } = useTheme();
60
+
61
+ // Automatically route audio to speaker devices as relevant for watching videos.
62
+ useIncallManager({ media: 'video', auto: true });
63
+
64
+ const topViewProps: HostLivestreamTopViewProps = {
65
+ LiveIndicator,
66
+ FollowerCount,
67
+ DurationBadge,
68
+ };
69
+
70
+ return (
71
+ <SafeAreaView
72
+ style={[
73
+ styles.container,
74
+ {
75
+ backgroundColor: colors.static_grey,
76
+ },
77
+ hostLivestream.container,
78
+ ]}
79
+ >
80
+ {HostLivestreamTopView && <HostLivestreamTopView {...topViewProps} />}
81
+ {LivestreamLayout && <LivestreamLayout />}
82
+ {HostLivestreamControls && (
83
+ <HostLivestreamControls
84
+ onEndStreamHandler={onEndStreamHandler}
85
+ onStartStreamHandler={onStartStreamHandler}
86
+ HostStartStreamButton={HostStartStreamButton}
87
+ LivestreamMediaControls={LivestreamMediaControls}
88
+ hls={hls}
89
+ />
90
+ )}
91
+ </SafeAreaView>
92
+ );
93
+ };
94
+
95
+ const styles = StyleSheet.create({
96
+ container: {
97
+ flex: 1,
98
+ },
99
+ });
@@ -0,0 +1 @@
1
+ export * from './HostLivestream';
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import {
4
+ HostStartStreamButton as DefaultHostStartStreamButton,
5
+ HostStartStreamButtonProps,
6
+ } from './HostStartStreamButton';
7
+ import {
8
+ LivestreamMediaControls as DefaultLivestreamMediaControls,
9
+ LivestreamMediaControlsProps,
10
+ } from './LivestreamMediaControls';
11
+ import { useTheme } from '../../../contexts';
12
+ import { Z_INDEX } from '../../../constants';
13
+
14
+ /**
15
+ * Props for the HostLivestreamControls component.
16
+ */
17
+ export type HostLivestreamControlsProps = HostStartStreamButtonProps & {
18
+ /**
19
+ * Component to customize the host's start/end live stream button.
20
+ */
21
+ HostStartStreamButton?: React.ComponentType<HostStartStreamButtonProps> | null;
22
+ /**
23
+ * Component to customize the host's media control(audio/video) buttons.
24
+ */
25
+ LivestreamMediaControls?: React.ComponentType<LivestreamMediaControlsProps> | null;
26
+ /**
27
+ * Enable HTTP live streaming
28
+ */
29
+ hls?: boolean;
30
+ };
31
+
32
+ /**
33
+ * The HostLivestreamControls component displays the call controls for the live stream at host's end.
34
+ */
35
+ export const HostLivestreamControls = ({
36
+ HostStartStreamButton = DefaultHostStartStreamButton,
37
+ LivestreamMediaControls = DefaultLivestreamMediaControls,
38
+ onEndStreamHandler,
39
+ onStartStreamHandler,
40
+ hls = false,
41
+ }: HostLivestreamControlsProps) => {
42
+ const {
43
+ theme: { colors, hostLivestreamControls },
44
+ } = useTheme();
45
+ return (
46
+ <View
47
+ style={[
48
+ styles.container,
49
+ { backgroundColor: colors.static_overlay },
50
+ hostLivestreamControls.container,
51
+ ]}
52
+ >
53
+ <View style={[styles.leftElement, hostLivestreamControls.leftElement]}>
54
+ {HostStartStreamButton && (
55
+ <HostStartStreamButton
56
+ onEndStreamHandler={onEndStreamHandler}
57
+ onStartStreamHandler={onStartStreamHandler}
58
+ hls={hls}
59
+ />
60
+ )}
61
+ </View>
62
+ <View style={[styles.rightElement, hostLivestreamControls.rightElement]}>
63
+ {LivestreamMediaControls && <LivestreamMediaControls />}
64
+ </View>
65
+ </View>
66
+ );
67
+ };
68
+
69
+ const styles = StyleSheet.create({
70
+ container: {
71
+ position: 'absolute',
72
+ bottom: 0,
73
+ flexDirection: 'row',
74
+ alignItems: 'center',
75
+ paddingVertical: 16,
76
+ paddingHorizontal: 8,
77
+ zIndex: Z_INDEX.IN_FRONT,
78
+ },
79
+ leftElement: {
80
+ flex: 1,
81
+ alignItems: 'flex-start',
82
+ },
83
+ rightElement: {
84
+ flex: 1,
85
+ alignItems: 'flex-end',
86
+ },
87
+ });
@@ -0,0 +1,163 @@
1
+ import {
2
+ useCall,
3
+ useCallStateHooks,
4
+ useI18n,
5
+ } from '@stream-io/video-react-bindings';
6
+ import React, { useState } from 'react';
7
+ import {
8
+ ActivityIndicator,
9
+ Pressable,
10
+ StyleSheet,
11
+ Text,
12
+ View,
13
+ } from 'react-native';
14
+ import { useTheme } from '../../../contexts';
15
+ import { EndBroadcastIcon, StartStreamIcon } from '../../../icons';
16
+
17
+ /**
18
+ * Props for the HostStartStreamButton component.
19
+ */
20
+ export type HostStartStreamButtonProps = {
21
+ /**
22
+ * Handler to be called when the Start Stream button is pressed.
23
+ * @returns void
24
+ */
25
+ onStartStreamHandler?: () => void;
26
+ /**
27
+ * Handler to be called when the End Stream button is pressed.
28
+ * @returns void
29
+ */
30
+ onEndStreamHandler?: () => void;
31
+ /**
32
+ * Enable HTTP live streaming
33
+ */
34
+ hls?: boolean;
35
+ };
36
+
37
+ /**
38
+ * The HostStartStreamButton component displays and controls the start and end of the host's live stream.
39
+ */
40
+ export const HostStartStreamButton = ({
41
+ onEndStreamHandler,
42
+ onStartStreamHandler,
43
+ hls,
44
+ }: HostStartStreamButtonProps) => {
45
+ const [isAwaitingResponse, setIsAwaitingResponse] = useState(false);
46
+ const { useIsCallLive, useIsCallBroadcastingInProgress } =
47
+ useCallStateHooks();
48
+ const {
49
+ theme: {
50
+ colors,
51
+ variants: { iconSizes },
52
+ typefaces,
53
+ hostStartStreamButton,
54
+ },
55
+ } = useTheme();
56
+
57
+ const call = useCall();
58
+ const isCallLive = useIsCallLive();
59
+ const isCallBroadcasting = useIsCallBroadcastingInProgress();
60
+ const { t } = useI18n();
61
+
62
+ const liveOrBroadcasting = isCallLive || isCallBroadcasting;
63
+
64
+ const onStartStreamButtonPress = async () => {
65
+ if (onStartStreamHandler) {
66
+ onStartStreamHandler();
67
+ return;
68
+ }
69
+ try {
70
+ setIsAwaitingResponse(true);
71
+ await call?.goLive();
72
+ if (hls) {
73
+ await call?.startHLS();
74
+ }
75
+ setIsAwaitingResponse(false);
76
+ } catch (error) {
77
+ console.error('Error starting livestream', error);
78
+ }
79
+ };
80
+
81
+ const onEndStreamButtonPress = async () => {
82
+ if (onEndStreamHandler) {
83
+ onEndStreamHandler();
84
+ return;
85
+ }
86
+ try {
87
+ setIsAwaitingResponse(true);
88
+ if (hls) {
89
+ await call?.stopHLS();
90
+ } else {
91
+ await call?.stopLive();
92
+ }
93
+
94
+ setIsAwaitingResponse(false);
95
+ } catch (error) {
96
+ console.error('Error stopping livestream', error);
97
+ }
98
+ };
99
+
100
+ return (
101
+ <Pressable
102
+ disabled={isAwaitingResponse}
103
+ style={[
104
+ styles.container,
105
+ {
106
+ backgroundColor: isAwaitingResponse
107
+ ? colors.dark_gray
108
+ : liveOrBroadcasting
109
+ ? colors.error
110
+ : colors.primary,
111
+ },
112
+ hostStartStreamButton.container,
113
+ ]}
114
+ onPress={
115
+ liveOrBroadcasting ? onEndStreamButtonPress : onStartStreamButtonPress
116
+ }
117
+ >
118
+ <View
119
+ style={[
120
+ styles.icon,
121
+ { height: iconSizes.xs, width: iconSizes.xs },
122
+ hostStartStreamButton.icon,
123
+ ]}
124
+ >
125
+ {isAwaitingResponse ? (
126
+ <ActivityIndicator />
127
+ ) : liveOrBroadcasting ? (
128
+ <EndBroadcastIcon />
129
+ ) : (
130
+ <StartStreamIcon />
131
+ )}
132
+ </View>
133
+ <Text
134
+ style={[
135
+ styles.text,
136
+ typefaces.subtitleBold,
137
+ { color: colors.static_white },
138
+ hostStartStreamButton.text,
139
+ ]}
140
+ >
141
+ {isAwaitingResponse
142
+ ? t('Loading...')
143
+ : liveOrBroadcasting
144
+ ? t('Stop Livestream')
145
+ : t('Start Livestream')}
146
+ </Text>
147
+ </Pressable>
148
+ );
149
+ };
150
+
151
+ const styles = StyleSheet.create({
152
+ container: {
153
+ flexDirection: 'row',
154
+ alignItems: 'center',
155
+ padding: 8,
156
+ borderRadius: 4,
157
+ },
158
+ icon: {},
159
+ text: {
160
+ marginLeft: 8,
161
+ includeFontPadding: false,
162
+ },
163
+ });
@@ -0,0 +1,78 @@
1
+ import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
2
+ import React from 'react';
3
+ import { useTheme } from '../../../contexts';
4
+ import { Pressable, StyleSheet, View } from 'react-native';
5
+ import { Mic, MicOff } from '../../../icons';
6
+
7
+ /**
8
+ * The LivestreamAudioControlButton controls the audio stream publish/unpublish while in the livestream for the host.
9
+ */
10
+ export const LivestreamAudioControlButton = () => {
11
+ const call = useCall();
12
+ const { useMicrophoneState } = useCallStateHooks();
13
+ const { status } = useMicrophoneState();
14
+ const {
15
+ theme: {
16
+ colors,
17
+ variants: { iconSizes, buttonSizes },
18
+ livestreamAudioControlButton,
19
+ },
20
+ } = useTheme();
21
+
22
+ const onPress = async () => {
23
+ await call?.microphone.toggle();
24
+ };
25
+
26
+ return (
27
+ <Pressable
28
+ onPress={onPress}
29
+ style={[
30
+ styles.container,
31
+ {
32
+ backgroundColor: colors.dark_gray,
33
+ height: buttonSizes.xs,
34
+ width: buttonSizes.xs,
35
+ },
36
+ livestreamAudioControlButton.container,
37
+ ]}
38
+ >
39
+ {status === 'enabled' ? (
40
+ <View
41
+ style={[
42
+ styles.icon,
43
+ {
44
+ height: iconSizes.sm,
45
+ width: iconSizes.sm,
46
+ },
47
+ livestreamAudioControlButton.icon,
48
+ ]}
49
+ >
50
+ <Mic color={colors.static_white} />
51
+ </View>
52
+ ) : (
53
+ <View
54
+ style={[
55
+ styles.icon,
56
+ {
57
+ height: iconSizes.sm,
58
+ width: iconSizes.sm,
59
+ },
60
+ livestreamAudioControlButton.icon,
61
+ ]}
62
+ >
63
+ <MicOff color={colors.static_white} />
64
+ </View>
65
+ )}
66
+ </Pressable>
67
+ );
68
+ };
69
+
70
+ const styles = StyleSheet.create({
71
+ container: {
72
+ justifyContent: 'center',
73
+ alignItems: 'center',
74
+ marginHorizontal: 4,
75
+ borderRadius: 4,
76
+ },
77
+ icon: {},
78
+ });
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import { useTheme } from '../../../contexts';
4
+ import { LivestreamAudioControlButton } from './LivestreamAudioControlButton';
5
+ import { LivestreamVideoControlButton } from './LivestreamVideoControlButton';
6
+
7
+ /**
8
+ * Props for the LivestreamMediaControls component.
9
+ */
10
+ export type LivestreamMediaControlsProps = {};
11
+
12
+ /**
13
+ * The LivestreamMediaControls component controls the media publish/unpublish for the host's live stream.
14
+ */
15
+ export const LivestreamMediaControls = ({}: LivestreamMediaControlsProps) => {
16
+ const {
17
+ theme: { livestreamMediaControls },
18
+ } = useTheme();
19
+ return (
20
+ <View style={[styles.container, livestreamMediaControls.container]}>
21
+ <LivestreamAudioControlButton />
22
+ <LivestreamVideoControlButton />
23
+ </View>
24
+ );
25
+ };
26
+
27
+ const styles = StyleSheet.create({
28
+ container: {
29
+ flexDirection: 'row',
30
+ alignItems: 'center',
31
+ },
32
+ });
@@ -0,0 +1,78 @@
1
+ import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
2
+ import React from 'react';
3
+ import { useTheme } from '../../../contexts';
4
+ import { Pressable, StyleSheet, View } from 'react-native';
5
+ import { Video, VideoSlash } from '../../../icons';
6
+
7
+ /**
8
+ * The LivestreamVideoControlButton controls the video stream publish/unpublish while in the livestream for the host.
9
+ */
10
+ export const LivestreamVideoControlButton = () => {
11
+ const call = useCall();
12
+ const { useCameraState } = useCallStateHooks();
13
+ const { status } = useCameraState();
14
+ const {
15
+ theme: {
16
+ colors,
17
+ variants: { iconSizes, buttonSizes },
18
+ livestreamVideoControlButton,
19
+ },
20
+ } = useTheme();
21
+
22
+ const onPress = async () => {
23
+ await call?.camera.toggle();
24
+ };
25
+
26
+ return (
27
+ <Pressable
28
+ onPress={onPress}
29
+ style={[
30
+ styles.container,
31
+ {
32
+ backgroundColor: colors.dark_gray,
33
+ height: buttonSizes.xs,
34
+ width: buttonSizes.xs,
35
+ },
36
+ livestreamVideoControlButton.container,
37
+ ]}
38
+ >
39
+ {status === 'enabled' ? (
40
+ <View
41
+ style={[
42
+ styles.icon,
43
+ {
44
+ height: iconSizes.sm,
45
+ width: iconSizes.sm,
46
+ },
47
+ livestreamVideoControlButton.icon,
48
+ ]}
49
+ >
50
+ <Video color={colors.static_white} />
51
+ </View>
52
+ ) : (
53
+ <View
54
+ style={[
55
+ styles.icon,
56
+ {
57
+ height: iconSizes.sm,
58
+ width: iconSizes.sm,
59
+ },
60
+ livestreamVideoControlButton.icon,
61
+ ]}
62
+ >
63
+ <VideoSlash color={colors.static_white} />
64
+ </View>
65
+ )}
66
+ </Pressable>
67
+ );
68
+ };
69
+
70
+ const styles = StyleSheet.create({
71
+ container: {
72
+ justifyContent: 'center',
73
+ alignItems: 'center',
74
+ marginHorizontal: 4,
75
+ borderRadius: 4,
76
+ },
77
+ icon: {},
78
+ });
@@ -0,0 +1,102 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ ActivityIndicator,
4
+ Pressable,
5
+ StyleSheet,
6
+ Text,
7
+ View,
8
+ } from 'react-native';
9
+ import { useTheme } from '../../../contexts';
10
+ import { LeaveStreamIcon } from '../../../icons';
11
+ import { useCall, useI18n } from '@stream-io/video-react-bindings';
12
+
13
+ /**
14
+ * Props for the ViewerLeaveStreamButton component.
15
+ */
16
+ export type ViewerLeaveStreamButtonProps = {
17
+ /**
18
+ * Handler to be called when the viewer's leave stream button is called.
19
+ * @returns void
20
+ */
21
+ onLeaveStreamHandler?: () => void;
22
+ };
23
+
24
+ /**
25
+ * The ViewerLeaveStreamButton component displays and controls the leave stream logic of the viewer's live stream.
26
+ */
27
+ export const ViewerLeaveStreamButton = ({
28
+ onLeaveStreamHandler,
29
+ }: ViewerLeaveStreamButtonProps) => {
30
+ const [isAwaitingResponse, setIsAwaitingResponse] = useState(false);
31
+ const call = useCall();
32
+ const { t } = useI18n();
33
+ const {
34
+ theme: {
35
+ colors,
36
+ variants: { iconSizes },
37
+ typefaces,
38
+ viewerLeaveStreamButton,
39
+ },
40
+ } = useTheme();
41
+
42
+ const onLeaveStreamButtonPress = async () => {
43
+ if (onLeaveStreamHandler) {
44
+ onLeaveStreamHandler();
45
+ return;
46
+ }
47
+ try {
48
+ setIsAwaitingResponse(true);
49
+ await call?.leave();
50
+ setIsAwaitingResponse(false);
51
+ } catch (error) {
52
+ console.error('Error stopping livestream', error);
53
+ }
54
+ };
55
+
56
+ return (
57
+ <Pressable
58
+ style={[
59
+ styles.container,
60
+ {
61
+ backgroundColor: colors.dark_gray,
62
+ },
63
+ viewerLeaveStreamButton.container,
64
+ ]}
65
+ onPress={onLeaveStreamButtonPress}
66
+ >
67
+ <View
68
+ style={[
69
+ styles.icon,
70
+ { height: iconSizes.xs, width: iconSizes.xs },
71
+ viewerLeaveStreamButton.icon,
72
+ ]}
73
+ >
74
+ {isAwaitingResponse ? <ActivityIndicator /> : <LeaveStreamIcon />}
75
+ </View>
76
+ <Text
77
+ style={[
78
+ styles.text,
79
+ typefaces.subtitleBold,
80
+ { color: colors.static_white },
81
+ viewerLeaveStreamButton.text,
82
+ ]}
83
+ >
84
+ {isAwaitingResponse ? t('Loading...') : t('Leave Stream')}
85
+ </Text>
86
+ </Pressable>
87
+ );
88
+ };
89
+
90
+ const styles = StyleSheet.create({
91
+ container: {
92
+ flexDirection: 'row',
93
+ alignItems: 'center',
94
+ padding: 8,
95
+ borderRadius: 4,
96
+ },
97
+ icon: {},
98
+ text: {
99
+ marginLeft: 8,
100
+ includeFontPadding: false,
101
+ },
102
+ });