vdocipher-rn-bridge 1.12.2 → 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 CHANGED
@@ -1,4 +1,6 @@
1
1
  ## Changelog
2
+ ### 1.12.3
3
+ * Adding typescript support
2
4
 
3
5
  ### 1.12.2
4
6
  * Bug fix
@@ -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
- class VdoPlayerSupportView extends Component {
9
+ const VdoViewPropTypes = VdoPropTypes;
10
+ type MyProps = InferProps<typeof VdoViewPropTypes>;
8
11
 
9
- constructor(props) {
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', VdoPlayerSupportView, {
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
- constructor(props) {
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
- render() {
95
- return (
96
- <RCTVdoPlayerUIView ref={component => this._root = component}
97
- {...this.props}
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', VdoPlayerUIView, {
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;
@@ -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.2"
22
- def releaseVersionCode = 13
21
+ def releaseVersionName = "1.12.3"
22
+ def releaseVersionCode = 14
23
23
 
24
24
  android {
25
25
  compileSdkVersion 33
@@ -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,
@@ -12,10 +12,11 @@
12
12
  import { NativeModules } from 'react-native';
13
13
  import VdoPlayerView from './VdoPlayerView';
14
14
  import VdoDownload from './downloads';
15
+ import { EmbedInfo } from './type';
15
16
 
16
17
  const { VdocipherRnBridge } = NativeModules;
17
18
 
18
- const startVideoScreen = (params) => {
19
+ const startVideoScreen = (params: {embedInfo: EmbedInfo}) => {
19
20
  VdocipherRnBridge.startVideoScreen(params);
20
21
  }
21
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
4
4
  "description": "React native bridge library that delegates to vdocipher native android SDK",
5
5
  "homepage": "https://www.vdocipher.com/docs/mobile/react-native/getting-started/",
6
6
  "scripts": {
@@ -22,12 +22,23 @@
22
22
  "android/build.gradle",
23
23
  "android/src",
24
24
  "ios",
25
- "VdoPlayerView.js",
26
- "VdoPlayerSupportView.js",
27
- "VdoPlayerUIView.js",
28
- "downloads.js",
29
- "downloadMonitor.js",
30
- "index.android.js",
31
- "index.ios.js"
32
- ]
25
+ "VdoPlayerView.tsx",
26
+ "VdoPlayerSupportView.tsx",
27
+ "VdoPlayerUIView.tsx",
28
+ "downloads.ts",
29
+ "downloadMonitor.ts",
30
+ "index.ts",
31
+ "tsconfig.json",
32
+ "type.ts"
33
+ ],
34
+ "devDependencies": {
35
+ "@tsconfig/react-native": "^2.0.3",
36
+ "@types/jest": "^29.4.0",
37
+ "@types/node": "^18.11.18",
38
+ "@types/prop-types": "^15.7.5",
39
+ "@types/react": "18.0.0",
40
+ "@types/react-native": "0.70",
41
+ "@types/react-test-renderer": "^18.0.0",
42
+ "typescript": "^4.9.4"
43
+ }
33
44
  }
package/tsconfig.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ "jsx": "react-native", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "ES6", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ "typeRoots": ["./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ "types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files. */
39
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+
71
+ /* Interop Constraints */
72
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
+ "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
+
78
+ /* Type Checking */
79
+ "strict": true, /* Enable all strict type-checking options. */
80
+ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
+
99
+ /* Completeness */
100
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
+ }
103
+ }
104
+
105
+ // {
106
+ // "extends": "@tsconfig/react-native/tsconfig.json"
107
+ // }
package/type.ts ADDED
@@ -0,0 +1,151 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ export interface EmbedInfo {
4
+ otp: string;
5
+ playbackInfo: string;
6
+ forceLowestBitrate?: boolean | null;
7
+ forceHighestSupportedBitrate?: boolean | null;
8
+ maxVideoBitrateKbps?: number | null;
9
+ bufferingGoalMs?: number | null;
10
+ enableAutoResume?: boolean | null;
11
+ safetyNetApiKey?: string | null;
12
+ preferredCaptionsLanguage?: string | null;
13
+ playerConfig?: string | null;
14
+ setPictureInPictureSupport?: boolean | null;
15
+ }
16
+
17
+ export type OfflineEmbedInfo = {
18
+ offline: boolean;
19
+ mediaId: string;
20
+ enableAutoResume?: boolean | null;
21
+ safetyNetApiKey?: string | null;
22
+ preferredCaptionsLanguage?: string | null;
23
+ playerConfig?: string | null;
24
+ setPictureInPictureSupport?: boolean | null;
25
+ }
26
+
27
+ export interface MediaInfo {
28
+ mediaId: string;
29
+ type: string;
30
+ title: string;
31
+ description: string;
32
+ duration: number;
33
+ }
34
+
35
+ export interface DownloadOptions {
36
+ mediaId: string;
37
+ mediaInfo: MediaInfo;
38
+ availableTracks: Array<Track>;
39
+ }
40
+
41
+ export interface Track {
42
+ id: number;
43
+ type: string;
44
+ language: string;
45
+ bitrate: number;
46
+ width: number;
47
+ height: number;
48
+ label: string;
49
+ }
50
+
51
+ export interface DownloadStatus {
52
+ mediaInfo: MediaInfo;
53
+ localStorageFolder: string;
54
+ status: string;
55
+ reason: number;
56
+ reasonDescription: string;
57
+ totalSizeBytes: number;
58
+ bytesDownloaded: number;
59
+ downloadPercent: number;
60
+ poster: string;
61
+ lastModifiedTimestamp: number;
62
+ }
63
+
64
+ export interface VideoQuality {
65
+ id: number;
66
+ bitrate: number;
67
+ width: number;
68
+ height: number;
69
+ }
70
+
71
+ export interface AudioQuality {
72
+ id: number;
73
+ bitrate: number;
74
+ width: number;
75
+ height: number;
76
+ }
77
+
78
+ export interface CaptionLanguage {
79
+ id: number;
80
+ language: string;
81
+ label: string;
82
+ }
83
+
84
+ export const VdoPropTypes = {
85
+ /* Native only */
86
+ onInitSuccess: PropTypes.func,
87
+ onInitFailure: PropTypes.func,
88
+ onVdoLoading: PropTypes.func,
89
+ onVdoLoaded: PropTypes.func,
90
+ onVdoLoadError: PropTypes.func,
91
+ onVdoPlayerStateChanged: PropTypes.func,
92
+ onVdoProgress: PropTypes.func,
93
+ onVdoBufferUpdate: PropTypes.func,
94
+ onVdoPlaybackSpeedChanged: PropTypes.func,
95
+ onVdoTracksChanged: PropTypes.func,
96
+ onVdoMediaEnded: PropTypes.func,
97
+ onVdoError: PropTypes.func,
98
+ playbackProperties: PropTypes.number,
99
+ onVdoPlaybackProperties: PropTypes.func,
100
+ seek: PropTypes.number,
101
+ fullscreen: PropTypes.bool,
102
+ onVdoEnterFullscreen: PropTypes.func,
103
+ onVdoExitFullscreen: PropTypes.func,
104
+ onIsInitialPortrait: PropTypes.func,
105
+ onVdoPictureInPictureModeChanged: PropTypes.func,
106
+
107
+ /* Wrapper component public api */
108
+ embedInfo: PropTypes.oneOfType([
109
+ PropTypes.shape({
110
+ otp: PropTypes.string.isRequired,
111
+ playbackInfo: PropTypes.string.isRequired,
112
+ forceLowestBitrate: PropTypes.bool,
113
+ forceHighestSupportedBitrate: PropTypes.bool,
114
+ maxVideoBitrateKbps: PropTypes.number,
115
+ bufferingGoalMs: PropTypes.number,
116
+ enableAutoResume: PropTypes.bool,
117
+ safetyNetApiKey: PropTypes.string,
118
+ preferredCaptionsLanguage: PropTypes.string,
119
+ playerConfig: PropTypes.string,
120
+ setPictureInPictureSupport: PropTypes.bool,
121
+ }),
122
+ PropTypes.shape({
123
+ offline: PropTypes.bool.isRequired,
124
+ mediaId: PropTypes.string.isRequired,
125
+ enableAutoResume: PropTypes.bool,
126
+ safetyNetApiKey: PropTypes.string,
127
+ preferredCaptionsLanguage: PropTypes.string,
128
+ playerConfig: PropTypes.string,
129
+ setPictureInPictureSupport: PropTypes.bool,
130
+ })
131
+ ]).isRequired,
132
+ showNativeControls: PropTypes.bool,
133
+ playWhenReady: PropTypes.bool,
134
+ playbackSpeed: PropTypes.number,
135
+ onInitializationSuccess: PropTypes.func,
136
+ onInitializationFailure: PropTypes.func,
137
+ onLoading: PropTypes.func,
138
+ onLoaded: PropTypes.func,
139
+ onLoadError: PropTypes.func,
140
+ onPlayerStateChanged: PropTypes.func,
141
+ onProgress: PropTypes.func,
142
+ onBufferUpdate: PropTypes.func,
143
+ onPlaybackSpeedChanged: PropTypes.func,
144
+ onTracksChanged: PropTypes.func,
145
+ onMediaEnded: PropTypes.func,
146
+ onError: PropTypes.func,
147
+ onPlaybackProperties: PropTypes.func,
148
+ onEnterFullscreen: PropTypes.func,
149
+ onExitFullscreen: PropTypes.func,
150
+ onPictureInPictureModeChanged: PropTypes.func,
151
+ }
package/VdoPlayerView.js DELETED
@@ -1,352 +0,0 @@
1
- /**
2
- * VdoPlayerView component that can be dropped into a layout for video playback.
3
- */
4
- import React, { Component, Fragment } from 'react';
5
- import PropTypes from 'prop-types';
6
- import { BackHandler, NativeModules} from 'react-native';
7
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
8
- import VdoPlayerSupportView from './VdoPlayerSupportView';
9
- import VdoPlayerUIView from './VdoPlayerUIView';
10
- const { TrackSelection } = NativeModules;
11
-
12
- export default class VdoPlayerView extends Component {
13
-
14
- constructor(props) {
15
- super(props);
16
- this.state = {
17
- fullscreen: false,
18
- isInitialPortrait: true,
19
- isInPictureInPictureMode: false
20
- }
21
- this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
22
- this._propRef = 1;
23
- }
24
-
25
- componentDidMount() {
26
- BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
27
- }
28
-
29
- componentWillUnmount() {
30
- BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
31
- }
32
-
33
- handleBackButtonClick() {
34
- if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.state.isInitialPortrait) {
35
- this._vdoPlayerView.handleBackButtonClick();
36
- return true;
37
- }
38
- }
39
-
40
- seek = seekTargetMs => {
41
- if (this._vdoPlayerView) {
42
- this._vdoPlayerView.seek(seekTargetMs);
43
- }
44
- }
45
-
46
- enterFullscreen = () => {
47
- if (this._vdoPlayerView) {
48
- this._vdoPlayerView.enterFullscreen();
49
- }
50
- }
51
-
52
- exitFullscreen = () => {
53
- if (this._vdoPlayerView) {
54
- this._vdoPlayerView.exitFullscreen();
55
- }
56
- }
57
-
58
- getPlaybackProperties = () => {
59
- if (this._vdoPlayerView) {
60
- this._vdoPlayerView.getPlaybackProperties();
61
- }
62
- }
63
-
64
- isAdaptive = async() => {
65
- return new Promise(async(resolve) => { await TrackSelection.isAdaptive((isAdaptive) => {
66
- resolve(isAdaptive);
67
- });
68
- });
69
- }
70
-
71
- getVideoQualities = async() => {
72
- return new Promise(async(resolve) => { await TrackSelection.getVideoQualities((videoQualities) => {
73
- resolve(videoQualities);
74
- });
75
- });
76
- }
77
-
78
- getSelectedVideoQuality = async() => {
79
- return new Promise(async(resolve) => { await TrackSelection.getSelectedVideoQuality((selectedVideoQuality) => {
80
- resolve(selectedVideoQuality);
81
- });
82
- });
83
- }
84
-
85
- setVideoQuality = videoQuality => {
86
- if (this._vdoPlayerView) {
87
- this._vdoPlayerView.setVideoQuality(videoQuality);
88
- }
89
- }
90
-
91
- enableAdaptiveVideo = () => {
92
- if (this._vdoPlayerView) {
93
- this._vdoPlayerView.enableAdaptiveVideo();
94
- }
95
- }
96
-
97
- getSelectedAudioQuality = async() => {
98
- return new Promise(async(resolve) => { await TrackSelection.getSelectedAudioQuality((selectedAudioQuality) => {
99
- resolve(selectedAudioQuality);
100
- });
101
- });
102
- }
103
-
104
- getCaptionLanguages = async() => {
105
- return new Promise(async(resolve) => { await TrackSelection.getCaptionLanguages((captionLanguages) => {
106
- resolve(captionLanguages);
107
- });
108
- });
109
- }
110
-
111
- getSelectedCaptionLanguage = async() => {
112
- return new Promise(async(resolve) => { await TrackSelection.getSelectedCaptionLanguage((selectedCaptionLanguage) => {
113
- resolve(selectedCaptionLanguage);
114
- });
115
- });
116
- }
117
-
118
- setCaptionLanguage = captionLanguage => {
119
- if (this._vdoPlayerView) {
120
- this._vdoPlayerView.setCaptionLanguage(captionLanguage);
121
- }
122
- }
123
-
124
- disableCaptions = () => {
125
- if (this._vdoPlayerView) {
126
- this._vdoPlayerView.disableCaptions();
127
- }
128
- }
129
-
130
- getDuration = async() => {
131
- return new Promise(async(resolve) => { await TrackSelection.getDuration((duration) => {
132
- resolve(duration);
133
- });
134
- });
135
- }
136
-
137
- _onInitSuccess = (event) => {
138
- if (this.props.onInitializationSuccess) {
139
- this.props.onInitializationSuccess(event.nativeEvent);
140
- }
141
- }
142
-
143
- _onInitFailure = (event) => {
144
- if (this.props.onInitializationFailure) {
145
- this.props.onInitializationFailure(event.nativeEvent);
146
- }
147
- }
148
-
149
- _onLoading = (embedInfo, event) => {
150
- if (this.props.onLoading) {
151
- this.props.onLoading({embedInfo, ...event.nativeEvent});
152
- }
153
- }
154
-
155
- _onLoaded = (embedInfo, event) => {
156
- if (this.props.onLoaded) {
157
- this.props.onLoaded({embedInfo, ...event.nativeEvent});
158
- }
159
- }
160
-
161
- _onLoadError = (embedInfo, event) => {
162
- if (this.props.onLoadError) {
163
- this.props.onLoadError({embedInfo, ...event.nativeEvent});
164
- }
165
- }
166
-
167
- _onPlayerStateChanged = (event) => {
168
- if (this.props.onPlayerStateChanged) {
169
- this.props.onPlayerStateChanged(event.nativeEvent);
170
- }
171
- }
172
-
173
- _onProgress = (event) => {
174
- if (this.props.onProgress) {
175
- this.props.onProgress(event.nativeEvent);
176
- }
177
- }
178
-
179
- _onBufferUpdate = (event) => {
180
- if (this.props.onBufferUpdate) {
181
- this.props.onBufferUpdate(event.nativeEvent);
182
- }
183
- }
184
-
185
- _onPlaybackSpeedChanged = (event) => {
186
- if (this.props.onPlaybackSpeedChanged) {
187
- this.props.onPlaybackSpeedChanged(event.nativeEvent.playbackSpeed);
188
- }
189
- }
190
-
191
- _onTracksChanged = (event) => {
192
- if (this.props.onTracksChanged) {
193
- this.props.onTracksChanged(event.nativeEvent);
194
- }
195
- }
196
-
197
- _onMediaEnded = (embedInfo, event) => {
198
- if (this.props.onMediaEnded) {
199
- this.props.onMediaEnded({embedInfo, ...event.nativeEvent});
200
- }
201
- }
202
-
203
- _onError = (embedInfo, event) => {
204
- if (this.props.onError) {
205
- this.props.onError({embedInfo, ...event.nativeEvent});
206
- }
207
- }
208
-
209
- _onPlaybackProperties = (event) => {
210
- if (this.props.onPlaybackProperties) {
211
- this.props.onPlaybackProperties(event.nativeEvent);
212
- }
213
- }
214
-
215
- _onEnterFullscreen = () => {
216
- this.setState({
217
- fullscreen: true
218
- });
219
-
220
- if (this.props.onEnterFullscreen) {
221
- this.props.onEnterFullscreen();
222
- }
223
- }
224
-
225
- _onExitFullscreen = () => {
226
- this.setState({
227
- fullscreen: false
228
- });
229
-
230
- if (this.props.onExitFullscreen) {
231
- this.props.onExitFullscreen();
232
- }
233
- }
234
-
235
- _onIsInitialPortrait =(event) => {
236
- this.setState({
237
- isInitialPortrait: event.nativeEvent.isInitialPortrait
238
- });
239
- }
240
-
241
- _onPictureInPictureModeChanged = (event) => {
242
- this.setState({
243
- isInPictureInPictureMode: event.nativeEvent.isInPictureInPictureMode
244
- });
245
-
246
- if (this.props.onPictureInPictureModeChanged) {
247
- this.props.onPictureInPictureModeChanged(event.nativeEvent);
248
- }
249
- }
250
-
251
- render() {
252
- return (
253
- <Fragment>
254
- {
255
- this.props.showNativeControls === false ? (
256
- <VdoPlayerSupportView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
257
- onInitSuccess={this._onInitSuccess}
258
- onInitFailure={this._onInitFailure}
259
- onVdoLoading={((embedInfo) => (event) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
260
- onVdoLoaded={((embedInfo) => (event) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
261
- onVdoLoadError={((embedInfo) => (event) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
262
- onVdoPlayerStateChanged={this._onPlayerStateChanged}
263
- onVdoProgress={this._onProgress}
264
- onVdoBufferUpdate={this._onBufferUpdate}
265
- onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
266
- onVdoTracksChanged={this._onTracksChanged}
267
- onVdoMediaEnded={((embedInfo) => (event) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
268
- onVdoError={((embedInfo) => (event) => this._onError(embedInfo, event))(this.props.embedInfo)}
269
- onVdoPlaybackProperties={this._onPlaybackProperties}
270
- onVdoEnterFullscreen={this._onEnterFullscreen}
271
- onVdoExitFullscreen={this._onExitFullscreen}
272
- onIsInitialPortrait={this._onIsInitialPortrait}
273
- onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
274
- {...this.props}
275
- />
276
- ) :
277
- (
278
- <VdoPlayerUIView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
279
- onInitSuccess={this._onInitSuccess}
280
- onInitFailure={this._onInitFailure}
281
- onVdoLoading={((embedInfo) => (event) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
282
- onVdoLoaded={((embedInfo) => (event) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
283
- onVdoLoadError={((embedInfo) => (event) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
284
- onVdoPlayerStateChanged={this._onPlayerStateChanged}
285
- onVdoProgress={this._onProgress}
286
- onVdoBufferUpdate={this._onBufferUpdate}
287
- onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
288
- onVdoTracksChanged={this._onTracksChanged}
289
- onVdoMediaEnded={((embedInfo) => (event) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
290
- onVdoError={((embedInfo) => (event) => this._onError(embedInfo, event))(this.props.embedInfo)}
291
- onVdoPlaybackProperties={this._onPlaybackProperties}
292
- onVdoEnterFullscreen={this._onEnterFullscreen}
293
- onVdoExitFullscreen={this._onExitFullscreen}
294
- onIsInitialPortrait={this._onIsInitialPortrait}
295
- onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
296
- {...this.props}
297
- />
298
- )
299
- }
300
- </Fragment>
301
- )
302
- }
303
- }
304
-
305
- VdoPlayerView.propTypes = {
306
- /* Native only */
307
- onInitSuccess: PropTypes.func,
308
- onInitFailure: PropTypes.func,
309
- onVdoLoading: PropTypes.func,
310
- onVdoLoaded: PropTypes.func,
311
- onVdoLoadError: PropTypes.func,
312
- onVdoPlayerStateChanged: PropTypes.func,
313
- onVdoProgress: PropTypes.func,
314
- onVdoBufferUpdate: PropTypes.func,
315
- onVdoPlaybackSpeedChanged: PropTypes.func,
316
- onVdoTracksChanged: PropTypes.func,
317
- onVdoMediaEnded: PropTypes.func,
318
- onVdoError: PropTypes.func,
319
- playbackProperties: PropTypes.number,
320
- onVdoPlaybackProperties: PropTypes.func,
321
- seek: PropTypes.number,
322
- fullscreen: PropTypes.bool,
323
- onVdoEnterFullscreen: PropTypes.func,
324
- onVdoExitFullscreen: PropTypes.func,
325
- onIsInitialPortrait: PropTypes.func,
326
- onVdoPictureInPictureModeChanged: PropTypes.func,
327
-
328
- /* Wrapper component public api */
329
- embedInfo: PropTypes.object,
330
- showNativeControls: PropTypes.bool,
331
- playWhenReady: PropTypes.bool,
332
- playbackSpeed: PropTypes.number,
333
- onInitializationSuccess: PropTypes.func,
334
- onInitializationFailure: PropTypes.func,
335
- onLoading: PropTypes.func,
336
- onLoaded: PropTypes.func,
337
- onLoadError: PropTypes.func,
338
- onPlayerStateChanged: PropTypes.func,
339
- onProgress: PropTypes.func,
340
- onBufferUpdate: PropTypes.func,
341
- onPlaybackSpeedChanged: PropTypes.func,
342
- onTracksChanged: PropTypes.func,
343
- onMediaEnded: PropTypes.func,
344
- onError: PropTypes.func,
345
- onPlaybackProperties: PropTypes.func,
346
- onEnterFullscreen: PropTypes.func,
347
- onExitFullscreen: PropTypes.func,
348
- onPictureInPictureModeChanged: PropTypes.func,
349
-
350
- /* Required */
351
- ...ViewPropTypes,
352
- };
@@ -1,28 +0,0 @@
1
- import { NativeEventEmitter } from 'react-native';
2
-
3
- const eventEmitter = new NativeEventEmitter();
4
-
5
- const nativeEvents = ['onQueued', 'onChanged', 'onCompleted', 'onFailed', 'onDeleted'];
6
-
7
- nativeEvents.forEach((name) => {
8
- eventEmitter.addListener(name, (event) => {
9
- _emitEvent(name, event.mediaId, event.downloadStatus);
10
- });
11
- });
12
-
13
- var _eventListeners = {};
14
-
15
- var _emitEvent = (eventName, mediaId, downloadStatus) => {
16
- if (!_eventListeners[eventName]) {
17
- return;
18
- }
19
- _eventListeners[eventName].forEach((fn) => fn(mediaId, downloadStatus));
20
- };
21
-
22
- var addEventListener = (eventName, fn) => {
23
- const list = _eventListeners[eventName] = _eventListeners[eventName] || [];
24
- list.push(fn);
25
- return () => list.splice(list.findIndex((f) => f === fn), 1);
26
- };
27
-
28
- export default addEventListener;
package/index.ios.js DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * The native VdoCipher player module exposes a function 'startVideoScreen'
3
- * which takes the following parameters:
4
- *
5
- * 1. String params = json_stringify({
6
- * embedInfo: {
7
- * otp: string,
8
- * playbackInfo: string
9
- * }
10
- * })
11
- */
12
- import { NativeModules } from 'react-native';
13
- import VdoPlayerView from './VdoPlayerView';
14
-
15
- const { VdocipherRnBridge } = NativeModules;
16
-
17
- const startVideoScreen = (params) => {
18
- VdocipherRnBridge.startVideoScreen(params);
19
- }
20
-
21
- export {
22
- startVideoScreen,
23
- VdoPlayerView
24
- }