vdocipher-rn-bridge 1.11.0 → 1.12.1

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,5 +1,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.12.1
4
+ * Adding support of pip in separate activity
5
+
6
+ ### 1.12.0
7
+ * Updated VdoCipher android sdk dependency to 1.19.1
8
+ * Added track selection APIs
9
+
3
10
  ### 1.11.0
4
11
  * Updated VdoCipher android sdk dependency to 1.19.0
5
12
 
package/README.md CHANGED
@@ -1,347 +1,7 @@
1
-
2
1
  # vdocipher-rn-bridge
3
2
 
4
-
5
- ## Note:
6
-
7
- 1. IOS is not supported. Only Android support available. IOS support will be
8
- added in future.
9
- 2. Currently, it is not possible to get any events or callbacks from Android
10
- player activity. The video will open in a new _native_ activity outside of
11
- the react native setup. Back button will take the user from the player
12
- activity to home activity.
13
-
14
3
  React native library for integrating vdocipher android sdk into your react native app.
15
4
 
16
- ## Getting started
17
-
18
- `$ npm install vdocipher-rn-bridge --save`
19
-
20
- For installation you can choose either automatic or manual installation:
21
-
22
- **Note**: If your app uses react-native version >= 0.60.0, you can skip the linking
23
- instructions. No explicit linking is required as new rn versions use
24
- [autolinking](https://facebook.github.io/react-native/blog/2019/07/03/version-60) for native modules.
25
-
26
- ### Automatic installation
27
-
28
- `$ react-native link vdocipher-rn-bridge`
29
-
30
- ### Manual installation
31
-
32
-
33
- #### iOS
34
-
35
- iOS is currently not supported.
36
-
37
- #### Android
38
-
39
- 1. Open up `android/app/src/main/java/[...]/MainActivity.java`
40
- - Add `import com.vdocipher.rnbridge.VdocipherRnBridgePackage;` to the imports at the top of the file
41
- - Add `new VdocipherRnBridgePackage()` to the list returned by the `getPackages()` method
42
- 2. Append the following lines to `android/settings.gradle`:
43
- ```
44
- include ':vdocipher-rn-bridge'
45
- project(':vdocipher-rn-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/vdocipher-rn-bridge/android')
46
- ```
47
- 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
48
- ```
49
- compile project(':vdocipher-rn-bridge')
50
- ```
51
-
52
- ### Installation troubleshooting
53
- If you encounter a build error for android project like _'Cannot find com.vdocipher.aegis:vdocipher-android:X.X.X',_
54
- you may need to add the following maven repository to your **android/build.gradle** under **allprojects -> repositories**:
55
-
56
- ```
57
- maven {
58
- url "https://github.com/VdoCipher/maven-repo/raw/master/repo"
59
- }
60
- ```
61
-
62
-
63
- ### Try the demo app
64
-
65
- To run the example react-native app included in this repo, clone this repo to your
66
- development machine, and run the example app:
67
-
68
- `$ mkdir vdocipher-react-native && cd vdocipher-react-native`
69
-
70
- `$ git clone https://github.com/VdoCipher/vdocipher-react-native.git .`
71
-
72
- `$ npm install && cd example && npm install`
73
-
74
- `$ npx react-native run-android`
75
-
76
5
  ## Usage
77
6
 
78
- For detailed usage of the library, refer the link [here.](https://www.vdocipher.com/docs/mobile/react-native/getting-started)
79
-
80
- ### Launch a video in a fullscreen player
81
-
82
- ```javascript
83
- import { startVideoScreen } from 'vdocipher-rn-bridge';
84
-
85
- startVideoScreen({embedInfo: {otp: 'some-otp', playbackInfo: 'some-playbackInfo'}});
86
- ```
87
-
88
- ### Embed a video in your react native layout
89
-
90
- ```javascript
91
- import { VdoPlayerView } from 'vdocipher-rn-bridge';
92
-
93
- const embedInfo = {otp: 'some-otp', playbackInfo: 'some-playbackInfo'};
94
-
95
- // in JSX
96
-
97
- <VdoPlayerView
98
- style={{height: 200, width: '100%'}}
99
- embedInfo={embedInfo}
100
- />
101
- ```
102
-
103
- ### VdoPlayerView props
104
-
105
- * [embedInfo](#embedinfo)
106
- * [showNativeControls](#shownativecontrols)
107
- * [playWhenReady](#playwhenready)
108
- * [playbackSpeed](#playbackspeed)
109
-
110
- ### VdoPlayerView event props
111
-
112
- * [onInitializationSuccess](#oninitializationsuccess)
113
- * [onInitializationFailure](#oninitializationfailure)
114
- * [onLoading](#onloading)
115
- * [onLoaded](#onloaded)
116
- * [onLoadError](#onloadError)
117
- * [onPlayerStateChanged](#onplayerstatechanged)
118
- * [onProgress](#onprogress)
119
- * [onBufferUpdate](#onbufferUpdate)
120
- * [onPlaybackSpeedChanged](#onplaybackspeedchanged)
121
- * [onTracksChanged](#ontrackschanged)
122
- * [onMediaEnded](#onmediaended)
123
- * [onError](#onerror)
124
- * [onEnterFullscreen](#onenterfullscreen)
125
- * [onExitFullscreen](#onexitfullscreen)
126
- * [onPlaybackProperties](#onplaybackproperties)
127
- * [onPictureInPictureModeChanged](#onPictureInPictureModeChanged)
128
-
129
- ### VdoPlayerView methods
130
-
131
- * [seek](#seek)
132
- * [enterFullscreen](#enterfullscreen)
133
- * [exitFullscreen](#exitfullscreen)
134
- * [getPlaybackProperties](#getplaybackproperties)
135
-
136
- ### Props
137
-
138
- #### embedInfo
139
-
140
- Property | Type | Description
141
- --- | --- | ---
142
- otp | string | a valid otp
143
- playbackInfo | string | a valid playbackInfo
144
- forceLowestBitrate | boolean | whether to force lowest bitrate; default: `false`
145
- forceHighestSupportedBitrate | boolean | whether to force highest supported bitrate; default: `false`
146
- maxVideoBitrateKbps | number | maximum allowed video bitrate in kbps
147
- bufferingGoalMs | number | buffering goal in milliseconds, NOT recommended to change this value for most use cases; cannot be set to a value less than 15000
148
- enableAutoResume | boolean | whether to auto resume from last saved position or play from the beginning, default: `false`.
149
- safetyNetApiKey | string | safetynet api key to be used for safetynet verification
150
- preferredCaptionsLanguage | string | language code for the preferred captions language
151
- playerConfig | string | player configuration id from dashboard to be used for player
152
- setPictureInPictureSupport | boolean | whether to enable picture in picture support, default: `false`.
153
-
154
- #### showNativeControls
155
-
156
- Controls whether natively embedded player controls are shown.
157
- * **true (default)** - show native controls
158
- * **false** - hide native controls
159
-
160
- #### playWhenReady
161
-
162
- Controls whether playback will progress if the player is in ready state.
163
- * **true (default)** - play when ready
164
- * **false** - pause playback
165
-
166
- #### playbackSpeed
167
-
168
- Controls the playback speed; can be used once the player is loaded.
169
- * **1.0 (default)** - play at normal speed of the video
170
- * **Other values** - slow down or speed up playback
171
-
172
- ### Event props
173
-
174
- #### onInitializationSuccess
175
- Callback function invoked when a native `VdoPlayer` is created.
176
-
177
- Typically, no handling is required when this is called. The internal player will automatically load the `embedInfo` provided in props.
178
-
179
- #### onInitializationFailure
180
- Callback function invoked when a `VdoPlayer` creation failed due to some reason. Playback will not happen.
181
-
182
- The error details are provided in the payload under `errorDescription`.
183
-
184
- Payload:
185
-
186
- Property | Type | Description
187
- --- | --- | ---
188
- errorDescription | object | error details
189
-
190
- `errorDescription`:
191
-
192
- Property | Type | Description
193
- --- | --- | ---
194
- errorCode | number | an integer identifying the error
195
- errorMsg | string | short message description of the error
196
- httpStatusCode | number | http status code if relevant, -1 otherwise
197
-
198
- #### onLoading
199
- Callback function invoked when a new video starts loading.
200
-
201
- #### onLoaded
202
- Callback function invoked when a new video has successfully loaded. Playback can begin now.
203
-
204
- #### onLoadError
205
- Callback function invoked when a video failed to load due to some reason.
206
-
207
- The error details are provided in the payload under `errorDescription`.
208
-
209
- Payload:
210
-
211
- Property | Type | Description
212
- --- | --- | ---
213
- errorDescription | object | error details
214
- embedInfo | object | embedInfo for which the error occurred
215
-
216
- `errorDescription`:
217
-
218
- Property | Type | Description
219
- --- | --- | ---
220
- errorCode | number | an integer identifying the error
221
- errorMsg | string | short message description of the error
222
- httpStatusCode | number | http status code if relevant, -1 otherwise
223
-
224
- #### onPlayerStateChanged
225
- Callback function invoked when player state changes.
226
-
227
- Payload:
228
-
229
- Property | Type | Description
230
- --- | --- | ---
231
- playerState | string | one of 'idle', 'buffering', 'ready' or 'ended'
232
- playWhenReady | boolean | whether playback will progress if playerState is 'ready'
233
-
234
- #### onProgress
235
- Callback function invoked to provided playback time updates.
236
-
237
- Payload:
238
-
239
- Property | Type | Description
240
- --- | --- | ---
241
- currentTime | number | current playback time in milliseconds
242
-
243
- #### onBufferUpdate
244
- Callback function invoked to provide buffered time updates.
245
-
246
- Payload:
247
-
248
- Property | Type | Description
249
- --- | --- | ---
250
- bufferTime | number | current buffered time in milliseconds
251
-
252
- #### onPlaybackSpeedChanged
253
- Callback function invoked when playback speed changes.
254
-
255
- Payload:
256
-
257
- Property | Type | Description
258
- --- | --- | ---
259
- playbackSpeed | number | current playback speed
260
-
261
- #### onTracksChanged
262
- Callback function invoked when available or selected track changes.
263
-
264
- Payload:
265
-
266
- Property | Type | Description
267
- --- | --- | ---
268
- availableTracks | object[] | array of available `track` objects
269
- selectedTracks | object[] | array of currently selected `track` objects
270
-
271
- `track`:
272
-
273
- Property | Type | Description
274
- --- | --- | ---
275
- id | number | an integer identifying the track
276
- type | string | one of 'audio', 'video', 'captions', 'combined' or 'unknown'
277
- language | string | optional: language of track if relevant
278
- bitrate | number | optional: bitrate in bps if relevant
279
- width | number | optional: width resolution if relevant
280
- height | number | optional: height resolution if relevant otherwise
281
-
282
- #### onMediaEnded
283
- Callback function invoked when a video reached end of playback.
284
-
285
- #### onError
286
- Callback function invoked when video playback is interrupted due to an error.
287
-
288
- The error details are provided in the payload under `errorDescription`.
289
-
290
- Payload:
291
-
292
- Property | Type | Description
293
- --- | --- | ---
294
- errorDescription | object | error details
295
- embedInfo | object | embedInfo for which the error occurred
296
-
297
- `errorDescription`:
298
-
299
- Property | Type | Description
300
- --- | --- | ---
301
- errorCode | number | an integer identifying the error
302
- errorMsg | string | short message description of the error
303
- httpStatusCode | number | http status code if relevant, -1 otherwise
304
-
305
- #### onEnterFullscreen
306
- Callback function invoked when the player enters fullscreen.
307
-
308
- #### onExitFullscreen
309
- Callback function invoked when the player exits fullscreen.
310
-
311
- #### onPlaybackProperties
312
- Callback function invoked when additional playback properties are requested using the `getPlaybackProperties` method.
313
-
314
- #### onPictureInPictureModeChanged
315
- Callback function invoked to handle UI when the player enters or exits pip mode
316
-
317
- Payload:
318
-
319
- Property | Type | Description
320
- --- | --- | ---
321
- isInPictureInPictureMode | boolean | is player in pip mode
322
-
323
- ### Methods
324
-
325
- Methods operate on a ref to the VdoPlayerView element. You can create a ref like this:
326
- ```
327
- <VdoPlayerView ref={player => this._player = player}
328
- ```
329
-
330
- #### seek
331
- `seek(seekTargetMs)`
332
- Set the seek target in milli seconds
333
-
334
- #### enterFullscreen
335
- `enterFullscreen()`
336
-
337
- Enter fullscreen mode.
338
-
339
- #### exitFullscreen
340
- `exitFullscreen()`
341
-
342
- Exit fullscreen mode.
343
-
344
- #### getPlaybackProperties
345
- `getPlaybackProperties()`
346
-
347
- Request additional playback properties. The callback `onPlaybackProperties` is invoked with the results.
7
+ Usage instructions available on our [documentation page for React Native](https://www.vdocipher.com/docs/mobile/react-native/getting-started)
@@ -2,9 +2,7 @@
2
2
  * VdoPlayerView component that can be dropped into a layout for video playback.
3
3
  */
4
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';
5
+ import { requireNativeComponent} from 'react-native';
8
6
 
9
7
  class VdoPlayerSupportView extends Component {
10
8
 
@@ -41,182 +39,39 @@ class VdoPlayerSupportView extends Component {
41
39
  }
42
40
  }
43
41
 
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();
42
+ setVideoQuality = videoQuality => {
43
+ if (this._root) {
44
+ this._root.setNativeProps({videoQuality: videoQuality});
125
45
  }
126
46
  }
127
47
 
128
- _onExitFullscreen = () => {
129
- if (this.props.onExitFullscreen) {
130
- this.props.onExitFullscreen();
48
+ enableAdaptiveVideo = () => {
49
+ if (this._root) {
50
+ this._root.setNativeProps({adaptiveVideo: this._propRef++});
131
51
  }
132
52
  }
133
53
 
134
- _onIsInitialPortrait =(event) => {
135
- if (this.props.onIsInitialPortrait) {
136
- this.props.onIsInitialPortrait(event);
54
+ setCaptionLanguage = captionLanguage => {
55
+ if (this._root) {
56
+ this._root.setNativeProps({captionLanguage: captionLanguage});
137
57
  }
138
58
  }
139
59
 
140
- _onPictureInPictureModeChanged = (event) => {
141
- if (this.props.onPictureInPictureModeChanged) {
142
- this.props.onPictureInPictureModeChanged(event.nativeEvent);
60
+ disableCaptions = () => {
61
+ if (this._root) {
62
+ this._root.setNativeProps({disableCaptions: this._propRef++});
143
63
  }
144
64
  }
145
65
 
146
66
  render() {
147
67
  return (
148
68
  <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
- onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
166
69
  {...this.props}
167
70
  />
168
71
  )
169
72
  }
170
73
  }
171
74
 
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
- onVdoPictureInPictureModeChanged: PropTypes.func,
194
-
195
- /* Wrapper component public api */
196
- embedInfo: PropTypes.object,
197
- playWhenReady: PropTypes.bool,
198
- playbackSpeed: PropTypes.number,
199
- onInitializationSuccess: PropTypes.func,
200
- onInitializationFailure: PropTypes.func,
201
- onLoading: PropTypes.func,
202
- onLoaded: PropTypes.func,
203
- onLoadError: PropTypes.func,
204
- onPlayerStateChanged: PropTypes.func,
205
- onProgress: PropTypes.func,
206
- onBufferUpdate: PropTypes.func,
207
- onPlaybackSpeedChanged: PropTypes.func,
208
- onTracksChanged: PropTypes.func,
209
- onMediaEnded: PropTypes.func,
210
- onError: PropTypes.func,
211
- onPlaybackProperties: PropTypes.func,
212
- onEnterFullscreen: PropTypes.func,
213
- onExitFullscreen: PropTypes.func,
214
- onPictureInPictureModeChanged: PropTypes.func,
215
-
216
- /* Required */
217
- ...ViewPropTypes,
218
- };
219
-
220
75
  var RCTVdoPlayerView = requireNativeComponent('RCTVdoPlayerView', VdoPlayerSupportView, {
221
76
  nativeOnly: {
222
77
  onInitSuccess: true,