vdocipher-rn-bridge 1.12.2 → 1.13.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/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
- }