amazon-ivs-react-native-player 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/LICENSE +175 -0
  2. package/README.md +56 -0
  3. package/amazon-ivs-react-native-player.podspec +31 -0
  4. package/android/.project +17 -0
  5. package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
  6. package/android/build/.transforms/1f4dbdc38179d2776be8ed38c6bd3b8d/classes/classes.dex +0 -0
  7. package/android/build/.transforms/1f4dbdc38179d2776be8ed38c6bd3b8d.bin +1 -0
  8. package/android/build/generated/source/buildConfig/debug/com/amazonaws/ivs/reactnative/player/BuildConfig.java +10 -0
  9. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +20 -0
  10. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +16 -0
  11. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +2 -0
  12. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
  13. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  14. package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  15. package/android/build/intermediates/compile_symbol_list/debug/R.txt +1864 -0
  16. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
  17. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
  18. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
  19. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -0
  20. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +2 -0
  21. package/android/build/intermediates/javac/debug/classes/com/amazonaws/ivs/reactnative/player/BuildConfig.class +0 -0
  22. package/android/build/intermediates/library_java_res/debug/res.jar +0 -0
  23. package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +20 -0
  24. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
  25. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +28 -0
  26. package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
  27. package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +16 -0
  28. package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  29. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +1384 -0
  30. package/android/build/kotlin/compileDebugKotlin/build-history.bin +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.len +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab_i +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  42. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  43. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  44. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  45. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  46. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  47. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  48. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  49. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  50. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  51. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  52. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab +0 -0
  53. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  54. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  55. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  56. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  57. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  58. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  59. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  60. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  61. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  62. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  63. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  64. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  65. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  66. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  67. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  68. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  69. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  70. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  71. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  72. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  73. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  74. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  75. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  76. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  77. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  78. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  79. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  80. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/counters.tab +2 -0
  81. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab +0 -0
  82. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  83. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  84. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.len +0 -0
  85. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  86. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab_i +0 -0
  87. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  88. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab +0 -0
  89. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  90. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  91. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.len +0 -0
  92. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  93. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab_i +0 -0
  94. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  95. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab +0 -0
  96. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.keystream +0 -0
  97. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  98. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.len +0 -0
  99. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.values.at +0 -0
  100. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab_i +0 -0
  101. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab_i.len +0 -0
  102. package/android/build/kotlin/compileDebugKotlin/last-build.bin +0 -0
  103. package/android/build/outputs/logs/manifest-merger-debug-report.txt +52 -0
  104. package/android/build/tmp/compileDebugJavaWithJavac/source-classes-mapping.txt +2 -0
  105. package/android/build/tmp/kotlin-classes/debug/META-INF/amazonivsreactnativeplayer_debug.kotlin_module +0 -0
  106. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsPackage.class +0 -0
  107. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$$special$$inlined$timerTask$1.class +0 -0
  108. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$1.class +0 -0
  109. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$Events.class +0 -0
  110. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$WhenMappings.class +0 -0
  111. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$mLayoutRunnable$1.class +0 -0
  112. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView.class +0 -0
  113. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager$Commands.class +0 -0
  114. package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager.class +0 -0
  115. package/android/build.gradle +138 -0
  116. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  117. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  118. package/android/gradle.properties +5 -0
  119. package/android/gradlew +183 -0
  120. package/android/gradlew.bat +84 -0
  121. package/android/src/main/AndroidManifest.xml +11 -0
  122. package/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsPackage.kt +16 -0
  123. package/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt +410 -0
  124. package/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager.kt +115 -0
  125. package/ios/AmazonIvs-Bridging-Header.h +3 -0
  126. package/ios/AmazonIvs.xcodeproj/project.pbxproj +283 -0
  127. package/ios/AmazonIvsManager.m +35 -0
  128. package/ios/AmazonIvsManager.swift +29 -0
  129. package/ios/AmazonIvsView.swift +414 -0
  130. package/lib/commonjs/IVSPlayer.js +245 -0
  131. package/lib/commonjs/IVSPlayer.js.flow +53 -0
  132. package/lib/commonjs/IVSPlayer.js.map +1 -0
  133. package/lib/commonjs/enums.js +27 -0
  134. package/lib/commonjs/enums.js.flow +21 -0
  135. package/lib/commonjs/enums.js.map +1 -0
  136. package/lib/commonjs/index.js +43 -0
  137. package/lib/commonjs/index.js.flow +11 -0
  138. package/lib/commonjs/index.js.map +1 -0
  139. package/lib/commonjs/types.js +2 -0
  140. package/lib/commonjs/types.js.flow +44 -0
  141. package/lib/commonjs/types.js.map +1 -0
  142. package/lib/module/IVSPlayer.js +229 -0
  143. package/lib/module/IVSPlayer.js.flow +53 -0
  144. package/lib/module/IVSPlayer.js.map +1 -0
  145. package/lib/module/enums.js +19 -0
  146. package/lib/module/enums.js.flow +21 -0
  147. package/lib/module/enums.js.map +1 -0
  148. package/lib/module/index.js +5 -0
  149. package/lib/module/index.js.flow +11 -0
  150. package/lib/module/index.js.map +1 -0
  151. package/lib/module/types.js +2 -0
  152. package/lib/module/types.js.flow +44 -0
  153. package/lib/module/types.js.map +1 -0
  154. package/lib/typescript/IVSPlayer.d.ts +41 -0
  155. package/lib/typescript/__tests__/index.test.d.ts +1 -0
  156. package/lib/typescript/enums.d.ts +13 -0
  157. package/lib/typescript/index.d.ts +4 -0
  158. package/lib/typescript/types.d.ts +37 -0
  159. package/package.json +149 -0
  160. package/src/IVSPlayer.js.flow +53 -0
  161. package/src/IVSPlayer.tsx +366 -0
  162. package/src/__tests__/index.test.tsx +226 -0
  163. package/src/enums.js.flow +21 -0
  164. package/src/enums.ts +14 -0
  165. package/src/index.js.flow +11 -0
  166. package/src/index.ts +5 -0
  167. package/src/types.js.flow +44 -0
  168. package/src/types.ts +42 -0
