vdocipher-rn-bridge 1.11.0 → 1.12.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 +4 -0
- package/README.md +167 -1
- package/VdoPlayerSupportView.js +13 -158
- package/VdoPlayerUIView.js +0 -161
- package/VdoPlayerView.js +84 -1
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +117 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +36 -1
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModule.java +86 -0
- package/android/src/main/java/com/vdocipher/rnbridge/Utils.java +83 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +9 -2
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgePackage.java +12 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -132,6 +132,17 @@ const embedInfo = {otp: 'some-otp', playbackInfo: 'some-playbackInfo'};
|
|
|
132
132
|
* [enterFullscreen](#enterfullscreen)
|
|
133
133
|
* [exitFullscreen](#exitfullscreen)
|
|
134
134
|
* [getPlaybackProperties](#getplaybackproperties)
|
|
135
|
+
* [isAdaptive](#isAdaptive)
|
|
136
|
+
* [getVideoQualities](#getVideoQualities)
|
|
137
|
+
* [getSelectedVideoQuality](#getSelectedVideoQuality)
|
|
138
|
+
* [setVideoQuality](#setVideoQuality)
|
|
139
|
+
* [enableAdaptiveVideo](#enableAdaptiveVideo)
|
|
140
|
+
* [getSelectedAudioQuality](#getSelectedAudioQuality)
|
|
141
|
+
* [getCaptionLanguages](#getCaptionLanguages)
|
|
142
|
+
* [getSelectedCaptionLanguage](#getSelectedCaptionLanguage)
|
|
143
|
+
* [setCaptionLanguage](#setCaptionLanguage)
|
|
144
|
+
* [disableCaptions](#disableCaptions)
|
|
145
|
+
* [getDuration](#getDuration)
|
|
135
146
|
|
|
136
147
|
### Props
|
|
137
148
|
|
|
@@ -278,6 +289,7 @@ language | string | optional: language of track if relevant
|
|
|
278
289
|
bitrate | number | optional: bitrate in bps if relevant
|
|
279
290
|
width | number | optional: width resolution if relevant
|
|
280
291
|
height | number | optional: height resolution if relevant otherwise
|
|
292
|
+
label | string | optional: Display name if relevant
|
|
281
293
|
|
|
282
294
|
#### onMediaEnded
|
|
283
295
|
Callback function invoked when a video reached end of playback.
|
|
@@ -344,4 +356,158 @@ Exit fullscreen mode.
|
|
|
344
356
|
#### getPlaybackProperties
|
|
345
357
|
`getPlaybackProperties()`
|
|
346
358
|
|
|
347
|
-
Request additional playback properties. The callback `onPlaybackProperties` is invoked with the results.
|
|
359
|
+
Request additional playback properties. The callback `onPlaybackProperties` is invoked with the results.
|
|
360
|
+
|
|
361
|
+
#### isAdaptive
|
|
362
|
+
`isAdaptive()`
|
|
363
|
+
|
|
364
|
+
Check whether the video is in adaptive mode or not
|
|
365
|
+
|
|
366
|
+
#### getVideoQualities
|
|
367
|
+
`getVideoQualities()`
|
|
368
|
+
|
|
369
|
+
Get available video tracks
|
|
370
|
+
|
|
371
|
+
Payload:
|
|
372
|
+
|
|
373
|
+
Property | Type | Description
|
|
374
|
+
--- | --- | ---
|
|
375
|
+
videoQualities | object[] | array of available `track` objects
|
|
376
|
+
|
|
377
|
+
`track`:
|
|
378
|
+
|
|
379
|
+
Property | Type | Description
|
|
380
|
+
--- | --- | ---
|
|
381
|
+
id | number | an integer identifying the track
|
|
382
|
+
bitrate | number | optional: bitrate in bps if relevant
|
|
383
|
+
width | number | optional: width resolution if relevant
|
|
384
|
+
height | number | optional: height resolution if relevant otherwise
|
|
385
|
+
|
|
386
|
+
#### getSelectedVideoQuality
|
|
387
|
+
`getSelectedVideoQuality()`
|
|
388
|
+
|
|
389
|
+
Get selected video track
|
|
390
|
+
|
|
391
|
+
Payload:
|
|
392
|
+
|
|
393
|
+
Property | Type | Description
|
|
394
|
+
--- | --- | ---
|
|
395
|
+
selectedVideoQuality| object | selected `track` object
|
|
396
|
+
|
|
397
|
+
`track`:
|
|
398
|
+
|
|
399
|
+
Property | Type | Description
|
|
400
|
+
--- | --- | ---
|
|
401
|
+
id | number | an integer identifying the track
|
|
402
|
+
bitrate | number | optional: bitrate in bps if relevant
|
|
403
|
+
width | number | optional: width resolution if relevant
|
|
404
|
+
height | number | optional: height resolution if relevant otherwise
|
|
405
|
+
|
|
406
|
+
If this method returns `null`, it means the video is playing in adaptive mode
|
|
407
|
+
|
|
408
|
+
#### setVideoQuality
|
|
409
|
+
`setVideoQuality(videoQuality)`
|
|
410
|
+
|
|
411
|
+
Set specified video track
|
|
412
|
+
|
|
413
|
+
`videoQuality`:
|
|
414
|
+
|
|
415
|
+
Property | Type | Description
|
|
416
|
+
--- | --- | ---
|
|
417
|
+
id | number | an integer identifying the track
|
|
418
|
+
bitrate | number | optional: bitrate in bps if relevant
|
|
419
|
+
width | number | optional: width resolution if relevant
|
|
420
|
+
height | number | optional: height resolution if relevant otherwise
|
|
421
|
+
|
|
422
|
+
#### enableAdaptiveVideo
|
|
423
|
+
`enableAdaptiveVideo()`
|
|
424
|
+
|
|
425
|
+
Run video in adaptive mode
|
|
426
|
+
|
|
427
|
+
#### getSelectedAudioQuality
|
|
428
|
+
`getSelectedAudioQuality()`
|
|
429
|
+
|
|
430
|
+
Get selected audio track
|
|
431
|
+
|
|
432
|
+
Payload:
|
|
433
|
+
|
|
434
|
+
Property | Type | Description
|
|
435
|
+
--- | --- | ---
|
|
436
|
+
selectedAudioQuality| object | selected `track` object
|
|
437
|
+
|
|
438
|
+
`track`:
|
|
439
|
+
|
|
440
|
+
Property | Type | Description
|
|
441
|
+
--- | --- | ---
|
|
442
|
+
id | number | an integer identifying the track
|
|
443
|
+
bitrate | number | optional: bitrate in bps if relevant
|
|
444
|
+
width | number | optional: width resolution if relevant
|
|
445
|
+
height | number | optional: height resolution if relevant otherwise
|
|
446
|
+
|
|
447
|
+
#### getCaptionLanguages
|
|
448
|
+
`getCaptionLanguages()`
|
|
449
|
+
|
|
450
|
+
Get available caption tracks
|
|
451
|
+
|
|
452
|
+
Payload:
|
|
453
|
+
|
|
454
|
+
Property | Type | Description
|
|
455
|
+
--- | --- | ---
|
|
456
|
+
captionLanguages | object[] | array of available `track` objects
|
|
457
|
+
|
|
458
|
+
`track`:
|
|
459
|
+
|
|
460
|
+
Property | Type | Description
|
|
461
|
+
--- | --- | ---
|
|
462
|
+
id | number | an integer identifying the track
|
|
463
|
+
language | string | optional: language of track if relevant
|
|
464
|
+
label | string | optional: Display name if relevant
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
#### getSelectedCaptionLanguage
|
|
468
|
+
`getSelectedCaptionLanguage()`
|
|
469
|
+
|
|
470
|
+
Get selected caption track
|
|
471
|
+
|
|
472
|
+
Payload:
|
|
473
|
+
|
|
474
|
+
Property | Type | Description
|
|
475
|
+
--- | --- | ---
|
|
476
|
+
selectedCaptionLanguage| object | selected `track` object
|
|
477
|
+
|
|
478
|
+
`track`:
|
|
479
|
+
|
|
480
|
+
Property | Type | Description
|
|
481
|
+
--- | --- | ---
|
|
482
|
+
id | number | an integer identifying the track
|
|
483
|
+
language | string | optional: language of track if relevant
|
|
484
|
+
label | string | optional: Display name if relevant
|
|
485
|
+
|
|
486
|
+
#### setCaptionLanguage
|
|
487
|
+
`setCaptionLanguage(captionLanguage)`
|
|
488
|
+
|
|
489
|
+
Set specified caption track
|
|
490
|
+
|
|
491
|
+
`captionLanguage`:
|
|
492
|
+
|
|
493
|
+
Property | Type | Description
|
|
494
|
+
--- | --- | ---
|
|
495
|
+
id | number | an integer identifying the track
|
|
496
|
+
language | string | optional: language of track if relevant
|
|
497
|
+
label | string | optional: Display name if relevant
|
|
498
|
+
|
|
499
|
+
#### disableCaptions
|
|
500
|
+
`disableCaptions()`
|
|
501
|
+
|
|
502
|
+
Disable captions
|
|
503
|
+
|
|
504
|
+
#### getDuration
|
|
505
|
+
`getDuration()`
|
|
506
|
+
|
|
507
|
+
Get video duration
|
|
508
|
+
|
|
509
|
+
Payload:
|
|
510
|
+
|
|
511
|
+
Property | Type | Description
|
|
512
|
+
--- | --- | ---
|
|
513
|
+
duration | number | duration of the video in milliseconds
|
package/VdoPlayerSupportView.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
45
|
-
if (this.
|
|
46
|
-
this.
|
|
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
|
-
|
|
129
|
-
if (this.
|
|
130
|
-
this.
|
|
48
|
+
enableAdaptiveVideo = () => {
|
|
49
|
+
if (this._root) {
|
|
50
|
+
this._root.setNativeProps({adaptiveVideo: this._propRef++});
|
|
131
51
|
}
|
|
132
52
|
}
|
|
133
53
|
|
|
134
|
-
|
|
135
|
-
if (this.
|
|
136
|
-
this.
|
|
54
|
+
setCaptionLanguage = captionLanguage => {
|
|
55
|
+
if (this._root) {
|
|
56
|
+
this._root.setNativeProps({captionLanguage: captionLanguage});
|
|
137
57
|
}
|
|
138
58
|
}
|
|
139
59
|
|
|
140
|
-
|
|
141
|
-
if (this.
|
|
142
|
-
this.
|
|
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,
|
package/VdoPlayerUIView.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* VdoPlayerUIView 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
5
|
import {requireNativeComponent, Platform} from 'react-native';
|
|
7
|
-
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
8
6
|
|
|
9
7
|
class VdoPlayerUIView extends Component {
|
|
10
8
|
constructor(props) {
|
|
@@ -93,174 +91,15 @@
|
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
|
|
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
94
|
render() {
|
|
193
95
|
return (
|
|
194
96
|
<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
97
|
{...this.props}
|
|
212
98
|
/>
|
|
213
99
|
);
|
|
214
100
|
}
|
|
215
101
|
}
|
|
216
102
|
|
|
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
103
|
var RCTVdoPlayerUIView = requireNativeComponent('RCTVdoPlayerUIView', VdoPlayerUIView, {
|
|
265
104
|
nativeOnly: {
|
|
266
105
|
onInitSuccess: true,
|
package/VdoPlayerView.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React, { Component, Fragment } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { BackHandler} from 'react-native';
|
|
6
|
+
import { BackHandler, NativeModules} from 'react-native';
|
|
7
7
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
8
8
|
import VdoPlayerSupportView from './VdoPlayerSupportView';
|
|
9
9
|
import VdoPlayerUIView from './VdoPlayerUIView';
|
|
10
|
+
const { TrackSelection } = NativeModules;
|
|
10
11
|
|
|
11
12
|
export default class VdoPlayerView extends Component {
|
|
12
13
|
|
|
@@ -58,6 +59,79 @@
|
|
|
58
59
|
this._vdoPlayerView.getPlaybackProperties();
|
|
59
60
|
}
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
isAdaptive = async() => {
|
|
64
|
+
return new Promise(async(resolve) => { await TrackSelection.isAdaptive((isAdaptive) => {
|
|
65
|
+
resolve(isAdaptive);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getVideoQualities = async() => {
|
|
71
|
+
return new Promise(async(resolve) => { await TrackSelection.getVideoQualities((videoQualities) => {
|
|
72
|
+
resolve(videoQualities);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getSelectedVideoQuality = async() => {
|
|
78
|
+
return new Promise(async(resolve) => { await TrackSelection.getSelectedVideoQuality((selectedVideoQuality) => {
|
|
79
|
+
resolve(selectedVideoQuality);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setVideoQuality = videoQuality => {
|
|
85
|
+
if (this._vdoPlayerView) {
|
|
86
|
+
this._vdoPlayerView.setVideoQuality(videoQuality);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
enableAdaptiveVideo = () => {
|
|
91
|
+
if (this._vdoPlayerView) {
|
|
92
|
+
this._vdoPlayerView.enableAdaptiveVideo();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getSelectedAudioQuality = async() => {
|
|
97
|
+
return new Promise(async(resolve) => { await TrackSelection.getSelectedAudioQuality((selectedAudioQuality) => {
|
|
98
|
+
resolve(selectedAudioQuality);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getCaptionLanguages = async() => {
|
|
104
|
+
return new Promise(async(resolve) => { await TrackSelection.getCaptionLanguages((captionLanguages) => {
|
|
105
|
+
resolve(captionLanguages);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getSelectedCaptionLanguage = async() => {
|
|
111
|
+
return new Promise(async(resolve) => { await TrackSelection.getSelectedCaptionLanguage((selectedCaptionLanguage) => {
|
|
112
|
+
resolve(selectedCaptionLanguage);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
setCaptionLanguage = captionLanguage => {
|
|
118
|
+
if (this._vdoPlayerView) {
|
|
119
|
+
this._vdoPlayerView.setCaptionLanguage(captionLanguage);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
disableCaptions = () => {
|
|
124
|
+
if (this._vdoPlayerView) {
|
|
125
|
+
this._vdoPlayerView.disableCaptions();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getDuration = async() => {
|
|
130
|
+
return new Promise(async(resolve) => { await TrackSelection.getDuration((duration) => {
|
|
131
|
+
resolve(duration);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
61
135
|
|
|
62
136
|
_onInitSuccess = (event) => {
|
|
63
137
|
if (this.props.onInitializationSuccess) {
|
|
@@ -162,6 +236,12 @@
|
|
|
162
236
|
isInitialPortrait: event.nativeEvent.isInitialPortrait
|
|
163
237
|
});
|
|
164
238
|
}
|
|
239
|
+
|
|
240
|
+
_onPictureInPictureModeChanged = (event) => {
|
|
241
|
+
if (this.props.onPictureInPictureModeChanged) {
|
|
242
|
+
this.props.onPictureInPictureModeChanged(event.nativeEvent);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
165
245
|
|
|
166
246
|
render() {
|
|
167
247
|
return (
|
|
@@ -185,6 +265,7 @@
|
|
|
185
265
|
onVdoEnterFullscreen={this._onEnterFullscreen}
|
|
186
266
|
onVdoExitFullscreen={this._onExitFullscreen}
|
|
187
267
|
onIsInitialPortrait={this._onIsInitialPortrait}
|
|
268
|
+
onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
|
|
188
269
|
{...this.props}
|
|
189
270
|
/>
|
|
190
271
|
) :
|
|
@@ -236,6 +317,7 @@
|
|
|
236
317
|
onVdoEnterFullscreen: PropTypes.func,
|
|
237
318
|
onVdoExitFullscreen: PropTypes.func,
|
|
238
319
|
onIsInitialPortrait: PropTypes.func,
|
|
320
|
+
onVdoPictureInPictureModeChanged: PropTypes.func,
|
|
239
321
|
|
|
240
322
|
/* Wrapper component public api */
|
|
241
323
|
embedInfo: PropTypes.object,
|
|
@@ -257,6 +339,7 @@
|
|
|
257
339
|
onPlaybackProperties: PropTypes.func,
|
|
258
340
|
onEnterFullscreen: PropTypes.func,
|
|
259
341
|
onExitFullscreen: PropTypes.func,
|
|
342
|
+
onPictureInPictureModeChanged: PropTypes.func,
|
|
260
343
|
|
|
261
344
|
/* Required */
|
|
262
345
|
...ViewPropTypes,
|
package/android/build.gradle
CHANGED
|
@@ -18,8 +18,8 @@ apply plugin: 'com.android.library'
|
|
|
18
18
|
// TODO read from package.json
|
|
19
19
|
// "releaseVersionName" must be the same as "version" in package.json
|
|
20
20
|
// "releaseVersionCode" must increment by 1 with every release
|
|
21
|
-
def releaseVersionName = "1.
|
|
22
|
-
def releaseVersionCode =
|
|
21
|
+
def releaseVersionName = "1.12.0"
|
|
22
|
+
def releaseVersionCode = 11
|
|
23
23
|
|
|
24
24
|
android {
|
|
25
25
|
compileSdkVersion 33
|
|
@@ -86,5 +86,5 @@ repositories {
|
|
|
86
86
|
dependencies {
|
|
87
87
|
compileOnly 'com.facebook.react:react-native:+'
|
|
88
88
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
|
89
|
-
implementation 'com.vdocipher.aegis:vdocipher-android:1.19.
|
|
89
|
+
implementation 'com.vdocipher.aegis:vdocipher-android:1.19.1'
|
|
90
90
|
}
|
|
@@ -34,6 +34,14 @@ import android.support.v4.media.session.PlaybackStateCompat;
|
|
|
34
34
|
import android.os.Handler;
|
|
35
35
|
import android.os.Bundle;
|
|
36
36
|
|
|
37
|
+
import android.os.Looper;
|
|
38
|
+
import com.facebook.react.bridge.Callback;
|
|
39
|
+
import static com.vdocipher.rnbridge.Utils.*;
|
|
40
|
+
import com.facebook.react.bridge.WritableArray;
|
|
41
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
42
|
+
import com.facebook.react.bridge.WritableMap;
|
|
43
|
+
import com.facebook.react.bridge.Arguments;
|
|
44
|
+
|
|
37
45
|
public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventListener {
|
|
38
46
|
private static final String TAG = "ReactVdoPlayerView";
|
|
39
47
|
|
|
@@ -63,11 +71,17 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
63
71
|
|
|
64
72
|
private Consumer<PictureInPictureModeChangedInfo> pictureModeChangedInfoConsumer;
|
|
65
73
|
|
|
74
|
+
private Track[] availableTracks;
|
|
75
|
+
private Track[] selectedTracks;
|
|
76
|
+
private Handler mainHandler;
|
|
77
|
+
|
|
66
78
|
public ReactVdoPlayerView(ThemedReactContext context) {
|
|
67
79
|
super(context);
|
|
68
80
|
context.addLifecycleEventListener(this);
|
|
69
81
|
themedReactContext = context;
|
|
70
82
|
activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
|
|
83
|
+
// Get a handler that can be used to post to the main thread
|
|
84
|
+
mainHandler = new Handler(Looper.getMainLooper());
|
|
71
85
|
setKeepScreenOn(true);
|
|
72
86
|
|
|
73
87
|
eventEmitter = new VdoEventEmitter(context);
|
|
@@ -273,6 +287,102 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
273
287
|
}
|
|
274
288
|
}
|
|
275
289
|
|
|
290
|
+
public void isAdaptive(Callback callback) {
|
|
291
|
+
|
|
292
|
+
if (vdoPlayer != null) {
|
|
293
|
+
mainHandler.post(() -> {
|
|
294
|
+
boolean isAdaptive = vdoPlayer.isAdaptive();
|
|
295
|
+
callback.invoke(isAdaptive);
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
callback.invoke(false);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public void getVideoQualities(Callback callback) {
|
|
303
|
+
WritableArray availableVideoQualities = Arguments.createArray();
|
|
304
|
+
if (this.availableTracks != null) {
|
|
305
|
+
availableVideoQualities = makeAvailableTrackMapArray(this.availableTracks, Track.TYPE_VIDEO);
|
|
306
|
+
}
|
|
307
|
+
callback.invoke(availableVideoQualities);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public void getSelectedVideoQuality(Callback callback) {
|
|
311
|
+
WritableMap selectedVideoQuality = Arguments.createMap();
|
|
312
|
+
if (this.selectedTracks != null) {
|
|
313
|
+
selectedVideoQuality = makeSelectedVideoTrackMap(this.selectedTracks);
|
|
314
|
+
}
|
|
315
|
+
callback.invoke(selectedVideoQuality);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
public void getSelectedAudioQuality(Callback callback) {
|
|
319
|
+
WritableMap selectedAudioQuality = Arguments.createMap();
|
|
320
|
+
if (this.selectedTracks != null) {
|
|
321
|
+
selectedAudioQuality = makeSelectedAudioTrackMap(this.selectedTracks);
|
|
322
|
+
}
|
|
323
|
+
callback.invoke(selectedAudioQuality);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
public void getSelectedCaptionLanguage(Callback callback) {
|
|
327
|
+
WritableMap selectedCaptionLanguage = Arguments.createMap();
|
|
328
|
+
if (this.selectedTracks != null) {
|
|
329
|
+
selectedCaptionLanguage = makeSelectedCaptionTrackMap(this.selectedTracks);
|
|
330
|
+
}
|
|
331
|
+
callback.invoke(selectedCaptionLanguage);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
public void setSelectedTrack(ReadableMap selectedTrackMap) {
|
|
335
|
+
Track selectedTrack = makeTrack(selectedTrackMap, availableTracks);
|
|
336
|
+
|
|
337
|
+
if (vdoPlayer != null && selectedTrack != null) {
|
|
338
|
+
mainHandler.post(() -> {
|
|
339
|
+
vdoPlayer.setSelectedTracks(new Track[]{selectedTrack});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
public void enableAdaptiveVideo() {
|
|
345
|
+
Track selectedTrack = Track.SET_ADAPTIVE;
|
|
346
|
+
|
|
347
|
+
if (vdoPlayer != null) {
|
|
348
|
+
mainHandler.post(() -> {
|
|
349
|
+
vdoPlayer.setSelectedTracks(new Track[]{selectedTrack});
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
public void getCaptionLanguages(Callback callback) {
|
|
355
|
+
WritableArray availableCaptionLanguages = Arguments.createArray();
|
|
356
|
+
if (this.availableTracks != null) {
|
|
357
|
+
availableCaptionLanguages = makeAvailableTrackMapArray(this.availableTracks, Track.TYPE_CAPTIONS);
|
|
358
|
+
}
|
|
359
|
+
callback.invoke(availableCaptionLanguages);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
public void disableCaptions() {
|
|
363
|
+
Track selectedTrack = Track.DISABLE_CAPTIONS;
|
|
364
|
+
|
|
365
|
+
if (vdoPlayer != null) {
|
|
366
|
+
mainHandler.post(() -> {
|
|
367
|
+
vdoPlayer.setSelectedTracks(new Track[]{selectedTrack});
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
public void getDuration(Callback callback) {
|
|
373
|
+
|
|
374
|
+
if (vdoPlayer != null) {
|
|
375
|
+
mainHandler.post(() -> {
|
|
376
|
+
double videoDuration = vdoPlayer.getDuration();
|
|
377
|
+
WritableMap videoDurationMap = Arguments.createMap();
|
|
378
|
+
videoDurationMap.putDouble("duration", videoDuration);
|
|
379
|
+
callback.invoke(videoDurationMap);
|
|
380
|
+
});
|
|
381
|
+
} else {
|
|
382
|
+
callback.invoke(0);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
276
386
|
@Override
|
|
277
387
|
public void setId(int id) {
|
|
278
388
|
super.setId(id);
|
|
@@ -344,6 +454,8 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
344
454
|
public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
|
|
345
455
|
Log.d(TAG, "init success");
|
|
346
456
|
vdoPlayer = player;
|
|
457
|
+
availableTracks = vdoPlayer.getAvailableTracks();
|
|
458
|
+
selectedTracks = vdoPlayer.getSelectedTracks();
|
|
347
459
|
vdoPlayer.addPlaybackEventListener(playbackListener);
|
|
348
460
|
eventEmitter.initSuccess(restored);
|
|
349
461
|
|
|
@@ -408,13 +520,13 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
408
520
|
private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.PlaybackEventListener() {
|
|
409
521
|
@Override
|
|
410
522
|
public void onPlayerStateChanged(boolean playWhenReady, int playerState) {
|
|
411
|
-
|
|
523
|
+
boolean playing = playerState != VdoPlayer.STATE_IDLE && playerState != VdoPlayer.STATE_ENDED && playWhenReady;
|
|
412
524
|
|
|
413
525
|
// We are playing the video now. Update the media session state and the PiP
|
|
414
526
|
// window will update the actions.
|
|
415
527
|
|
|
416
528
|
if (hasPictureInPictureSupport) {
|
|
417
|
-
|
|
529
|
+
updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
|
|
418
530
|
}
|
|
419
531
|
|
|
420
532
|
if (playing) {
|
|
@@ -480,7 +592,9 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
|
|
|
480
592
|
}
|
|
481
593
|
|
|
482
594
|
@Override
|
|
483
|
-
public void onTracksChanged(Track[]
|
|
595
|
+
public void onTracksChanged(Track[] tracksAvailable, Track[] tracksSelected) {
|
|
596
|
+
availableTracks = tracksAvailable;
|
|
597
|
+
selectedTracks = tracksSelected;
|
|
484
598
|
eventEmitter.tracksChanged(availableTracks, selectedTracks);
|
|
485
599
|
}
|
|
486
600
|
};
|
|
@@ -8,18 +8,23 @@ import com.facebook.react.uimanager.ThemedReactContext;
|
|
|
8
8
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
9
9
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
10
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
11
|
+
import com.vdocipher.aegis.media.Track;
|
|
11
12
|
|
|
12
13
|
import java.util.Map;
|
|
13
14
|
|
|
14
15
|
import javax.annotation.Nullable;
|
|
15
16
|
|
|
16
17
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
18
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
17
19
|
|
|
18
20
|
public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerView> {
|
|
19
21
|
private static final String TAG = "ReactVdoPlayerViewMngr";
|
|
20
22
|
|
|
21
23
|
private static final String REACT_CLASS = "RCTVdoPlayerView";
|
|
22
24
|
|
|
25
|
+
private ReactVdoPlayerView playerView;
|
|
26
|
+
private Callback callback;
|
|
27
|
+
|
|
23
28
|
@Override
|
|
24
29
|
public String getName() {
|
|
25
30
|
return REACT_CLASS;
|
|
@@ -27,11 +32,16 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
27
32
|
|
|
28
33
|
@Override
|
|
29
34
|
public ReactVdoPlayerView createViewInstance(ThemedReactContext context) {
|
|
30
|
-
|
|
35
|
+
playerView = new ReactVdoPlayerView(context);
|
|
31
36
|
Log.d(TAG, "created " + playerView.toString());
|
|
37
|
+
callback.onVideoPlayerViewInitialised(playerView);
|
|
32
38
|
return playerView;
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
public void setCallback(Callback callback) {
|
|
42
|
+
this.callback = callback;
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
@Nullable
|
|
36
46
|
@Override
|
|
37
47
|
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
@@ -142,4 +152,29 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
142
152
|
public void getPlaybackProperties(ReactVdoPlayerView vdoPlayerView, int ref) {
|
|
143
153
|
vdoPlayerView.getPlaybackProperties();
|
|
144
154
|
}
|
|
155
|
+
|
|
156
|
+
@ReactProp(name = "videoQuality")
|
|
157
|
+
public void setVideoQuality(ReactVdoPlayerView vdoPlayerView, ReadableMap videoQuality) {
|
|
158
|
+
vdoPlayerView.setSelectedTrack(videoQuality);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@ReactProp(name = "adaptiveVideo")
|
|
162
|
+
public void enableAdaptiveVideo(ReactVdoPlayerView vdoPlayerView, int ref) {
|
|
163
|
+
vdoPlayerView.enableAdaptiveVideo();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@ReactProp(name = "captionLanguage")
|
|
167
|
+
public void setCaptionLanguage(ReactVdoPlayerView vdoPlayerView, ReadableMap captionLanguage) {
|
|
168
|
+
vdoPlayerView.setSelectedTrack(captionLanguage);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@ReactProp(name = "disableCaptions")
|
|
172
|
+
public void disableCaptions(ReactVdoPlayerView vdoPlayerView, int ref) {
|
|
173
|
+
vdoPlayerView.disableCaptions();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public interface Callback {
|
|
177
|
+
void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView);
|
|
178
|
+
}
|
|
179
|
+
|
|
145
180
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
+
import com.facebook.react.bridge.Callback;
|
|
8
|
+
import android.util.Log;
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
|
+
|
|
11
|
+
public class TrackSelectionModule extends ReactContextBaseJavaModule implements ReactVdoPlayerViewManager.Callback {
|
|
12
|
+
private static final String TAG = "TrackSelectionModule";
|
|
13
|
+
|
|
14
|
+
private ReactVdoPlayerView vdoPlayerView;
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
public String getName() {
|
|
18
|
+
return "TrackSelection";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public TrackSelectionModule(ReactApplicationContext reactContext, ReactVdoPlayerViewManager vdoPlayerViewManager) {
|
|
22
|
+
super(reactContext);
|
|
23
|
+
if (vdoPlayerViewManager != null) {
|
|
24
|
+
vdoPlayerViewManager.setCallback(this);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@ReactMethod
|
|
29
|
+
public void isAdaptive(com.facebook.react.bridge.Callback callback) {
|
|
30
|
+
if (vdoPlayerView == null) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
vdoPlayerView.isAdaptive(callback);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
public void getVideoQualities(com.facebook.react.bridge.Callback callback) {
|
|
38
|
+
if (vdoPlayerView == null) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
vdoPlayerView.getVideoQualities(callback);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
public void getSelectedVideoQuality(com.facebook.react.bridge.Callback callback) {
|
|
46
|
+
if (vdoPlayerView == null) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
vdoPlayerView.getSelectedVideoQuality(callback);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
public void getSelectedAudioQuality(com.facebook.react.bridge.Callback callback) {
|
|
54
|
+
if (vdoPlayerView == null) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
vdoPlayerView.getSelectedAudioQuality(callback);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@ReactMethod
|
|
61
|
+
public void getCaptionLanguages(com.facebook.react.bridge.Callback callback) {
|
|
62
|
+
if (vdoPlayerView == null) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
vdoPlayerView.getCaptionLanguages(callback);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@ReactMethod
|
|
69
|
+
public void getSelectedCaptionLanguage(com.facebook.react.bridge.Callback callback) {
|
|
70
|
+
if (vdoPlayerView == null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
vdoPlayerView.getSelectedCaptionLanguage(callback);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod()
|
|
77
|
+
public void getDuration(com.facebook.react.bridge.Callback callback) {
|
|
78
|
+
vdoPlayerView.getDuration(callback);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Override
|
|
82
|
+
public void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView) {
|
|
83
|
+
this.vdoPlayerView = vdoPlayerView;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -35,6 +35,8 @@ public class Utils {
|
|
|
35
35
|
private static final String EVENT_PROP_TRACK_BITRATE = "bitrate";
|
|
36
36
|
private static final String EVENT_PROP_TRACK_WIDTH = "width";
|
|
37
37
|
private static final String EVENT_PROP_TRACK_HEIGHT = "height";
|
|
38
|
+
private static final String EVENT_PROP_TRACK_LABEL = "label";
|
|
39
|
+
|
|
38
40
|
|
|
39
41
|
private static final String EVENT_PROP_DOWNLOAD_STATUS_MEDIA_INFO = "mediaInfo";
|
|
40
42
|
private static final String EVENT_PROP_DOWNLOAD_STATUS_LOCAL_STORAGE_FOLDER = "localStorageFolder";
|
|
@@ -111,9 +113,90 @@ public class Utils {
|
|
|
111
113
|
trackMap.putInt(EVENT_PROP_TRACK_BITRATE, track.bitrate);
|
|
112
114
|
trackMap.putInt(EVENT_PROP_TRACK_WIDTH, track.width);
|
|
113
115
|
trackMap.putInt(EVENT_PROP_TRACK_HEIGHT, track.height);
|
|
116
|
+
trackMap.putString(EVENT_PROP_TRACK_LABEL, track.label);
|
|
117
|
+
return trackMap;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public static WritableArray makeAvailableTrackMapArray(Track[] availableTracks, int type) {
|
|
121
|
+
WritableArray trackArray = Arguments.createArray();
|
|
122
|
+
|
|
123
|
+
for (Track track : availableTracks) {
|
|
124
|
+
if (track.type == type && type == Track.TYPE_VIDEO) {
|
|
125
|
+
trackArray.pushMap(makeAudioVideoTrackMap(track));
|
|
126
|
+
} else if (track.type == type && type == Track.TYPE_CAPTIONS) {
|
|
127
|
+
trackArray.pushMap(makeLanguagesMap(track));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return trackArray;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public static WritableMap makeSelectedVideoTrackMap(Track[] selectedTracks) {
|
|
134
|
+
WritableMap trackMap = Arguments.createMap();
|
|
135
|
+
|
|
136
|
+
int selectedVideoCount = 0;
|
|
137
|
+
for (Track track : selectedTracks) {
|
|
138
|
+
if (track.type == Track.TYPE_VIDEO) {
|
|
139
|
+
trackMap = makeAudioVideoTrackMap(track);
|
|
140
|
+
selectedVideoCount++;
|
|
141
|
+
if (selectedVideoCount > 1) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
114
147
|
return trackMap;
|
|
115
148
|
}
|
|
116
149
|
|
|
150
|
+
public static WritableMap makeSelectedAudioTrackMap(Track[] selectedTracks) {
|
|
151
|
+
for (Track track : selectedTracks) {
|
|
152
|
+
if (track.type == Track.TYPE_AUDIO) {
|
|
153
|
+
return makeAudioVideoTrackMap(track);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return Arguments.createMap();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public static WritableMap makeSelectedCaptionTrackMap(Track[] selectedTracks) {
|
|
161
|
+
for (Track track : selectedTracks) {
|
|
162
|
+
if (track.type == Track.TYPE_CAPTIONS) {
|
|
163
|
+
return makeLanguagesMap(track);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public static WritableMap makeAudioVideoTrackMap(Track track) {
|
|
171
|
+
WritableMap trackMap = Arguments.createMap();
|
|
172
|
+
trackMap.putInt(EVENT_PROP_TRACK_ID, track.id);
|
|
173
|
+
trackMap.putInt(EVENT_PROP_TRACK_BITRATE, track.bitrate);
|
|
174
|
+
trackMap.putInt(EVENT_PROP_TRACK_WIDTH, track.width);
|
|
175
|
+
trackMap.putInt(EVENT_PROP_TRACK_HEIGHT, track.height);
|
|
176
|
+
return trackMap;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public static WritableMap makeLanguagesMap(Track track) {
|
|
180
|
+
WritableMap trackMap = Arguments.createMap();
|
|
181
|
+
trackMap.putInt(EVENT_PROP_TRACK_ID, track.id);
|
|
182
|
+
trackMap.putString(EVENT_PROP_TRACK_LANGUAGE, track.language);
|
|
183
|
+
trackMap.putString(EVENT_PROP_TRACK_LABEL, track.label);
|
|
184
|
+
return trackMap;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public static Track makeTrack(ReadableMap selectedTrackMap, Track[] availableTracks) {
|
|
188
|
+
int id = selectedTrackMap.getInt("id");
|
|
189
|
+
|
|
190
|
+
for (Track track : availableTracks) {
|
|
191
|
+
if (track.id == id) {
|
|
192
|
+
return track;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return null;
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
117
200
|
public static WritableMap makeDownloadOptionsMap(DownloadOptions options) {
|
|
118
201
|
WritableMap optionsMap = Arguments.createMap();
|
|
119
202
|
optionsMap.putString(EVENT_PROP_MEDIA_INFO_ID, options.mediaId);
|
|
@@ -41,6 +41,8 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
41
41
|
boolean offline = embedInfo.hasKey("offline") && embedInfo.getBoolean("offline");
|
|
42
42
|
final VdoInitParams vdoParams;
|
|
43
43
|
boolean enableAutoResume = embedInfo.hasKey("enableAutoResume") && embedInfo.getBoolean("enableAutoResume");
|
|
44
|
+
String preferredCaptionsLanguage = embedInfo.hasKey("preferredCaptionsLanguage") ?
|
|
45
|
+
embedInfo.getString("preferredCaptionsLanguage") : null;
|
|
44
46
|
|
|
45
47
|
if (offline) {
|
|
46
48
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
@@ -60,6 +62,9 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
60
62
|
if (safetyNetApiKey != null) {
|
|
61
63
|
builder.setSafetyNetApiKey(safetyNetApiKey);
|
|
62
64
|
}
|
|
65
|
+
if (preferredCaptionsLanguage != null) {
|
|
66
|
+
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
67
|
+
}
|
|
63
68
|
vdoParams = builder.build();
|
|
64
69
|
} else {
|
|
65
70
|
String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
|
|
@@ -84,8 +89,7 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
84
89
|
.setAllowAdbDebugging(allowAdbDebugging)
|
|
85
90
|
.setForceLowestBitrate(forceLowestBitrate)
|
|
86
91
|
.setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
|
|
87
|
-
.setMaxVideoBitrateKbps(maxVideoBitrateKbps)
|
|
88
|
-
.setPreferredCaptionsLanguage("en");
|
|
92
|
+
.setMaxVideoBitrateKbps(maxVideoBitrateKbps);
|
|
89
93
|
|
|
90
94
|
if (enableAutoResume) {
|
|
91
95
|
builder.enableAutoResume();
|
|
@@ -99,6 +103,9 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
99
103
|
if (safetyNetApiKey != null) {
|
|
100
104
|
builder.setSafetyNetApiKey(safetyNetApiKey);
|
|
101
105
|
}
|
|
106
|
+
if (preferredCaptionsLanguage != null) {
|
|
107
|
+
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
108
|
+
}
|
|
102
109
|
vdoParams = builder.build();
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -11,11 +11,17 @@ import com.facebook.react.uimanager.ViewManager;
|
|
|
11
11
|
import com.facebook.react.bridge.JavaScriptModule;
|
|
12
12
|
|
|
13
13
|
public class VdocipherRnBridgePackage implements ReactPackage {
|
|
14
|
+
private ReactVdoPlayerViewManager vdoPlayerViewManager;
|
|
15
|
+
|
|
14
16
|
@Override
|
|
15
17
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
18
|
+
if (vdoPlayerViewManager == null) {
|
|
19
|
+
vdoPlayerViewManager = new ReactVdoPlayerViewManager();
|
|
20
|
+
}
|
|
16
21
|
return Arrays.<NativeModule>asList(
|
|
17
22
|
new VdocipherRnBridgeModule(reactContext),
|
|
18
|
-
new VdoDownloadModule(reactContext)
|
|
23
|
+
new VdoDownloadModule(reactContext),
|
|
24
|
+
new TrackSelectionModule(reactContext, vdoPlayerViewManager));
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
// Deprecated from RN 0.47
|
|
@@ -25,9 +31,12 @@ public class VdocipherRnBridgePackage implements ReactPackage {
|
|
|
25
31
|
|
|
26
32
|
@Override
|
|
27
33
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
34
|
+
if (vdoPlayerViewManager == null) {
|
|
35
|
+
vdoPlayerViewManager = new ReactVdoPlayerViewManager();
|
|
36
|
+
}
|
|
28
37
|
return Arrays.<ViewManager>asList(
|
|
29
|
-
new
|
|
30
|
-
|
|
38
|
+
new ReactVdoPlayerUIViewManager(),
|
|
39
|
+
vdoPlayerViewManager
|
|
31
40
|
);
|
|
32
41
|
}
|
|
33
42
|
}
|
package/package.json
CHANGED