vdocipher-rn-bridge 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,20 @@
1
1
  ## Changelog
2
+ ### 1.16.0
3
+ * Updated VdoCipher Android SDK dependency to 1.21.0.
4
+ * Added support for `windowLayoutInDisplayCutoutMode` with inbuilt player UI.
5
+ * Improved feedback of double tap to skip forward and backward.
6
+ * Fullscreen Changes for Player UI:
7
+ * Fixed auto rotate lock while going into fullscreen mode.
8
+ * Implemented fullscreen behavior based on aspect ratio:
9
+ * Vertical videos will go fullscreen in portrait mode.
10
+ * Horizontal videos will go fullscreen in landscape mode.
11
+ * Deprecated `enterFullscreen` and `exitFullscreen` APIs.
12
+ * Added `enterFullscreenV2` and `exitFullscreenV2` APIs with aspect ratio-based fullscreen rotation.
13
+ * Fullscreen Changes for Player with Custom Controls:
14
+ * Deprecated `enterFullscreen` and `exitFullscreen` APIs.
15
+ * Removed the option to go back to portrait mode when the back button is pressed while in fullscreen mode.
16
+ * Fullscreen-related changes need to be performed manually.
17
+
2
18
  ### 1.15.0
3
19
  * Updated VdoCipher android sdk dependency to 1.19.6
4
20
  * Added PlayerUI for fullscreen player
@@ -18,22 +18,24 @@ class VdoPlayerSupportView extends Component<MyProps> {
18
18
  this._propRef = 1;
19
19
  }
20
20
 
21
- handleBackButtonClick() {
22
- this._root.setNativeProps({fullscreen: false});
23
- }
24
-
25
21
  seek = (seekTargetMs: number) => {
26
22
  if (this._root) {
27
23
  this._root.setNativeProps({seek: seekTargetMs});
28
24
  }
29
25
  }
30
26
 
27
+ /**
28
+ * @deprecated
29
+ */
31
30
  enterFullscreen = () => {
32
31
  if (this._root) {
33
32
  this._root.setNativeProps({fullscreen: true});
34
33
  }
35
34
  }
36
35
 
36
+ /**
37
+ * @deprecated
38
+ */
37
39
  exitFullscreen = () => {
38
40
  if (this._root) {
39
41
  this._root.setNativeProps({fullscreen: false});
@@ -66,7 +66,7 @@
66
66
  }
67
67
 
68
68
  handleBackButtonClick() {
69
- this._root.setNativeProps({fullscreen: false});
69
+ this._root.setNativeProps({backpressCalled: this._propRef++});
70
70
  }
71
71
 
72
72
  seek = (seekTargetMs: number) => {
@@ -75,13 +75,25 @@
75
75
  }
76
76
  }
77
77
 