@@ -0,0 +1,226 @@
1
+ import { render, fireEvent } from '@testing-library/react-native';
2
+ import React from 'react';
3
+ import { UIManager } from 'react-native';
4
+ import type { IVSPlayerRef } from '../types';
5
+
6
+ import IVSPlayer from '../IVSPlayer';
7
+
8
+ const URL =
9
+ 'https://fcc3ddae59ed.us-west-2.playback.live-video.net/api/video/v1/us-west-2.893648527354.channel.DmumNckWFTqz.m3u8';
10
+
11
+ jest.mock('react-native', () => {
12
+ const RN = jest.requireActual('react-native');
13
+
14
+ RN.UIManager.getViewManagerConfig = (name: string) => {
15
+ if (name === 'AmazonIvs') {
16
+ return {
17
+ Commands: {
18
+ play: 1,
19
+ pause: 2,
20
+ seekTo: 3,
21
+ },
22
+ };
23
+ }
24
+ return {};
25
+ };
26
+
27
+ return RN;
28
+ });
29
+
30
+ const testCallbackPassing = async (
31
+ name: string,
32
+ nativeEvent?: any,
33
+ result?: any
34
+ ) => {
35
+ const mockFn = jest.fn();
36
+
37
+ const { findByTestId } = render(
38
+ <IVSPlayer streamUrl={URL} {...{ [name]: mockFn }} />
39
+ );
40
+ const nativePlayer = await findByTestId('IVSPlayer');
41
+
42
+ fireEvent(
43
+ nativePlayer,
44
+ name,
45
+ nativeEvent
46
+ ? {
47
+ nativeEvent,
48
+ }
49
+ : undefined
50
+ );
51
+ expect(mockFn).toHaveBeenCalledWith(result);
52
+ };
53
+
54
+ test('Renders the native component', async () => {
55
+ const { findByTestId } = render(<IVSPlayer />);
56
+ const nativePlayer = await findByTestId('IVSPlayer');
57
+
58
+ expect(nativePlayer).toBeDefined();
59
+ });
60
+
61
+ test('Passing onDurationChange down works correctly', async () => {
62
+ await testCallbackPassing('onDurationChange', { duration: 1 }, 1);
63
+ });
64
+
65
+ test('Passing onSeek down works correctly', async () => {
66
+ await testCallbackPassing('onSeek', { position: 1 }, 1);
67
+ });
68
+
69
+ test('Passing onData down works correctly', async () => {
70
+ await testCallbackPassing(
71
+ 'onData',
72
+ { playerData: { sessionId: 1 } },
73
+ { sessionId: 1 }
74
+ );
75
+ });
76
+
77
+ test('Passing onVideoStatistics down works correctly', async () => {
78
+ await testCallbackPassing(
79
+ 'onVideoStatistics',
80
+ { videoData: { duration: 1 } },
81
+ { duration: 1 }
82
+ );
83
+ });
84
+
85
+ test('Passing onPlayerStateChange down works correctly', async () => {
86
+ await testCallbackPassing('onPlayerStateChange', { state: 1 }, 1);
87
+ });
88
+
89
+ test('Passing onQualityChange down works correctly', async () => {
90
+ await testCallbackPassing(
91
+ 'onQualityChange',
92
+ { quality: { bitrate: 1 } },
93
+ { bitrate: 1 }
94
+ );
95
+ });
96
+
97
+ test('Passing onRebuffering down works correctly', async () => {
98
+ await testCallbackPassing('onRebuffering');
99
+ });
100
+
101
+ test('Passing onLoadStart down works correctly', async () => {
102
+ await testCallbackPassing('onLoadStart');
103
+ });
104
+
105
+ test('Passing onLoad down works correctly', async () => {
106
+ await testCallbackPassing('onLoad', { duration: 1 }, 1);
107
+ });
108
+
109
+ test('Passing onLiveLatencyChange down works correctly', async () => {
110
+ await testCallbackPassing('onLiveLatencyChange', { liveLatency: 1 }, 1);
111
+ });
112
+
113
+ test('Passing onTextCue down works correctly', async () => {
114
+ await testCallbackPassing(
115
+ 'onTextCue',
116
+ { textCue: { text: 'text' } },
117
+ { text: 'text' }
118
+ );
119
+ });
120
+
121
+ test('Passing onTextMetadataCue down works correctly', async () => {
122
+ await testCallbackPassing(
123
+ 'onTextMetadataCue',
124
+ { textMetadataCue: { text: 'text' } },
125
+ { text: 'text' }
126
+ );
127
+ });
128
+
129
+ test('Passing onProgress down works correctly', async () => {
130
+ await testCallbackPassing('onProgress', { position: 1 }, 1);
131
+ });
132
+
133
+ test('Passing onError down works correctly', async () => {
134
+ await testCallbackPassing('onError', { error: 'err' }, 'err');
135
+ });
136
+
137
+ test('Passing onTimePoint down works correctly', async () => {
138
+ await testCallbackPassing('onTimePoint', { position: 1 }, 1);
139
+ });
140
+
141
+ test('Player will autoplay without any props', async () => {
142
+ const mockCommandFn = jest.fn();
143
+ UIManager.dispatchViewManagerCommand = mockCommandFn;
144
+
145
+ render(<IVSPlayer streamUrl={URL} />);
146
+
147
+ expect(mockCommandFn).toHaveBeenCalled();
148
+
149
+ // Checking if the second argument of the function is the "play" command
150
+ expect(mockCommandFn.mock.calls[0][1]).toEqual(1);
151
+ });
152
+
153
+ test('Paused set to false wont play the video', async () => {
154
+ const mockCommandFn = jest.fn();
155
+ UIManager.dispatchViewManagerCommand = mockCommandFn;
156
+
157
+ render(<IVSPlayer streamUrl={URL} paused />);
158
+
159
+ expect(mockCommandFn).toHaveBeenCalled();
160
+
161
+ // Checking if the second argument of the function is the "pause" command
162
+ expect(mockCommandFn.mock.calls[0][1]).toEqual(2);
163
+ });
164
+
165
+ test('Using pause on ref calls pause on native component', async () => {
166
+ const mockCommandFn = jest.fn();
167
+ const ref = React.createRef<IVSPlayerRef>();
168
+
169
+ render(<IVSPlayer streamUrl={URL} ref={ref} />);
170
+
171
+ UIManager.dispatchViewManagerCommand = mockCommandFn;
172
+ ref.current?.pause();
173
+
174
+ expect(mockCommandFn).toHaveBeenCalled();
175
+
176
+ // Checking if the second argument of the function is the "pause" command
177
+ expect(mockCommandFn.mock.calls[0][1]).toEqual(2);
178
+ });
179
+
180
+ test('Using play on ref calls play on native component', async () => {
181
+ const mockCommandFn = jest.fn();
182
+ const ref = React.createRef<IVSPlayerRef>();
183
+
184
+ render(<IVSPlayer streamUrl={URL} ref={ref} />);
185
+
186
+ UIManager.dispatchViewManagerCommand = mockCommandFn;
187
+ ref.current?.pause();
188
+ ref.current?.play();
189
+
190
+ expect(mockCommandFn).toHaveBeenCalledTimes(2);
191
+
192
+ // Checking if the second argument of the function is the "play" command
193
+ expect(mockCommandFn.mock.calls[1][1]).toEqual(1);
194
+ });
195
+
196
+ test('Using seekTo on ref calls seekTo on native component', async () => {
197
+ const mockCommandFn = jest.fn();
198
+ const ref = React.createRef<IVSPlayerRef>();
199
+
200
+ render(<IVSPlayer streamUrl={URL} ref={ref} />);
201
+
202
+ UIManager.dispatchViewManagerCommand = mockCommandFn;
203
+ ref.current?.seekTo(10);
204
+
205
+ expect(mockCommandFn).toHaveBeenCalled();
206
+
207
+ // Checking if the second argument of the function is the "play" command
208
+ expect(mockCommandFn.mock.calls[0][1]).toEqual(3);
209
+
210
+ // Checking if the value we pass down is proper
211
+ expect(mockCommandFn.mock.calls[0][2]).toEqual([10]);
212
+ });
213
+
214
+ test('Autoplay when onLoad', async () => {
215
+ const mockCommandFn = jest.fn();
216
+
217
+ const { findByTestId } = render(<IVSPlayer streamUrl={URL} />);
218
+ UIManager.dispatchViewManagerCommand = mockCommandFn;
219
+ const nativePlayer = await findByTestId('IVSPlayer');
220
+ fireEvent(nativePlayer, 'onLoad', { nativeEvent: { duration: 10 } });
221
+
222
+ expect(mockCommandFn).toHaveBeenCalled();
223
+
224
+ // Checking if the second argument of the function is the "play" command
225
+ expect(mockCommandFn.mock.calls[0][1]).toEqual(1);
226
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Flowtype definitions for enums
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.13.0
5
+ * @flow
6
+ */
7
+
8
+ declare export var LogLevel: {|
9
+ +IVSLogLevelDebug: 0, // 0
10
+ +IVSLogLevelInfo: 1, // 1
11
+ +IVSLogLevelWarning: 2, // 2
12
+ +IVSLogLevelError: 3, // 3
13
+ |};
14
+
15
+ declare export var PlayerState: {|
16
+ +Idle: 0, // 0
17
+ +Ready: 1, // 1
18
+ +Buffering: 2, // 2
19
+ +Playing: 3, // 3
20
+ +Ended: 4, // 4
21
+ |};
package/src/enums.ts ADDED
@@ -0,0 +1,14 @@
1
+ export enum LogLevel {
2
+ IVSLogLevelDebug,
3
+ IVSLogLevelInfo,
4
+ IVSLogLevelWarning,
5
+ IVSLogLevelError,
6
+ }
7
+
8
+ export enum PlayerState {
9
+ Idle = 'Idle',
10
+ Ready = 'Ready',
11
+ Buffering = 'Buffering',
12
+ Playing = 'Playing',
13
+ Ended = 'Ended',
14
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Flowtype definitions for index
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.13.0
5
+ * @flow
6
+ */
7
+
8
+ declare export * from './enums'
9
+ declare export * from './types'
10
+ import IVSPlayer from './IVSPlayer';
11
+ declare export default typeof IVSPlayer;
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './enums';
2
+ export * from './types';
3
+ import IVSPlayer from './IVSPlayer';
4
+
5
+ export default IVSPlayer;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Flowtype definitions for types
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.13.0
5
+ * @flow
6
+ */
7
+
8
+ export type Quality = {|
9
+ name: string,
10
+ codecs: string,
11
+ bitrate: number,
12
+ framerate: number,
13
+ width: number,
14
+ height: number,
15
+ |};
16
+ export type PlayerData = {|
17
+ qualities: Quality[],
18
+ version: string,
19
+ sessionId: string,
20
+ |};
21
+ export type VideoData = {|
22
+ bitrate: number,
23
+ duration: number | null,
24
+ framesDecoded: number | null,
25
+ framesDropped: number | null,
26
+ |};
27
+ export type TextCue = {|
28
+ type: string,
29
+ line: number,
30
+ size: number,
31
+ position: number,
32
+ text: string,
33
+ textAlignment: string,
34
+ |};
35
+ export type TextMetadataCue = {|
36
+ type: string,
37
+ text: string,
38
+ textDescription: string,
39
+ |};
40
+ export type IVSPlayerRef = {|
41
+ play: () => void,
42
+ pause: () => void,
43
+ seekTo: (position: number) => void,
44
+ |};
package/src/types.ts ADDED
@@ -0,0 +1,42 @@
1
+ export type Quality = {
2
+ name: string;
3
+ codecs: string;
4
+ bitrate: number;
5
+ framerate: number;
6
+ width: number;
7
+ height: number;
8
+ };
9
+
10
+ export type PlayerData = {
11
+ qualities: Quality[];
12
+ version: string;
13
+ sessionId: string;
14
+ };
15
+
16
+ export type VideoData = {
17
+ bitrate: number;
18
+ duration: number | null;
19
+ framesDecoded: number | null;
20
+ framesDropped: number | null;
21
+ };
22
+
23
+ export type TextCue = {
24
+ type: string;
25
+ line: number;
26
+ size: number;
27
+ position: number;
28
+ text: string;
29
+ textAlignment: string;
30
+ };
31
+
32
+ export type TextMetadataCue = {
33
+ type: string;
34
+ text: string;
35
+ textDescription: string;
36
+ };
37
+
38
+ export type IVSPlayerRef = {
39
+ play: () => void;
40
+ pause: () => void;
41
+ seekTo: (position: number) => void;
42
+ };