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.
- package/LICENSE +175 -0
- package/README.md +56 -0
- package/amazon-ivs-react-native-player.podspec +31 -0
- package/android/.project +17 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/build/.transforms/1f4dbdc38179d2776be8ed38c6bd3b8d/classes/classes.dex +0 -0
- package/android/build/.transforms/1f4dbdc38179d2776be8ed38c6bd3b8d.bin +1 -0
- package/android/build/generated/source/buildConfig/debug/com/amazonaws/ivs/reactnative/player/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +20 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +16 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +2 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +1864 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/classes/com/amazonaws/ivs/reactnative/player/BuildConfig.class +0 -0
- package/android/build/intermediates/library_java_res/debug/res.jar +0 -0
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +20 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +28 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +16 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +1384 -0
- package/android/build/kotlin/compileDebugKotlin/build-history.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/counters.tab +2 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/last-build.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +52 -0
- package/android/build/tmp/compileDebugJavaWithJavac/source-classes-mapping.txt +2 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/amazonivsreactnativeplayer_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsPackage.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$$special$$inlined$timerTask$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$Events.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$WhenMappings.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView$mLayoutRunnable$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsView.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager$Commands.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager.class +0 -0
- package/android/build.gradle +138 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +5 -0
- package/android/gradlew +183 -0
- package/android/gradlew.bat +84 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsPackage.kt +16 -0
- package/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt +410 -0
- package/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager.kt +115 -0
- package/ios/AmazonIvs-Bridging-Header.h +3 -0
- package/ios/AmazonIvs.xcodeproj/project.pbxproj +283 -0
- package/ios/AmazonIvsManager.m +35 -0
- package/ios/AmazonIvsManager.swift +29 -0
- package/ios/AmazonIvsView.swift +414 -0
- package/lib/commonjs/IVSPlayer.js +245 -0
- package/lib/commonjs/IVSPlayer.js.flow +53 -0
- package/lib/commonjs/IVSPlayer.js.map +1 -0
- package/lib/commonjs/enums.js +27 -0
- package/lib/commonjs/enums.js.flow +21 -0
- package/lib/commonjs/enums.js.map +1 -0
- package/lib/commonjs/index.js +43 -0
- package/lib/commonjs/index.js.flow +11 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.flow +44 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/IVSPlayer.js +229 -0
- package/lib/module/IVSPlayer.js.flow +53 -0
- package/lib/module/IVSPlayer.js.map +1 -0
- package/lib/module/enums.js +19 -0
- package/lib/module/enums.js.flow +21 -0
- package/lib/module/enums.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.flow +11 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.flow +44 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/IVSPlayer.d.ts +41 -0
- package/lib/typescript/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/enums.d.ts +13 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/types.d.ts +37 -0
- package/package.json +149 -0
- package/src/IVSPlayer.js.flow +53 -0
- package/src/IVSPlayer.tsx +366 -0
- package/src/__tests__/index.test.tsx +226 -0
- package/src/enums.js.flow +21 -0
- package/src/enums.ts +14 -0
- package/src/index.js.flow +11 -0
- package/src/index.ts +5 -0
- package/src/types.js.flow +44 -0
- 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,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,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
|
+
};
|