78
- enterFullscreen = () => {
78
+ /**
79
+ * @deprecated
80
+ * Use {@link enterFullscreenV2} instead.
81
+ */
82
+ enterFullscreen = () => {}
83
+
84
+ enterFullscreenV2 = () => {
79
85
  if (this._root) {
80
86
  this._root.setNativeProps({fullscreen: true});
81
87
  }
82
88
  }
83
89
 
84
- exitFullscreen = () => {
90
+ /**
91
+ * @deprecated
92
+ * Use {@link exitFullscreenV2} instead.
93
+ */
94
+ exitFullscreen = () => {}
95
+
96
+ exitFullscreenV2 = () => {
85
97
  if (this._root) {
86
98
  this._root.setNativeProps({fullscreen: false});
87
99
  }
package/VdoPlayerView.tsx CHANGED
@@ -14,7 +14,6 @@ const VdoViewPropTypes = VdoType.VdoPropTypes;
14
14
  type MyProps = InferProps<typeof VdoViewPropTypes>;
15
15
  type MyState = {
16
16
  fullscreen: boolean;
17
- isInitialPortrait: boolean;
18
17
  isInPictureInPictureMode: false;
19
18
  };
20
19
 
@@ -27,7 +26,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
27
26
  super(props);
28
27
  this.state = {
29
28
  fullscreen: false,
30
- isInitialPortrait: true,
31
29
  isInPictureInPictureMode: false
32
30
  }
33
31
  this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
@@ -46,10 +44,10 @@ class VdoPlayerView extends Component<MyProps, MyState> {
46
44
  }
47
45
 
48
46
  handleBackButtonClick() {
49
- if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.state.isInitialPortrait) {
50
- this._vdoPlayerView.handleBackButtonClick();
51
- return true;
52
- }
47
+ if (!this.state.isInPictureInPictureMode && this.state.fullscreen && !(this.props.showNativeControls === false)) {
48
+ this._vdoPlayerView.handleBackButtonClick();
49
+ return true;
50
+ }
53
51
  }
54
52
 
55
53
  seek = (seekTargetMs: number) => {
@@ -58,15 +56,51 @@ class VdoPlayerView extends Component<MyProps, MyState> {
58
56
  }
59
57
  }
60
58
 
59
+ /**
60
+ * @deprecated
61
+ * Use {@link enterFullscreenV2} instead.
62
+ */
61
63
  enterFullscreen = () => {
62
- if (this._vdoPlayerView) {
64
+ if (this.props.showNativeControls === false) {
65
+ console.warn('enterFullscreen method is deprecated. We advise handling fullscreen changes manually or utilizing our player with native controls which handles fullscreen automatically.');
66
+ } else {
67
+ console.warn('enterFullscreen method is deprecated. Please use enterFullscreenV2 instead.');
68
+ }
69
+ if (this._vdoPlayerView) {
63
70
  this._vdoPlayerView.enterFullscreen();
64
- }
71
+ }
65
72
  }
66
73
 
74
+ /**
75
+ * Works only with player with native controls
76
+ */
77
+ enterFullscreenV2 = () => {
78
+ if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
79
+ this._vdoPlayerView.enterFullscreenV2();
80
+ }
81
+ }
82
+
83
+ /**
84
+ * @deprecated
85
+ * Use {@link exitFullscreenV2} instead.
86
+ */
67
87
  exitFullscreen = () => {
68
- if (this._vdoPlayerView) {
88
+ if (this.props.showNativeControls === false) {
89
+ console.warn('exitFullscreen method is deprecated. We advise handling fullscreen changes manually or utilizing our player with native controls which handles fullscreen automatically.');
90
+ } else {
91
+ console.warn('exitFullscreen method is deprecated. Please use exitFullscreenV2 instead.');
92
+ }
93
+ if (this._vdoPlayerView) {
69
94
  this._vdoPlayerView.exitFullscreen();
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Works only with player with native controls
100
+ */
101
+ exitFullscreenV2 = () => {
102
+ if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
103
+ this._vdoPlayerView.exitFullscreenV2();
70
104
  }
71
105
  }
72
106
 
@@ -260,12 +294,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
260
294
  }
261
295
  }
262
296
 
263
- _onIsInitialPortrait =(event: any) => {
264
- this.setState({
265
- isInitialPortrait: event.nativeEvent.isInitialPortrait
266
- });
267
- }
268
-
269
297
  _onPictureInPictureModeChanged = (event: any) => {
270
298
  this.setState({
271
299
  isInPictureInPictureMode: event.nativeEvent.isInPictureInPictureMode
@@ -297,7 +325,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
297
325
  onVdoPlaybackProperties={this._onPlaybackProperties}
298
326
  onVdoEnterFullscreen={this._onEnterFullscreen}
299
327
  onVdoExitFullscreen={this._onExitFullscreen}
300
- onIsInitialPortrait={this._onIsInitialPortrait}
301
328
  onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
302
329
  />
303
330
  ) :
@@ -320,7 +347,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
320
347
  onVdoPlaybackProperties={this._onPlaybackProperties}
321
348
  onVdoEnterFullscreen={this._onEnterFullscreen}
322
349
  onVdoExitFullscreen={this._onExitFullscreen}
323
- onIsInitialPortrait={this._onIsInitialPortrait}
324
350
  onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
325
351
  />
326
352
  )
@@ -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.15.0"
22
- def releaseVersionCode = 19
21
+ def releaseVersionName = "1.16.0"
22
+ def releaseVersionCode = 20
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.6'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.21.0'
90
90
  }
@@ -1,11 +1,9 @@
1
1
  package com.vdocipher.rnbridge;
2
2
 
3
3
  import androidx.appcompat.app.AppCompatActivity;
4
- import androidx.core.util.Consumer;
5
4
  import androidx.fragment.app.FragmentManager;
6
5
  import androidx.fragment.app.Fragment;
7
6
 
8
- import android.content.res.Configuration;
9
7
  import android.util.Log;
10
8
  import android.view.KeyEvent;
11
9
  import android.view.ViewGroup;
@@ -37,12 +35,15 @@ import com.facebook.react.bridge.Arguments;
37
35
  import com.facebook.react.bridge.WritableArray;
38
36
  import com.facebook.react.bridge.ReadableMap;
39
37
 
38
+ import com.vdocipher.aegis.ui.view.FullScreenActionListener;
39
+
40
40
 
41
- public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
41
+ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener {
42
42
  private static final String TAG = "ReactVdoPlayerUIView";
43
43
 
44
44
  private final ThemedReactContext themedReactContext;
45
45
  private final VdoEventEmitter eventEmitter;
46
+ private FullScreenActionListener fullscreenToggleListener;
46
47
  private VdoPlayerUIFragment vdoPlayerUIFragment;
47
48
  private VdoPlayerControlView vdoPlayerControlView;
48
49
 
@@ -73,18 +74,13 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
73
74
  setBackgroundColor(Color.BLACK);
74
75
 
75
76
  context.addLifecycleEventListener(this);
76
- activity.addOnConfigurationChangedListener(this);
77
77
 
78
78
  mainHandler = new Handler(Looper.getMainLooper());
79
79
 
80
80
  eventEmitter = new VdoEventEmitter(context);
81
81
 
82
- int orientation = getResources().getConfiguration().orientation;
83
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
84
- eventEmitter.isInitialPortrait();
85
- }
86
-
87
82
  setPictureInPictureSupport();
83
+ setFullscreenActionListener();
88
84
 
89
85
  }
