vdocipher-rn-bridge 1.20.7 → 1.20.8

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.
@@ -65,6 +65,14 @@
65
65
  }
66
66
  }
67
67
 
68
+ setScreenFocused() {
69
+ this._root.setNativeProps({screenFocused: true});
70
+ }
71
+
72
+ setScreenBlurred() {
73
+ this._root.setNativeProps({screenFocused: false});
74
+ }
75
+
68
76
  handleBackButtonClick() {
69
77
  this._root.setNativeProps({backpressCalled: this._propRef++});
70
78
  }
package/VdoPlayerView.tsx CHANGED
@@ -7,6 +7,9 @@ import { BackHandler, NativeModules, StyleSheet, Dimensions, NativeEventEmitter,
7
7
  import VdoPlayerSupportView from './VdoPlayerSupportView';
8
8
  import VdoPlayerUIView from './VdoPlayerUIView';
9
9
  import * as VdoType from './type';
10
+ import { getNavigationContext } from './navigationHelper';
11
+ let NavigationContext: React.Context<any> | null = getNavigationContext();
12
+
10
13
  const { TrackSelection, VdoPlayer, VdoEventEmitter } = NativeModules;
11
14
 
12
15
  const VdoViewPropTypes = VdoType.VdoPropTypes;
@@ -22,6 +25,8 @@ class VdoPlayerView extends Component<MyProps, MyState> {
22
25
  _vdoPlayerView: any;
23
26
  static propTypes: typeof VdoViewPropTypes;
24
27
  eventEmitter: NativeEventEmitter;
28
+ focusListener: (() => void) | undefined;
29
+ blurListener: (() => void) | undefined;
25
30
 
26
31
  constructor(props: MyProps) {
27
32
  super(props);
@@ -74,6 +79,10 @@ class VdoPlayerView extends Component<MyProps, MyState> {
74
79
  this.eventEmitter.addListener('onVdoPlaybackSpeedChanged', (data) => {
75
80
  this._onPlaybackSpeedChanged(data);
76
81
  })
82
+
83
+ if (Platform.OS == "ios" && !(this.props.showNativeControls === false)) {
84
+ this.addFocusListeners();
85
+ }
77
86
  }
78
87
 
79
88
  componentWillUnmount() {
@@ -89,8 +98,38 @@ class VdoPlayerView extends Component<MyProps, MyState> {
89
98
  this.eventEmitter.removeAllListeners('onVdoEnterFullscreen');
90
99
  this.eventEmitter.removeAllListeners('onVdoExitFullscreen');
91
100
  this.eventEmitter.removeAllListeners('onVdoPlaybackSpeedChanged');
101
+
102
+ if (Platform.OS == "ios" && !(this.props.showNativeControls === false)) {
103
+ this.removeFocusListeners();
104
+ }
92
105
  }
93
106
 
107
+ addFocusListeners() {
108
+
109
+ if (NavigationContext) {
110
+ const navigation: any = this.context;
111
+ this.focusListener = navigation.addListener('focus', this.onScreenFocused);
112
+ this.blurListener = navigation.addListener('blur', this.onScreenBlurred);
113
+ }
114
+ }
115
+
116
+ removeFocusListeners() {
117
+ this.focusListener && this.focusListener();
118
+ this.blurListener && this.blurListener();
119
+ }
120
+
121
+ onScreenFocused = () => {
122
+ if (this._vdoPlayerView) {
123
+ this._vdoPlayerView.setScreenFocused();
124
+ }
125
+ };
126
+
127
+ onScreenBlurred = () => {
128
+ if (this._vdoPlayerView) {
129
+ this._vdoPlayerView.setScreenBlurred();
130
+ }
131
+ };
132
+
94
133
  handleBackButtonClick() {
95
134
  if (!this.state.isInPictureInPictureMode && this.state.fullscreen && !(this.props.showNativeControls === false)) {
96
135
  this._vdoPlayerView.handleBackButtonClick();
@@ -425,6 +464,9 @@ class VdoPlayerView extends Component<MyProps, MyState> {
425
464
  }
426
465
  }
427
466
 
467
+ if (NavigationContext) {
468
+ VdoPlayerView.contextType = NavigationContext; // Assign the context type only if NavigationContext is available
469
+ }
428
470
  VdoPlayerView.propTypes = VdoViewPropTypes;
429
471
 
430
472
  export default VdoPlayerView;
@@ -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.20.7"
22
- def releaseVersionCode = 39
21
+ def releaseVersionName = "1.20.8"
22
+ def releaseVersionCode = 40
23
23
 
24
24
  android {
25
25
  compileSdkVersion 33
@@ -305,7 +305,7 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
305
305
  */
306
306
  private void updatePlaybackState(
307
307
  @PlaybackStateCompat.State int state, long position, float playBackSpeed) {
308
- if (mSession == null) return;
308
+ if (mSession == null || mSession.getController() == null || mSession.getController().getPlaybackState() == null) return;
309
309
  long actions = mSession.getController().getPlaybackState().getActions();
310
310
  updatePlaybackState(state, actions, position, playBackSpeed);
311
311
  }
@@ -29,8 +29,6 @@ class RCTVdoPlayerUIView: VdoCipherRNView {
29
29
  if self.playerState == .unknown {
30
30
  self.showActivityIndicator()
31
31
  }
32
- guard let reactVC = self.reactViewController() else {return}
33
- reactVC.navigationController?.delegate = self
34
32
  })
35
33
  }
36
34
 
@@ -18,9 +18,6 @@ class RCTVdoPlayerView: VdoCipherRNView {
18
18
  override func setEmbedInfo(_ embedInfo: [String: Any]) {
19
19
  super.setEmbedInfo(embedInfo)
20
20
  EventEmitter.sharedInstance.dispatch(name: EventName.EVENT_LOADING, params: nil)
21
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.33 , execute: {
22
- self.reactViewController().navigationController?.delegate = self
23
- })
24
21
  if embedInfo["offline"] as? Bool == true {
25
22
  self.parseOfflineCredentials(fromInfo: embedInfo)
26
23
  } else {
@@ -326,6 +326,10 @@ class VdoCipherRNView: UIView {
326
326
 
327
327
  asset.enableAutoAdaptation()
328
328
  }
329
+
330
+ @objc func setScreenFocused(_ val: Bool) {
331
+ setPlayWhenReady(val)
332
+ }
329
333
 
330
334
  func setCaptionLanguage(lanCode: String?) -> Bool {
331
335
  var isSuccess: Bool = false
@@ -431,22 +435,6 @@ extension VdoCipherRNView: VdoPlayerViewControllerDelegate {
431
435
  }
432
436
  }
433
437
 
434
- extension VdoCipherRNView: UINavigationControllerDelegate {
435
- // MARK: 'UINavigationControllerDelegate' FUNCTIONS
436
- func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
437
-
438
- }
439
-
440
- func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
441
- guard let parentController = self.reactViewController() else {return}
442
- if viewController != parentController {
443
- player?.pause()
444
- } else if viewController == parentController {
445
- player?.rate = targetPlaybackSpeed
446
- }
447
- }
448
- }
449
-
450
438
  enum PlayerState : String {
451
439
  case buffering = "buffering",
452
440
  ready = "ready",
@@ -30,6 +30,7 @@ RCT_EXPORT_VIEW_PROPERTY(disableCaptions, int)
30
30
  RCT_EXPORT_VIEW_PROPERTY(videoQuality, NSDictionary *)
31
31
  RCT_EXPORT_VIEW_PROPERTY(adaptiveVideo, BOOL)
32
32
  RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL)
33
+ RCT_EXPORT_VIEW_PROPERTY(screenFocused, BOOL)
33
34
 
34
35
  - (VdoCipherRNView *)view
35
36
  {
@@ -5,7 +5,7 @@ import VdoFramework
5
5
  @objc(VdocipherRnBridge)
6
6
  class VdocipherRnBridge: RCTViewManager {
7
7
 
8
- static let vdocipherRnBridgeVersionString = "1.20.7"
8
+ static let vdocipherRnBridgeVersionString = "1.20.8"
9
9
 
10
10
  @objc override static func requiresMainQueueSetup() -> Bool {
11
11
  return true
@@ -0,0 +1,8 @@
1
+ export const getNavigationContext = (): any | null => {
2
+ try {
3
+ const NavigationPackage = require('@react-navigation/native');
4
+ return NavigationPackage.NavigationContext || null;
5
+ } catch (error) {
6
+ return null;
7
+ }
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.20.7",
3
+ "version": "1.20.8",
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": {
@@ -12,7 +12,7 @@
12
12
  "author": "",
13
13
  "license": "",
14
14
  "peerDependencies": {
15
- "react-native": "0.68 - 0.73"
15
+ "react-native": "0.68 - 0.75"
16
16
  },
17
17
  "dependencies": {
18
18
  "deprecated-react-native-prop-types": "^2.3.0",
@@ -30,7 +30,8 @@
30
30
  "index.ts",
31
31
  "tsconfig.json",
32
32
  "type.ts",
33
- "react-native-vdocipher-rn-bridge.podspec"
33
+ "react-native-vdocipher-rn-bridge.podspec",
34
+ "navigationHelper.ts"
34
35
  ],
35
36
  "devDependencies": {
36
37
  "@tsconfig/react-native": "^2.0.3",