vdocipher-rn-bridge 1.12.1 → 1.12.3
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/CHANGELOG.md +5 -0
- package/{VdoPlayerSupportView.js → VdoPlayerSupportView.tsx} +15 -13
- package/{VdoPlayerUIView.js → VdoPlayerUIView.tsx} +23 -20
- package/VdoPlayerView.tsx +318 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +10 -8
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +10 -7
- package/downloadMonitor.ts +29 -0
- package/{downloads.js → downloads.ts} +15 -12
- package/{index.android.js → index.ts} +2 -1
- package/package.json +20 -9
- package/tsconfig.json +107 -0
- package/type.ts +151 -0
- package/VdoPlayerView.js +0 -352
- package/downloadMonitor.js +0 -28
- package/index.ios.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
5
|
import { requireNativeComponent} from 'react-native';
|
|
6
|
+
import { InferProps } from 'prop-types';
|
|
7
|
+
import { VdoPropTypes, VideoQuality, CaptionLanguage } from './type';
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
const VdoViewPropTypes = VdoPropTypes;
|
|
10
|
+
type MyProps = InferProps<typeof VdoViewPropTypes>;
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
class VdoPlayerSupportView extends Component<MyProps> {
|
|
13
|
+
_propRef: number;
|
|
14
|
+
_root: any;
|
|
15
|
+
|
|
16
|
+
constructor(props: MyProps) {
|
|
10
17
|
super(props);
|
|
11
18
|
this._propRef = 1;
|
|
12
19
|
}
|
|
@@ -15,7 +22,7 @@ class VdoPlayerSupportView extends Component {
|
|
|
15
22
|
this._root.setNativeProps({fullscreen: false});
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
seek = seekTargetMs => {
|
|
25
|
+
seek = (seekTargetMs: number) => {
|
|
19
26
|
if (this._root) {
|
|
20
27
|
this._root.setNativeProps({seek: seekTargetMs});
|
|
21
28
|
}
|
|
@@ -39,7 +46,7 @@ class VdoPlayerSupportView extends Component {
|
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
|
|
42
|
-
setVideoQuality = videoQuality => {
|
|
49
|
+
setVideoQuality = (videoQuality: VideoQuality) => {
|
|
43
50
|
if (this._root) {
|
|
44
51
|
this._root.setNativeProps({videoQuality: videoQuality});
|
|
45
52
|
}
|
|
@@ -51,7 +58,7 @@ class VdoPlayerSupportView extends Component {
|
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
setCaptionLanguage = captionLanguage => {
|
|
61
|
+
setCaptionLanguage = (captionLanguage: CaptionLanguage) => {
|
|
55
62
|
if (this._root) {
|
|
56
63
|
this._root.setNativeProps({captionLanguage: captionLanguage});
|
|
57
64
|
}
|
|
@@ -65,18 +72,13 @@ class VdoPlayerSupportView extends Component {
|
|
|
65
72
|
|
|
66
73
|
render() {
|
|
67
74
|
return (
|
|
68
|
-
<RCTVdoPlayerView ref={component => this._root = component}
|
|
75
|
+
<RCTVdoPlayerView ref={(component: any) => this._root = component}
|
|
69
76
|
{...this.props}
|
|
70
77
|
/>
|
|
71
|
-
)
|
|
78
|
+
);
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
var RCTVdoPlayerView = requireNativeComponent('RCTVdoPlayerView'
|
|
76
|
-
nativeOnly: {
|
|
77
|
-
onInitSuccess: true,
|
|
78
|
-
onInitFailure: true,
|
|
79
|
-
}
|
|
80
|
-
});
|
|
82
|
+
var RCTVdoPlayerView = requireNativeComponent('RCTVdoPlayerView');
|
|
81
83
|
|
|
82
84
|
export default VdoPlayerSupportView;
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
5
|
import {requireNativeComponent, Platform} from 'react-native';
|
|
6
|
+
import { InferProps } from 'prop-types';
|
|
7
|
+
import { VdoPropTypes } from './type';
|
|
8
|
+
|
|
9
|
+
const VdoViewPropTypes = VdoPropTypes;
|
|
10
|
+
type MyProps = InferProps<typeof VdoViewPropTypes>;
|
|
6
11
|
|
|
7
|
-
class VdoPlayerUIView extends Component {
|
|
8
|
-
|
|
12
|
+
class VdoPlayerUIView extends Component<MyProps> {
|
|
13
|
+
_propRef: number;
|
|
14
|
+
_root: any;
|
|
15
|
+
_tvEventHandler: any;
|
|
16
|
+
constructor(props: MyProps) {
|
|
9
17
|
super(props);
|
|
10
18
|
this._propRef = 1;
|
|
11
19
|
}
|
|
@@ -31,7 +39,7 @@
|
|
|
31
39
|
_enableTVEventHandler() {
|
|
32
40
|
const {TVEventHandler} = require('react-native');
|
|
33
41
|
this._tvEventHandler = new TVEventHandler();
|
|
34
|
-
this._tvEventHandler.enable(this, function (cmp, evt) {
|
|
42
|
+
this._tvEventHandler.enable(this, function (cmp: any, evt: any) {
|
|
35
43
|
if (cmp._vdoPlayerView) {
|
|
36
44
|
if (evt && evt.eventType === "right") {
|
|
37
45
|
cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 22});
|
|
@@ -56,12 +64,12 @@
|
|
|
56
64
|
delete this._tvEventHandler;
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
|
-
|
|
67
|
+
|
|
60
68
|
handleBackButtonClick() {
|
|
61
69
|
this._root.setNativeProps({fullscreen: false});
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
seek = seekTargetMs => {
|
|
72
|
+
seek = (seekTargetMs: number) => {
|
|
65
73
|
if (this._root) {
|
|
66
74
|
this._root.setNativeProps({seek: seekTargetMs});
|
|
67
75
|
}
|
|
@@ -85,26 +93,21 @@
|
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
|
|
88
|
-
setKeyDownEvent = (keyDownEvent) => {
|
|
96
|
+
setKeyDownEvent = (keyDownEvent: any) => {
|
|
89
97
|
if (this._root) {
|
|
90
98
|
this._root.setNativeProps({keyDownEvent: keyDownEvent});
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
|
|
102
|
+
render() {
|
|
103
|
+
return (
|
|
104
|
+
<RCTVdoPlayerUIView ref={(component: any) => this._root = component}
|
|
105
|
+
{...this.props}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
var RCTVdoPlayerUIView = requireNativeComponent('RCTVdoPlayerUIView'
|
|
104
|
-
nativeOnly: {
|
|
105
|
-
onInitSuccess: true,
|
|
106
|
-
onInitFailure: true,
|
|
107
|
-
}
|
|
108
|
-
});
|
|
111
|
+
var RCTVdoPlayerUIView = requireNativeComponent('RCTVdoPlayerUIView');
|
|
109
112
|
|
|
110
113
|
export default VdoPlayerUIView;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VdoPlayerView component that can be dropped into a layout for video playback.
|
|
3
|
+
*/
|
|
4
|
+
import React, { Component, Fragment } from 'react';
|
|
5
|
+
import { InferProps } from 'prop-types';
|
|
6
|
+
import { BackHandler, NativeModules} from 'react-native';
|
|
7
|
+
import VdoPlayerSupportView from './VdoPlayerSupportView';
|
|
8
|
+
import VdoPlayerUIView from './VdoPlayerUIView';
|
|
9
|
+
import * as VdoType from './type';
|
|
10
|
+
const { TrackSelection } = NativeModules;
|
|
11
|
+
|
|
12
|
+
const VdoViewPropTypes = VdoType.VdoPropTypes;
|
|
13
|
+
|
|
14
|
+
type MyProps = InferProps<typeof VdoViewPropTypes>;
|
|
15
|
+
type MyState = {
|
|
16
|
+
fullscreen: boolean;
|
|
17
|
+
isInitialPortrait: boolean;
|
|
18
|
+
isInPictureInPictureMode: false;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class VdoPlayerView extends Component<MyProps, MyState> {
|
|
22
|
+
_propRef: number;
|
|
23
|
+
_vdoPlayerView: any;
|
|
24
|
+
static propTypes: typeof VdoViewPropTypes;
|
|
25
|
+
|
|
26
|
+
constructor(props: MyProps) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.state = {
|
|
29
|
+
fullscreen: false,
|
|
30
|
+
isInitialPortrait: true,
|
|
31
|
+
isInPictureInPictureMode: false
|
|
32
|
+
}
|
|
33
|
+
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
|
|
34
|
+
this._propRef = 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
componentDidMount() {
|
|
38
|
+
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
componentWillUnmount() {
|
|
42
|
+
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
handleBackButtonClick() {
|
|
46
|
+
if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.state.isInitialPortrait) {
|
|
47
|
+
this._vdoPlayerView.handleBackButtonClick();
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
seek = (seekTargetMs: number) => {
|
|
53
|
+
if (this._vdoPlayerView) {
|
|
54
|
+
this._vdoPlayerView.seek(seekTargetMs);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
enterFullscreen = () => {
|
|
59
|
+
if (this._vdoPlayerView) {
|
|
60
|
+
this._vdoPlayerView.enterFullscreen();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exitFullscreen = () => {
|
|
65
|
+
if (this._vdoPlayerView) {
|
|
66
|
+
this._vdoPlayerView.exitFullscreen();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getPlaybackProperties = () => {
|
|
71
|
+
if (this._vdoPlayerView) {
|
|
72
|
+
this._vdoPlayerView.getPlaybackProperties();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
isAdaptive = async() => {
|
|
77
|
+
return new Promise(async(resolve) => { await TrackSelection.isAdaptive((isAdaptive: boolean) => {
|
|
78
|
+
resolve(isAdaptive);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getVideoQualities = async() => {
|
|
84
|
+
return new Promise(async(resolve) => { await TrackSelection.getVideoQualities((videoQualities: Array<VdoType.VideoQuality>) => {
|
|
85
|
+
resolve(videoQualities);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getSelectedVideoQuality = async() => {
|
|
91
|
+
return new Promise(async(resolve) => { await TrackSelection.getSelectedVideoQuality((selectedVideoQuality: VdoType.VideoQuality) => {
|
|
92
|
+
resolve(selectedVideoQuality);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setVideoQuality = (videoQuality: VdoType.VideoQuality) => {
|
|
98
|
+
if (this._vdoPlayerView) {
|
|
99
|
+
this._vdoPlayerView.setVideoQuality(videoQuality);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
enableAdaptiveVideo = () => {
|
|
104
|
+
if (this._vdoPlayerView) {
|
|
105
|
+
this._vdoPlayerView.enableAdaptiveVideo();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getSelectedAudioQuality = async() => {
|
|
110
|
+
return new Promise(async(resolve) => { await TrackSelection.getSelectedAudioQuality((selectedAudioQuality: VdoType.AudioQuality) => {
|
|
111
|
+
resolve(selectedAudioQuality);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getCaptionLanguages = async() => {
|
|
117
|
+
return new Promise(async(resolve) => { await TrackSelection.getCaptionLanguages((captionLanguages: Array<VdoType.CaptionLanguage>) => {
|
|
118
|
+
resolve(captionLanguages);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
getSelectedCaptionLanguage = async() => {
|
|
124
|
+
return new Promise(async(resolve) => { await TrackSelection.getSelectedCaptionLanguage((selectedCaptionLanguage: VdoType.CaptionLanguage) => {
|
|
125
|
+
resolve(selectedCaptionLanguage);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setCaptionLanguage = (captionLanguage: VdoType.CaptionLanguage) => {
|
|
131
|
+
if (this._vdoPlayerView) {
|
|
132
|
+
this._vdoPlayerView.setCaptionLanguage(captionLanguage);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
disableCaptions = () => {
|
|
137
|
+
if (this._vdoPlayerView) {
|
|
138
|
+
this._vdoPlayerView.disableCaptions();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
getDuration = async() => {
|
|
143
|
+
return new Promise(async(resolve) => { await TrackSelection.getDuration((duration: number) => {
|
|
144
|
+
resolve(duration);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_onInitSuccess = (event: any) => {
|
|
150
|
+
if (this.props.onInitializationSuccess) {
|
|
151
|
+
this.props.onInitializationSuccess(event.nativeEvent);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_onInitFailure = (event: any) => {
|
|
156
|
+
if (this.props.onInitializationFailure) {
|
|
157
|
+
this.props.onInitializationFailure(event.nativeEvent);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_onLoading = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
|
|
162
|
+
if (this.props.onLoading) {
|
|
163
|
+
this.props.onLoading({embedInfo, ...event.nativeEvent});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_onLoaded = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
|
|
168
|
+
if (this.props.onLoaded) {
|
|
169
|
+
this.props.onLoaded({embedInfo, ...event.nativeEvent});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_onLoadError = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
|
|
174
|
+
if (this.props.onLoadError) {
|
|
175
|
+
this.props.onLoadError({embedInfo, ...event.nativeEvent});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
_onPlayerStateChanged = (event: any) => {
|
|
180
|
+
if (this.props.onPlayerStateChanged) {
|
|
181
|
+
this.props.onPlayerStateChanged(event.nativeEvent);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_onProgress = (event: any) => {
|
|
186
|
+
if (this.props.onProgress) {
|
|
187
|
+
this.props.onProgress(event.nativeEvent);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_onBufferUpdate = (event: any) => {
|
|
192
|
+
if (this.props.onBufferUpdate) {
|
|
193
|
+
this.props.onBufferUpdate(event.nativeEvent);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_onPlaybackSpeedChanged = (event: any) => {
|
|
198
|
+
if (this.props.onPlaybackSpeedChanged) {
|
|
199
|
+
this.props.onPlaybackSpeedChanged(event.nativeEvent.playbackSpeed);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
_onTracksChanged = (event: any) => {
|
|
204
|
+
if (this.props.onTracksChanged) {
|
|
205
|
+
this.props.onTracksChanged(event.nativeEvent);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_onMediaEnded = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
|
|
210
|
+
if (this.props.onMediaEnded) {
|
|
211
|
+
this.props.onMediaEnded({embedInfo, ...event.nativeEvent});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
_onError = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
|
|
216
|
+
if (this.props.onError) {
|
|
217
|
+
this.props.onError({embedInfo, ...event.nativeEvent});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
_onPlaybackProperties = (event: any) => {
|
|
222
|
+
if (this.props.onPlaybackProperties) {
|
|
223
|
+
this.props.onPlaybackProperties(event.nativeEvent);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
_onEnterFullscreen = () => {
|
|
228
|
+
this.setState({
|
|
229
|
+
fullscreen: true
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
if (this.props.onEnterFullscreen) {
|
|
233
|
+
this.props.onEnterFullscreen();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
_onExitFullscreen = () => {
|
|
238
|
+
this.setState({
|
|
239
|
+
fullscreen: false
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (this.props.onExitFullscreen) {
|
|
243
|
+
this.props.onExitFullscreen();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
_onIsInitialPortrait =(event: any) => {
|
|
248
|
+
this.setState({
|
|
249
|
+
isInitialPortrait: event.nativeEvent.isInitialPortrait
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
_onPictureInPictureModeChanged = (event: any) => {
|
|
254
|
+
this.setState({
|
|
255
|
+
isInPictureInPictureMode: event.nativeEvent.isInPictureInPictureMode
|
|
256
|
+
});
|
|
257
|
+
if (this.props.onPictureInPictureModeChanged) {
|
|
258
|
+
this.props.onPictureInPictureModeChanged(event.nativeEvent);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
render() {
|
|
263
|
+
return (
|
|
264
|
+
<Fragment>
|
|
265
|
+
{
|
|
266
|
+
this.props.showNativeControls === false ? (
|
|
267
|
+
<VdoPlayerSupportView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
|
|
268
|
+
{...this.props}
|
|
269
|
+
onInitSuccess={this._onInitSuccess}
|
|
270
|
+
onInitFailure={this._onInitFailure}
|
|
271
|
+
onVdoLoading={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
|
|
272
|
+
onVdoLoaded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
|
|
273
|
+
onVdoLoadError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
|
|
274
|
+
onVdoPlayerStateChanged={this._onPlayerStateChanged}
|
|
275
|
+
onVdoProgress={this._onProgress}
|
|
276
|
+
onVdoBufferUpdate={this._onBufferUpdate}
|
|
277
|
+
onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
|
|
278
|
+
onVdoTracksChanged={this._onTracksChanged}
|
|
279
|
+
onVdoMediaEnded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
|
|
280
|
+
onVdoError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onError(embedInfo, event))(this.props.embedInfo)}
|
|
281
|
+
onVdoPlaybackProperties={this._onPlaybackProperties}
|
|
282
|
+
onVdoEnterFullscreen={this._onEnterFullscreen}
|
|
283
|
+
onVdoExitFullscreen={this._onExitFullscreen}
|
|
284
|
+
onIsInitialPortrait={this._onIsInitialPortrait}
|
|
285
|
+
onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
|
|
286
|
+
/>
|
|
287
|
+
) :
|
|
288
|
+
(
|
|
289
|
+
<VdoPlayerUIView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
|
|
290
|
+
{...this.props}
|
|
291
|
+
onInitSuccess={this._onInitSuccess}
|
|
292
|
+
onInitFailure={this._onInitFailure}
|
|
293
|
+
onVdoLoading={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
|
|
294
|
+
onVdoLoaded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
|
|
295
|
+
onVdoLoadError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
|
|
296
|
+
onVdoPlayerStateChanged={this._onPlayerStateChanged}
|
|
297
|
+
onVdoProgress={this._onProgress}
|
|
298
|
+
onVdoBufferUpdate={this._onBufferUpdate}
|
|
299
|
+
onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
|
|
300
|
+
onVdoTracksChanged={this._onTracksChanged}
|
|
301
|
+
onVdoMediaEnded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
|
|
302
|
+
onVdoError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onError(embedInfo, event))(this.props.embedInfo)}
|
|
303
|
+
onVdoPlaybackProperties={this._onPlaybackProperties}
|
|
304
|
+
onVdoEnterFullscreen={this._onEnterFullscreen}
|
|
305
|
+
onVdoExitFullscreen={this._onExitFullscreen}
|
|
306
|
+
onIsInitialPortrait={this._onIsInitialPortrait}
|
|
307
|
+
onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
|
|
308
|
+
/>
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
</Fragment>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
VdoPlayerView.propTypes = VdoViewPropTypes;
|
|
317
|
+
|
|
318
|
+
export default VdoPlayerView;
|
package/android/build.gradle
CHANGED
|
@@ -18,8 +18,8 @@ apply plugin: 'com.android.library'
|
|
|
18
18
|
// TODO read from package.json
|
|
19
19
|
// "releaseVersionName" must be the same as "version" in package.json
|
|
20
20
|
// "releaseVersionCode" must increment by 1 with every release
|
|
21
|
-
def releaseVersionName = "1.12.
|
|
22
|
-
def releaseVersionCode =
|
|
21
|
+
def releaseVersionName = "1.12.3"
|
|
22
|
+
def releaseVersionCode = 14
|
|
23
23
|
|
|
24
24
|
android {
|
|
25
25
|
compileSdkVersion 33
|
|
@@ -26,6 +26,7 @@ import android.os.Bundle;
|
|
|
26
26
|
|
|
27
27
|
import androidx.core.app.PictureInPictureModeChangedInfo;
|
|
28
28
|
import androidx.core.util.Consumer;
|
|
29
|
+
import android.graphics.Color;
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
|
|
@@ -54,20 +55,13 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
54
55
|
themedReactContext = context;
|
|
55
56
|
activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
|
|
56
57
|
setKeepScreenOn(true);
|
|
58
|
+
setBackgroundColor(Color.BLACK);
|
|
57
59
|
|
|
58
60
|
context.addLifecycleEventListener(this);
|
|
59
61
|
activity.addOnConfigurationChangedListener(this);
|
|
60
62
|
|
|
61
63
|
eventEmitter = new VdoEventEmitter(context);
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
vdoPlayerUIFragment = new VdoPlayerUIFragment();
|
|
65
|
-
Bundle bundle = new Bundle();
|
|
66
|
-
bundle.putBoolean("showControls", true);
|
|
67
|
-
vdoPlayerUIFragment.setArguments(bundle);
|
|
68
|
-
fragmentManager = this.activity.getSupportFragmentManager();
|
|
69
|
-
initializePlayer();
|
|
70
|
-
|
|
71
65
|
int orientation = getResources().getConfiguration().orientation;
|
|
72
66
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
73
67
|
eventEmitter.isInitialPortrait();
|
|
@@ -165,6 +159,14 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
165
159
|
protected void onAttachedToWindow() {
|
|
166
160
|
Log.d(TAG, "onAttachedToWindow");
|
|
167
161
|
super.onAttachedToWindow();
|
|
162
|
+
if (vdoPlayerUIFragment == null) {
|
|
163
|
+
vdoPlayerUIFragment = new VdoPlayerUIFragment();
|
|
164
|
+
Bundle bundle = new Bundle();
|
|
165
|
+
bundle.putBoolean("showControls", true);
|
|
166
|
+
vdoPlayerUIFragment.setArguments(bundle);
|
|
167
|
+
fragmentManager = this.activity.getSupportFragmentManager();
|
|
168
|
+
initializePlayer();
|
|
169
|
+
}
|
|
168
170
|
if (playWhenReady) {
|
|
169
171
|
if (vdoPlayer != null) {
|
|
170
172
|
vdoPlayer.setPlayWhenReady(true);
|
|
@@ -41,6 +41,7 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
41
41
|
import com.facebook.react.bridge.ReadableMap;
|
|
42
42
|
import com.facebook.react.bridge.WritableMap;
|
|
43
43
|
import com.facebook.react.bridge.Arguments;
|
|
44
|
+
import android.graphics.Color;
|
|
44
45
|
|
|
45
46
|
public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventListener {
|
|
46
47
|
private static final String TAG = "ReactVdoPlayerView";
|
|
@@ -83,16 +84,10 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
83
84
|
// Get a handler that can be used to post to the main thread
|
|
84
85
|
mainHandler = new Handler(Looper.getMainLooper());
|
|
85
86
|
setKeepScreenOn(true);
|
|
87
|
+
setBackgroundColor(Color.BLACK);
|
|
86
88
|
|
|
87
89
|
eventEmitter = new VdoEventEmitter(context);
|
|
88
90
|
|
|
89
|
-
vdoPlayerUIFragment = new VdoPlayerUIFragment();
|
|
90
|
-
Bundle bundle = new Bundle();
|
|
91
|
-
bundle.putBoolean("showControls", false);
|
|
92
|
-
vdoPlayerUIFragment.setArguments(bundle);
|
|
93
|
-
fragmentManager = activity.getSupportFragmentManager();
|
|
94
|
-
initializePlayer();
|
|
95
|
-
|
|
96
91
|
int orientation = getResources().getConfiguration().orientation;
|
|
97
92
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
98
93
|
eventEmitter.isInitialPortrait();
|
|
@@ -398,6 +393,14 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
398
393
|
protected void onAttachedToWindow() {
|
|
399
394
|
Log.d(TAG, "onAttachedToWindow");
|
|
400
395
|
super.onAttachedToWindow();
|
|
396
|
+
if (vdoPlayerUIFragment == null) {
|
|
397
|
+
vdoPlayerUIFragment = new VdoPlayerUIFragment();
|
|
398
|
+
Bundle bundle = new Bundle();
|
|
399
|
+
bundle.putBoolean("showControls", false);
|
|
400
|
+
vdoPlayerUIFragment.setArguments(bundle);
|
|
401
|
+
fragmentManager = activity.getSupportFragmentManager();
|
|
402
|
+
initializePlayer();
|
|
403
|
+
}
|
|
401
404
|
if (playWhenReady) {
|
|
402
405
|
if (vdoPlayer != null) {
|
|
403
406
|
vdoPlayer.setPlayWhenReady(true);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
|
2
|
+
import { DownloadStatus } from './type';
|
|
3
|
+
|
|
4
|
+
const eventEmitter = new NativeEventEmitter();
|
|
5
|
+
|
|
6
|
+
const nativeEvents = ['onQueued', 'onChanged', 'onCompleted', 'onFailed', 'onDeleted'];
|
|
7
|
+
|
|
8
|
+
nativeEvents.forEach((name) => {
|
|
9
|
+
eventEmitter.addListener(name, (event: {mediaId: string, downloadStatus: DownloadStatus}) => {
|
|
10
|
+
_emitEvent(name, event.mediaId, event.downloadStatus);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
var _eventListeners: {[index: string]: any} = {};
|
|
15
|
+
|
|
16
|
+
var _emitEvent = (eventName: string, mediaId: string, downloadStatus: DownloadStatus) => {
|
|
17
|
+
if (!_eventListeners[eventName]) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
_eventListeners[eventName].forEach((fn: (mediaId: string, downloadStatus: DownloadStatus) => void) => fn(mediaId, downloadStatus));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var addEventListener = (eventName: string, fn: (mediaId: string, downloadStatus: DownloadStatus) => void) => {
|
|
24
|
+
const list = _eventListeners[eventName] = _eventListeners[eventName] || [];
|
|
25
|
+
list.push(fn);
|
|
26
|
+
return () => list.splice(list.findIndex((f: (mediaId: string, downloadStatus: DownloadStatus) => void) => f === fn), 1);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default addEventListener;
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
import { NativeModules } from 'react-native';
|
|
10
10
|
import addEventListener from './downloadMonitor';
|
|
11
|
+
import * as VdoTypes from './type';
|
|
11
12
|
|
|
12
13
|
const { VdoDownload } = NativeModules;
|
|
13
14
|
|
|
14
|
-
const getDownloadOptions = (optionParams) => {
|
|
15
|
+
const getDownloadOptions = (optionParams: VdoTypes.EmbedInfo) => {
|
|
15
16
|
|
|
16
17
|
return new Promise(function(resolve, reject) {
|
|
17
18
|
VdoDownload.getDownloadOptions(
|
|
18
19
|
optionParams,
|
|
19
|
-
(errorDescription) => {
|
|
20
|
+
(errorDescription: {errorCode: number, errorMsg: string, httpStatusCode: number}) => {
|
|
20
21
|
reject(errorDescription);
|
|
21
22
|
},
|
|
22
|
-
(nativeId, downloadOptions) => {
|
|
23
|
+
(nativeId: string, downloadOptions: VdoTypes.DownloadOptions) => {
|
|
23
24
|
resolve({
|
|
24
25
|
downloadOptions,
|
|
25
26
|
enqueue: getEnqueueFn(nativeId)
|
|
@@ -29,9 +30,9 @@ const getDownloadOptions = (optionParams) => {
|
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
const getEnqueueFn = (nativeId) => (downloadOptions) => {
|
|
33
|
+
const getEnqueueFn = (nativeId: string) => (downloadOptions: {selections: Array<number>}) => {
|
|
33
34
|
|
|
34
|
-
return new Promise(function(resolve, reject) {
|
|
35
|
+
return new Promise<void>(function(resolve, reject) {
|
|
35
36
|
const requestOptions = {
|
|
36
37
|
selections: downloadOptions.selections
|
|
37
38
|
};
|
|
@@ -39,7 +40,7 @@ const getEnqueueFn = (nativeId) => (downloadOptions) => {
|
|
|
39
40
|
VdoDownload.enqueueDownload(
|
|
40
41
|
nativeId,
|
|
41
42
|
requestOptions,
|
|
42
|
-
(exception, msg) => {
|
|
43
|
+
(exception: string | null, msg: string) => {
|
|
43
44
|
reject({exception, msg});
|
|
44
45
|
},
|
|
45
46
|
() => {
|
|
@@ -50,15 +51,15 @@ const getEnqueueFn = (nativeId) => (downloadOptions) => {
|
|
|
50
51
|
});
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
const query = (queryFilters) => {
|
|
54
|
+
const query = (queryFilters: {mediaId: Array<string>, status: Array<string>}) => {
|
|
54
55
|
|
|
55
56
|
return new Promise(function(resolve, reject) {
|
|
56
57
|
VdoDownload.query(
|
|
57
58
|
queryFilters,
|
|
58
|
-
(exception, msg) => {
|
|
59
|
+
(exception: string, msg: string) => {
|
|
59
60
|
reject({exception, msg});
|
|
60
61
|
},
|
|
61
|
-
(downloadStatusArray) => {
|
|
62
|
+
(downloadStatusArray: Array<VdoTypes.DownloadStatus>) => {
|
|
62
63
|
// Query completed
|
|
63
64
|
resolve(downloadStatusArray);
|
|
64
65
|
}
|
|
@@ -66,12 +67,12 @@ const query = (queryFilters) => {
|
|
|
66
67
|
});
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
const remove = (mediaIds) => {
|
|
70
|
+
const remove = (mediaIds: Array<string>) => {
|
|
70
71
|
|
|
71
|
-
return new Promise(function(resolve, reject) {
|
|
72
|
+
return new Promise<void>(function(resolve, reject) {
|
|
72
73
|
VdoDownload.remove(
|
|
73
74
|
mediaIds,
|
|
74
|
-
(exception, msg) => {
|
|
75
|
+
(exception: string, msg: string) => {
|
|
75
76
|
reject({exception, msg});
|
|
76
77
|
},
|
|
77
78
|
() => {
|
|
@@ -82,6 +83,8 @@ const remove = (mediaIds) => {
|
|
|
82
83
|
});
|
|
83
84
|
};
|
|
84
85
|
|
|
86
|
+
export default VdoDownload;
|
|
87
|
+
|
|
85
88
|
module.exports = {
|
|
86
89
|
getDownloadOptions,
|
|
87
90
|
query,
|