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.
@@ -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
 
@@ -15,6 +16,7 @@
15
16
  this.state = {
16
17
  fullscreen: false,
17
18
  isInitialPortrait: true,
19
+ isInPictureInPictureMode: false
18
20
  }
19
21
  this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
20
22
  this._propRef = 1;
@@ -29,8 +31,8 @@
29
31
  }
30
32
 
31
33
  handleBackButtonClick() {
32
- if (this.state.fullscreen && this.state.isInitialPortrait) {
33
- this._vdoPlayerView.handleBackButtonClick();
34
+ if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.state.isInitialPortrait) {
35
+ this._vdoPlayerView.handleBackButtonClick();
34
36
  return true;
35
37
  }
36
38
  }
@@ -58,6 +60,79 @@
58
60
  this._vdoPlayerView.getPlaybackProperties();
59
61
  }
60
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
+ }
61
136
 
62
137
  _onInitSuccess = (event) => {
63
138
  if (this.props.onInitializationSuccess) {
@@ -162,6 +237,16 @@
162
237
  isInitialPortrait: event.nativeEvent.isInitialPortrait
163
238
  });
164
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
+ }
165
250
 
166
251
  render() {
167
252
  return (
@@ -185,6 +270,7 @@
185
270
  onVdoEnterFullscreen={this._onEnterFullscreen}
186
271
  onVdoExitFullscreen={this._onExitFullscreen}
187
272
  onIsInitialPortrait={this._onIsInitialPortrait}
273
+ onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
188
274
  {...this.props}
189
275
  />
190
276
  ) :
@@ -206,6 +292,7 @@
206
292
  onVdoEnterFullscreen={this._onEnterFullscreen}
207
293
  onVdoExitFullscreen={this._onExitFullscreen}
208
294
  onIsInitialPortrait={this._onIsInitialPortrait}
295
+ onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
209
296
  {...this.props}
210
297
  />
211
298
  )
@@ -236,6 +323,7 @@
236
323
  onVdoEnterFullscreen: PropTypes.func,
237
324
  onVdoExitFullscreen: PropTypes.func,
238
325
  onIsInitialPortrait: PropTypes.func,
326
+ onVdoPictureInPictureModeChanged: PropTypes.func,
239
327
 
240
328
  /* Wrapper component public api */
241
329
  embedInfo: PropTypes.object,
@@ -257,6 +345,7 @@
257
345
  onPlaybackProperties: PropTypes.func,
258
346
  onEnterFullscreen: PropTypes.func,
259
347
  onExitFullscreen: PropTypes.func,
348
+ onPictureInPictureModeChanged: PropTypes.func,
260
349
 
261
350
  /* Required */
262
351
  ...ViewPropTypes,
@@ -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.11.0"
22
- def releaseVersionCode = 10
21
+ def releaseVersionName = "1.12.1"
22
+ def releaseVersionCode = 12
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.0'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.19.1'
90
90
  }
@@ -24,6 +24,9 @@ import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
24
24
  import android.os.Handler;
25
25
  import android.os.Bundle;
26
26
 
27
+ import androidx.core.app.PictureInPictureModeChangedInfo;
28
+ import androidx.core.util.Consumer;
29
+
27
30
 
28
31
  public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
29
32
  private static final String TAG = "ReactVdoPlayerUIView";
@@ -44,6 +47,8 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
44
47
 
45
48
  private FragmentManager fragmentManager;
46
49
 
50
+ private Consumer<PictureInPictureModeChangedInfo> pictureModeChangedInfoConsumer;
51
+
47
52
  public ReactVdoPlayerUIView(ThemedReactContext context) {
48
53
  super(context);
49
54
  themedReactContext = context;
@@ -90,6 +95,9 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
90
95
  */
91
96
  public void cleanUp() {
92
97
  themedReactContext.removeLifecycleEventListener(this);
98
+ if (pictureModeChangedInfoConsumer != null) {
99
+ activity.removeOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
100
+ }
93
101
  if (vdoPlayer != null) {
94
102
  vdoPlayer.stop();
95
103
  }
@@ -138,6 +146,12 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
138
146
  public void setPictureInPictureSupport() {
139
147
  if (vdoPlayerUIFragment != null) {
140
148
  vdoPlayerUIFragment.setPictureInPictureSupport(true);
149
+ pictureModeChangedInfoConsumer = pictureInPictureModeChangedInfo ->
150
+ {
151
+ eventEmitter.onPictureInPictureModeChanged(pictureInPictureModeChangedInfo.isInPictureInPictureMode());
152
+ };
153
+
154
+ activity.addOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
141
155
  }
142
156
  }
143
157
 
@@ -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
- boolean playing = playerState != VdoPlayer.STATE_IDLE && playerState != VdoPlayer.STATE_ENDED && playWhenReady;
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
- updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
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[] availableTracks, Track[] selectedTracks) {
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
- ReactVdoPlayerView playerView = new ReactVdoPlayerView(context);
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
  }