90
86
 
@@ -92,13 +88,19 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
92
88
  if (vdoPlayerUIFragment != null) {
93
89
  new Handler().postDelayed(() -> {
94
90
  if (fragmentManager != null && !fragmentManager.isDestroyed()) {
95
- fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitNow();
91
+ try {
92
+ fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitAllowingStateLoss();
93
+ fragmentManager.executePendingTransactions();
94
+ vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
95
+ // initialize the playerFragment; a VdoPlayer instance will be received
96
+ // in onInitializationSuccess() callback
97
+ vdoPlayerUIFragment.initialize(initializationListener);
98
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
99
+ vdoPlayerUIFragment.setFullscreenActionListener(fullscreenToggleListener);
100
+ } catch(Exception e) {
101
+ e.printStackTrace();
102
+ }
96
103
  }
97
- vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
98
- // initialize the playerFragment; a VdoPlayer instance will be received
99
- // in onInitializationSuccess() callback
100
- vdoPlayerUIFragment.initialize(initializationListener);
101
- vdoPlayerUIFragment.setResizeMode(this.resizeMode);
102
104
  }, 200);
103
105
  }
104
106
  }
@@ -189,7 +191,20 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
189
191
  };
190
192
  activity.addOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
191
193
  }
192
- }
194
+ }
195
+
196
+ private void setFullscreenActionListener() {
197
+ fullscreenToggleListener = isFullscreen -> {
198
+
199
+ if (isFullscreen) {
200
+ eventEmitter.enterFullscreen();
201
+ } else {
202
+ eventEmitter.exitFullscreen();
203
+ }
204
+
205
+ return false;
206
+ };
207
+ }
193
208
 
194
209
  public void setResizeMode(String resizeModeName) {
195
210
  this.resizeMode = resizeModeIntFromName(resizeModeName);
@@ -364,14 +379,19 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
364
379
  layout(getLeft(), getTop(), getRight(), getBottom());
365
380
  };
366
381
 
382
+
367
383
  public void setFullscreen(boolean setFullscreen) {
368
- if (!setFullscreen) {
369
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
384
+ if (setFullscreen) {
385
+ vdoPlayerUIFragment.enterFullScreen();
370
386
  } else {
371
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
387
+ vdoPlayerUIFragment.exitFullScreen();
372
388
  }
373
389
  }
374
390
 
391
+ public void setBackpressCalled() {
392
+ vdoPlayerUIFragment.setBackPressCalled();
393
+ }
394
+
375
395
  // InitializationListener impl
376
396
 
377
397
  PlayerHost.InitializationListener initializationListener = new PlayerHost.InitializationListener() {
@@ -481,16 +501,5 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
481
501
  }
482
502
  };
483
503
 
484
- @Override
485
- public void accept(Configuration configuration) {
486
- int newOrientation = configuration.orientation;
487
504
 
488
- if (newOrientation == Configuration.ORIENTATION_PORTRAIT) {
489
- vdoPlayerControlView.setFullscreenState(false);
490
- eventEmitter.exitFullscreen();
491
- } else if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) {
492
- vdoPlayerControlView.setFullscreenState(true);
493
- eventEmitter.enterFullscreen();
494
- }
495
- }
496
505
  }
@@ -194,6 +194,11 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
194
194
  vdoPlayerView.disableCaptions();
195
195
  }
196
196
 
197
+ @ReactProp(name = "backpressCalled")
198
+ public void setBackpressCalled(ReactVdoPlayerUIView vdoPlayerView, int ref) {
199
+ vdoPlayerView.setBackpressCalled();
200
+ }
201
+
197
202
  public interface Listener {
198
203
  void onVideoPlayerViewInitialised(ReactVdoPlayerUIView vdoPlayerView);
199
204
  }
@@ -90,11 +90,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
90
90
 
91
91
  eventEmitter = new VdoEventEmitter(context);
92
92
 
93
- int orientation = getResources().getConfiguration().orientation;
94
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
95
- eventEmitter.isInitialPortrait();
96
- }
97
-
98
93
  setPictureInPictureSupport();
