vdocipher-rn-bridge 1.9.2 → 1.10.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/CHANGELOG.md CHANGED
@@ -1,4 +1,17 @@
1
1
  ## Changelog
2
+ ### 1.10.0
3
+ * Updated VdoCipher android sdk dependency to 1.18.1
4
+ * Updated player with built-in controls to use Player-UI provided by native sdk
5
+ - The controls on this player can be managed using video dashboard
6
+ - All the controls like save offline, caption search, pip, etc which are present in Player-UI will be available in this player
7
+ - Player-UI is supported on tv only when using react-native-tvos library
8
+ * Added support for PIP
9
+ * Added support for setting preferred captions language
10
+ * Added support for safetynet
11
+ * Updated download implementation to use download feature provided by exoplayer
12
+ * Added support for react-native version 0.70
13
+ * Bug fixes
14
+
2
15
  ### 1.9.2
3
16
  * Migrating from jcenter to mavenCentral
4
17
 
@@ -0,0 +1,226 @@
1
+ /**
2
+ * VdoPlayerView component that can be dropped into a layout for video playback.
3
+ */
4
+ import React, { Component } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { requireNativeComponent, BackHandler} from 'react-native';
7
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
8
+
9
+ class VdoPlayerSupportView extends Component {
10
+
11
+ constructor(props) {
12
+ super(props);
13
+ this._propRef = 1;
14
+ }
15
+
16
+ handleBackButtonClick() {
17
+ this._root.setNativeProps({fullscreen: false});
18
+ }
19
+
20
+ seek = seekTargetMs => {
21
+ if (this._root) {
22
+ this._root.setNativeProps({seek: seekTargetMs});
23
+ }
24
+ }
25
+
26
+ enterFullscreen = () => {
27
+ if (this._root) {
28
+ this._root.setNativeProps({fullscreen: true});
29
+ }
30
+ }
31
+
32
+ exitFullscreen = () => {
33
+ if (this._root) {
34
+ this._root.setNativeProps({fullscreen: false});
35
+ }
36
+ }
37
+
38
+ getPlaybackProperties = () => {
39
+ if (this._root) {
40
+ this._root.setNativeProps({playbackProperties: this._propRef++});
41
+ }
42
+ }
43
+
44
+ _onInitSuccess = (event) => {
45
+ if (this.props.onInitializationSuccess) {
46
+ this.props.onInitializationSuccess(event.nativeEvent);
47
+ }
48
+ }
49
+
50
+ _onInitFailure = (event) => {
51
+ if (this.props.onInitializationFailure) {
52
+ this.props.onInitializationFailure(event.nativeEvent);
53
+ }
54
+ }
55
+
56
+ _onLoading = (embedInfo, event) => {
57
+ if (this.props.onLoading) {
58
+ this.props.onLoading({embedInfo, ...event.nativeEvent});
59
+ }
60
+ }
61
+
62
+ _onLoaded = (embedInfo, event) => {
63
+ if (this.props.onLoaded) {
64
+ this.props.onLoaded({embedInfo, ...event.nativeEvent});
65
+ }
66
+ }
67
+
68
+ _onLoadError = (embedInfo, event) => {
69
+ if (this.props.onLoadError) {
70
+ this.props.onLoadError({embedInfo, ...event.nativeEvent});
71
+ }
72
+ }
73
+
74
+ _onPlayerStateChanged = (event) => {
75
+ if (this.props.onPlayerStateChanged) {
76
+ this.props.onPlayerStateChanged(event.nativeEvent);
77
+ }
78
+ }
79
+
80
+ _onProgress = (event) => {
81
+ if (this.props.onProgress) {
82
+ this.props.onProgress(event.nativeEvent);
83
+ }
84
+ }
85
+
86
+ _onBufferUpdate = (event) => {
87
+ if (this.props.onBufferUpdate) {
88
+ this.props.onBufferUpdate(event.nativeEvent);
89
+ }
90
+ }
91
+
92
+ _onPlaybackSpeedChanged = (event) => {
93
+ if (this.props.onPlaybackSpeedChanged) {
94
+ this.props.onPlaybackSpeedChanged(event.nativeEvent.playbackSpeed);
95
+ }
96
+ }
97
+
98
+ _onTracksChanged = (event) => {
99
+ if (this.props.onTracksChanged) {
100
+ this.props.onTracksChanged(event.nativeEvent);
101
+ }
102
+ }
103
+
104
+ _onMediaEnded = (embedInfo, event) => {
105
+ if (this.props.onMediaEnded) {
106
+ this.props.onMediaEnded({embedInfo, ...event.nativeEvent});
107
+ }
108
+ }
109
+
110
+ _onError = (embedInfo, event) => {
111
+ if (this.props.onError) {
112
+ this.props.onError({embedInfo, ...event.nativeEvent});
113
+ }
114
+ }
115
+
116
+ _onPlaybackProperties = (event) => {
117
+ if (this.props.onPlaybackProperties) {
118
+ this.props.onPlaybackProperties(event.nativeEvent);
119
+ }
120
+ }
121
+
122
+ _onEnterFullscreen = () => {
123
+ if (this.props.onEnterFullscreen) {
124
+ this.props.onEnterFullscreen();
125
+ }
126
+ }
127
+
128
+ _onExitFullscreen = () => {
129
+ if (this.props.onExitFullscreen) {
130
+ this.props.onExitFullscreen();
131
+ }
132
+ }
133
+
134
+ _onIsInitialPortrait =(event) => {
135
+ if (this.props.onIsInitialPortrait) {
136
+ this.props.onIsInitialPortrait(event);
137
+ }
138
+ }
139
+
140
+ _onPictureInPictureModeChanged = (event) => {
141
+ if (this.props.onPictureInPictureModeChanged) {
142
+ this.props.onPictureInPictureModeChanged(event);
143
+ }
144
+ }
145
+
146
+ render() {
147
+ return (
148
+ <RCTVdoPlayerView ref={component => this._root = component}
149
+ onInitSuccess={this._onInitSuccess}
150
+ onInitFailure={this._onInitFailure}
151
+ onVdoLoading={((embedInfo) => (event) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
152
+ onVdoLoaded={((embedInfo) => (event) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
153
+ onVdoLoadError={((embedInfo) => (event) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
154
+ onVdoPlayerStateChanged={this._onPlayerStateChanged}
155
+ onVdoProgress={this._onProgress}
156
+ onVdoBufferUpdate={this._onBufferUpdate}
157
+ onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
158
+ onVdoTracksChanged={this._onTracksChanged}
159
+ onVdoMediaEnded={((embedInfo) => (event) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
160
+ onVdoError={((embedInfo) => (event) => this._onError(embedInfo, event))(this.props.embedInfo)}
161
+ onVdoPlaybackProperties={this._onPlaybackProperties}
162
+ onVdoEnterFullscreen={this._onEnterFullscreen}
163
+ onVdoExitFullscreen={this._onExitFullscreen}
164
+ onIsInitialPortrait={this._onIsInitialPortrait}
165
+ onPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
166
+ {...this.props}
167
+ />
168
+ )
169
+ }
170
+ }
171
+
172
+ VdoPlayerSupportView.propTypes = {
173
+ /* Native only */
174
+ onInitSuccess: PropTypes.func,
175
+ onInitFailure: PropTypes.func,
176
+ onVdoLoading: PropTypes.func,
177
+ onVdoLoaded: PropTypes.func,
178
+ onVdoLoadError: PropTypes.func,
179
+ onVdoPlayerStateChanged: PropTypes.func,
180
+ onVdoProgress: PropTypes.func,
181
+ onVdoBufferUpdate: PropTypes.func,
182
+ onVdoPlaybackSpeedChanged: PropTypes.func,
183
+ onVdoTracksChanged: PropTypes.func,
184
+ onVdoMediaEnded: PropTypes.func,
185
+ onVdoError: PropTypes.func,
186
+ playbackProperties: PropTypes.number,
187
+ onVdoPlaybackProperties: PropTypes.func,
188
+ seek: PropTypes.number,
189
+ fullscreen: PropTypes.bool,
190
+ onVdoEnterFullscreen: PropTypes.func,
191
+ onVdoExitFullscreen: PropTypes.func,
192
+ onIsInitialPortrait: PropTypes.func,
193
+
194
+ /* Wrapper component public api */
195
+ embedInfo: PropTypes.object,
196
+ playWhenReady: PropTypes.bool,
197
+ playbackSpeed: PropTypes.number,
198
+ onInitializationSuccess: PropTypes.func,
199
+ onInitializationFailure: PropTypes.func,
200
+ onLoading: PropTypes.func,
201
+ onLoaded: PropTypes.func,
202
+ onLoadError: PropTypes.func,
203
+ onPlayerStateChanged: PropTypes.func,
204
+ onProgress: PropTypes.func,
205
+ onBufferUpdate: PropTypes.func,
206
+ onPlaybackSpeedChanged: PropTypes.func,
207
+ onTracksChanged: PropTypes.func,
208
+ onMediaEnded: PropTypes.func,
209
+ onError: PropTypes.func,
210
+ onPlaybackProperties: PropTypes.func,
211
+ onEnterFullscreen: PropTypes.func,
212
+ onExitFullscreen: PropTypes.func,
213
+ onPictureInPictureModeChanged: PropTypes.func,
214
+
215
+ /* Required */
216
+ ...ViewPropTypes,
217
+ };
218
+
219
+ var RCTVdoPlayerView = requireNativeComponent('RCTVdoPlayerView', VdoPlayerSupportView, {
220
+ nativeOnly: {
221
+ onInitSuccess: true,
222
+ onInitFailure: true,
223
+ }
224
+ });
225
+
226
+ export default VdoPlayerSupportView;
@@ -0,0 +1,271 @@
1
+ /**
2
+ * VdoPlayerUIView component that can be dropped into a layout for video playback.
3
+ */
4
+ import React, { Component } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import {requireNativeComponent, Platform} from 'react-native';
7
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
8
+
9
+ class VdoPlayerUIView extends Component {
10
+ constructor(props) {
11
+ super(props);
12
+ this._propRef = 1;
13
+ }
14
+
15
+ componentDidMount() {
16
+ if (Platform.isTV) {
17
+ try {
18
+ this._enableTVEventHandler();
19
+ } catch (e) {
20
+ console.log("react-native tvos required for handling touch events");
21
+ }
22
+ }
23
+ }
24
+
25
+ componentWillUnmount() {
26
+ if (Platform.isTV) {
27
+ try {
28
+ this._disableTVEventHandler();
29
+ } catch (e) {}
30
+ }
31
+ }
32
+
33
+ _enableTVEventHandler() {
34
+ const {TVEventHandler} = require('react-native');
35
+ this._tvEventHandler = new TVEventHandler();
36
+ this._tvEventHandler.enable(this, function (cmp, evt) {
37
+ if (cmp._vdoPlayerView) {
38
+ if (evt && evt.eventType === "right") {
39
+ cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 22});
40
+ } else if (evt && evt.eventType === "left") {
41
+ cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 21});
42
+ } else if (evt && evt.eventType === "up") {
43
+ cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 24});
44
+ } else if (evt && evt.eventType === "down") {
45
+ cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 25});
46
+ } else if (evt && evt.eventType === "select") {
47
+ cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 23});
48
+ } else if (evt && evt.eventType === 'playPause') {
49
+ cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 23});
50
+ }
51
+ }
52
+ });
53
+ }
54
+
55
+ _disableTVEventHandler() {
56
+ if (this._tvEventHandler) {
57
+ this._tvEventHandler.disable();
58
+ delete this._tvEventHandler;
59
+ }
60
+ }
61
+
62
+ handleBackButtonClick() {
63
+ this._root.setNativeProps({fullscreen: false});
64
+ }
65
+
66
+ seek = seekTargetMs => {
67
+ if (this._root) {
68
+ this._root.setNativeProps({seek: seekTargetMs});
69
+ }
70
+ }
71
+
72
+ enterFullscreen = () => {
73
+ if (this._root) {
74
+ this._root.setNativeProps({fullscreen: true});
75
+ }
76
+ }
77
+
78
+ exitFullscreen = () => {
79
+ if (this._root) {
80
+ this._root.setNativeProps({fullscreen: false});
81
+ }
82
+ }
83
+
84
+ getPlaybackProperties = () => {
85
+ if (this._root) {
86
+ this._root.setNativeProps({playbackProperties: this._propRef++});
87
+ }
88
+ }
89
+
90
+ setKeyDownEvent = (keyDownEvent) => {
91
+ if (this._root) {
92
+ this._root.setNativeProps({keyDownEvent: keyDownEvent});
93
+ }
94
+ }
95
+
96
+ _onInitSuccess = (event) => {
97
+ if (this.props.onInitializationSuccess) {
98
+ this.props.onInitializationSuccess(event.nativeEvent);
99
+ }
100
+ }
101
+
102
+ _onInitFailure = (event) => {
103
+ if (this.props.onInitializationFailure) {
104
+ this.props.onInitializationFailure(event.nativeEvent);
105
+ }
106
+ }
107
+
108
+ _onLoading = (embedInfo, event) => {
109
+ if (this.props.onLoading) {
110
+ this.props.onLoading({embedInfo, ...event.nativeEvent});
111
+ }
112
+ }
113
+
114
+ _onLoaded = (embedInfo, event) => {
115
+ if (this.props.onLoaded) {
116
+ this.props.onLoaded({embedInfo, ...event.nativeEvent});
117
+ }
118
+ }
119
+
120
+ _onLoadError = (embedInfo, event) => {
121
+ if (this.props.onLoadError) {
122
+ this.props.onLoadError({embedInfo, ...event.nativeEvent});
123
+ }
124
+ }
125
+
126
+ _onPlayerStateChanged = (event) => {
127
+ if (this.props.onPlayerStateChanged) {
128
+ this.props.onPlayerStateChanged(event.nativeEvent);
129
+ }
130
+ }
131
+
132
+ _onProgress = (event) => {
133
+ if (this.props.onProgress) {
134
+ this.props.onProgress(event.nativeEvent);
135
+ }
136
+ }
137
+
138
+ _onBufferUpdate = (event) => {
139
+ if (this.props.onBufferUpdate) {
140
+ this.props.onBufferUpdate(event.nativeEvent);
141
+ }
142
+ }
143
+
144
+ _onPlaybackSpeedChanged = (event) => {
145
+ if (this.props.onPlaybackSpeedChanged) {
146
+ this.props.onPlaybackSpeedChanged(event.nativeEvent.playbackSpeed);
147
+ }
148
+ }
149
+
150
+ _onTracksChanged = (event) => {
151
+ if (this.props.onTracksChanged) {
152
+ this.props.onTracksChanged(event.nativeEvent);
153
+ }
154
+ }
155
+
156
+ _onMediaEnded = (embedInfo, event) => {
157
+ if (this.props.onMediaEnded) {
158
+ this.props.onMediaEnded({embedInfo, ...event.nativeEvent});
159
+ }
160
+ }
161
+
162
+ _onError = (embedInfo, event) => {
163
+ if (this.props.onError) {
164
+ this.props.onError({embedInfo, ...event.nativeEvent});
165
+ }
166
+ }
167
+
168
+ _onPlaybackProperties = (event) => {
169
+ if (this.props.onPlaybackProperties) {
170
+ this.props.onPlaybackProperties(event.nativeEvent);
171
+ }
172
+ }
173
+
174
+ _onEnterFullscreen = () => {
175
+ if (this.props.onEnterFullscreen) {
176
+ this.props.onEnterFullscreen();
177
+ }
178
+ }
179
+
180
+ _onExitFullscreen = () => {
181
+ if (this.props.onExitFullscreen) {
182
+ this.props.onExitFullscreen();
183
+ }
184
+ }
185
+
186
+ _onIsInitialPortrait =(event) => {
187
+ if (this.props.onIsInitialPortrait) {
188
+ this.props.onIsInitialPortrait(event);
189
+ }
190
+ }
191
+
192
+ render() {
193
+ return (
194
+ <RCTVdoPlayerUIView ref={component => this._root = component}
195
+ onInitSuccess={this._onInitSuccess}
196
+ onInitFailure={this._onInitFailure}
197
+ onVdoLoading={((embedInfo) => (event) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
198
+ onVdoLoaded={((embedInfo) => (event) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
199
+ onVdoLoadError={((embedInfo) => (event) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
200
+ onVdoPlayerStateChanged={this._onPlayerStateChanged}
201
+ onVdoProgress={this._onProgress}
202
+ onVdoBufferUpdate={this._onBufferUpdate}
203
+ onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
204
+ onVdoTracksChanged={this._onTracksChanged}
205
+ onVdoMediaEnded={((embedInfo) => (event) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
206
+ onVdoError={((embedInfo) => (event) => this._onError(embedInfo, event))(this.props.embedInfo)}
207
+ onVdoPlaybackProperties={this._onPlaybackProperties}
208
+ onVdoEnterFullscreen={this._onEnterFullscreen}
209
+ onVdoExitFullscreen={this._onExitFullscreen}
210
+ onIsInitialPortrait={this._onIsInitialPortrait}
211
+ {...this.props}
212
+ />
213
+ );
214
+ }
215
+ }
216
+
217
+ VdoPlayerUIView.propTypes = {
218
+ /* Native only */
219
+ onInitSuccess: PropTypes.func,
220
+ onInitFailure: PropTypes.func,
221
+ onVdoLoading: PropTypes.func,
222
+ onVdoLoaded: PropTypes.func,
223
+ onVdoLoadError: PropTypes.func,
224
+ onVdoPlayerStateChanged: PropTypes.func,
225
+ onVdoProgress: PropTypes.func,
226
+ onVdoBufferUpdate: PropTypes.func,
227
+ onVdoPlaybackSpeedChanged: PropTypes.func,
228
+ onVdoTracksChanged: PropTypes.func,
229
+ onVdoMediaEnded: PropTypes.func,
230
+ onVdoError: PropTypes.func,
231
+ playbackProperties: PropTypes.number,
232
+ keyDownEvent: PropTypes.object,
233
+ onVdoPlaybackProperties: PropTypes.func,
234
+ seek: PropTypes.number,
235
+ fullscreen: PropTypes.bool,
236
+ onVdoEnterFullscreen: PropTypes.func,
237
+ onVdoExitFullscreen: PropTypes.func,
238
+ onIsInitialPortrait: PropTypes.func,
239
+
240
+ /* Wrapper component public api */
241
+ embedInfo: PropTypes.object,
242
+ playWhenReady: PropTypes.bool,
243
+ playbackSpeed: PropTypes.number,
244
+ onInitializationSuccess: PropTypes.func,
245
+ onInitializationFailure: PropTypes.func,
246
+ onLoading: PropTypes.func,
247
+ onLoaded: PropTypes.func,
248
+ onLoadError: PropTypes.func,
249
+ onPlayerStateChanged: PropTypes.func,
250
+ onProgress: PropTypes.func,
251
+ onBufferUpdate: PropTypes.func,
252
+ onPlaybackSpeedChanged: PropTypes.func,
253
+ onTracksChanged: PropTypes.func,
254
+ onMediaEnded: PropTypes.func,
255
+ onError: PropTypes.func,
256
+ onPlaybackProperties: PropTypes.func,
257
+ onEnterFullscreen: PropTypes.func,
258
+ onExitFullscreen: PropTypes.func,
259
+
260
+ /* Required */
261
+ ...ViewPropTypes,
262
+ };
263
+
264
+ var RCTVdoPlayerUIView = requireNativeComponent('RCTVdoPlayerUIView', VdoPlayerUIView, {
265
+ nativeOnly: {
266
+ onInitSuccess: true,
267
+ onInitFailure: true,
268
+ }
269
+ });
270
+
271
+ export default VdoPlayerUIView;