99
94
  audioFocusManager = new AudioFocusManager(activity, audioFocusChangeListener);
100
95
 
@@ -104,12 +99,17 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
104
99
  if (vdoPlayerUIFragment != null) {
105
100
  new Handler().postDelayed(() -> {
106
101
  if (fragmentManager != null && !fragmentManager.isDestroyed()) {
107
- fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitNow();
102
+ try {
103
+ fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitAllowingStateLoss();
104
+ fragmentManager.executePendingTransactions();
105
+ // initialize the playerFragment; a VdoPlayer instance will be received
106
+ // in onInitializationSuccess() callback
107
+ vdoPlayerUIFragment.initialize(initializationListener);
108
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
109
+ } catch(IllegalStateException e) {
110
+ e.printStackTrace();
111
+ }
108
112
  }
109
- // initialize the playerFragment; a VdoPlayer instance will be received
110
- // in onInitializationSuccess() callback
111
- vdoPlayerUIFragment.initialize(initializationListener);
112
- vdoPlayerUIFragment.setResizeMode(this.resizeMode);
113
113
  }, 200);
114
114
  }
115
115
  }
@@ -33,7 +33,6 @@ class VdoEventEmitter {
33
33
  private static final String EVENT_PLAYBACK_PROPERTIES = "onVdoPlaybackProperties";
34
34
  private static final String EVENT_ENTER_FULLSCREEN = "onVdoEnterFullscreen";
35
35
  private static final String EVENT_EXIT_FULLSCREEN = "onVdoExitFullscreen";
36
- private static final String EVENT_IS_INITIAL_PORTRAIT = "onIsInitialPortrait";
37
36
  private static final String EVENT_PICTURE_IN_PICTURE_MODE_CHANGED ="onVdoPictureInPictureModeChanged";
38
37
 
39
38
 
@@ -47,7 +46,6 @@ class VdoEventEmitter {
47
46
  EVENT_ERROR,
48
47
  EVENT_PLAYBACK_PROPERTIES,
49
48
  EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
50
- EVENT_IS_INITIAL_PORTRAIT,
51
49
  EVENT_PICTURE_IN_PICTURE_MODE_CHANGED
52
50
  };
53
51
 
@@ -61,7 +59,7 @@ class VdoEventEmitter {
61
59
  EVENT_ERROR,
62
60
  EVENT_PLAYBACK_PROPERTIES,
63
61
  EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
64
- EVENT_IS_INITIAL_PORTRAIT, EVENT_PICTURE_IN_PICTURE_MODE_CHANGED})
62
+ EVENT_PICTURE_IN_PICTURE_MODE_CHANGED})
65
63
  @interface VdoEvent {}
66
64
 
67
65
  private static final String EVENT_PROP_RESTORED = "restored";
@@ -77,7 +75,6 @@ class VdoEventEmitter {
77
75
  private static final String EVENT_PROP_PLAY_WHEN_READY = "playWhenReady";
78
76
  private static final String EVENT_PROP_PLAYER_STATE = "playerState";
79
77
  private static final String EVENT_PROP_PLAYBACK_SPEED = "playbackSpeed";
80
- private static final String EVENT_PROP_IS_INITIAL_PORTRAIT = "isInitialPortrait";
81
78
  private static final String EVENT_PROP_IS_IN_PICTURE_IN_PICTURE_MODE = "isInPictureInPictureMode";
82
79
 
83
80
  private static final String EVENT_PROP_ERROR_DESCRIPTION = "errorDescription";
@@ -197,12 +194,6 @@ class VdoEventEmitter {
197
194
  receiveEvent(EVENT_PLAYBACK_PROPERTIES, event);
198
195
  }
199
196
 
200
- void isInitialPortrait() {
201
- WritableMap event = Arguments.createMap();
202
- event.putBoolean(EVENT_PROP_IS_INITIAL_PORTRAIT, true);
203
- receiveEvent(EVENT_IS_INITIAL_PORTRAIT, event);
204
- }
205
-
206
197
  private void receiveEvent(@VdoEvent String type, WritableMap event) {
207
198
  eventEmitter.receiveEvent(viewId, type, event);
208
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "React native bridge library that delegates to vdocipher native android SDK",
5
5
  "homepage": "https://www.vdocipher.com/docs/mobile/react-native/getting-started/",
6
6
  "scripts": {
package/type.ts CHANGED
@@ -126,7 +126,6 @@ export const VdoPropTypes = {
126
126
  fullscreen: PropTypes.bool,
127
127
  onVdoEnterFullscreen: PropTypes.func,
128
128
  onVdoExitFullscreen: PropTypes.func,
129
- onIsInitialPortrait: PropTypes.func,
130
129
  onVdoPictureInPictureModeChanged: PropTypes.func,
131
130
 
132
131
  /* Wrapper component public api */