vdocipher-rn-bridge 1.20.6 → 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
+ }
105
+ }
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
+ }
92
114
  }
93
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();
@@ -127,10 +166,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
127
166
  * Works only with player with native controls
128
167
  */
129
168
  enterFullscreenV2 = () => {
130
- if (Platform.OS == "ios" ) {
131
- console.warn("Method not supported for iOS");
132
- return;
133
- }
134
169
  if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
135
170
  this._vdoPlayerView.enterFullscreenV2();
136
171
  }
@@ -159,10 +194,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
159
194
  * Works only with player with native controls
160
195
  */
161
196
  exitFullscreenV2 = () => {
162
- if (Platform.OS == "ios" ) {
163
- console.warn("Method not supported for iOS");
164
- return;
165
- }
166
197
  if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
167
198
  this._vdoPlayerView.exitFullscreenV2();
168
199
  }
@@ -433,6 +464,9 @@ class VdoPlayerView extends Component<MyProps, MyState> {
433
464
  }
434
465
  }
435
466
 
467
+ if (NavigationContext) {
468
+ VdoPlayerView.contextType = NavigationContext; // Assign the context type only if NavigationContext is available
469
+ }
436
470
  VdoPlayerView.propTypes = VdoViewPropTypes;
437
471
 
438
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.6"
22
- def releaseVersionCode = 38
21
+ def releaseVersionName = "1.20.8"
22
+ def releaseVersionCode = 40
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.26.6'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.26.9'
90
90
  }
@@ -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
  }
@@ -278,10 +278,14 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
278
278
  VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(getReactApplicationContext());
279
279
  vdoDownloadManager.query(query, statusList -> {
280
280
  Log.i(TAG, statusList.size() + " results found");
281
- boolean isExpired = statusList.get(0).isExpired(getReactApplicationContext());
282
- successCallback.invoke(
283
- isExpired
284
- );
281
+ if (statusList.size() > 0) {
282
+ boolean isExpired = statusList.get(0).isExpired(getReactApplicationContext());
283
+ successCallback.invoke(
284
+ isExpired
285
+ );
286
+ } else {
287
+ errorCallback.invoke(null, "Video not found");
288
+ }
285
289
  });
286
290
  } catch (RuntimeException e) {
287
291
  Log.e(TAG, "error fetching expiry: " + Log.getStackTraceString(e));
@@ -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
 
@@ -79,4 +77,13 @@ class RCTVdoPlayerUIView: VdoCipherRNView {
79
77
  activityView = nil
80
78
  }
81
79
  }
80
+
81
+ @objc func setFullscreen(_ val: Bool) {
82
+ let playerViewController = VdoCipher.getVdoPlayerViewController()
83
+ if val == true {
84
+ playerViewController.enterFullscreen()
85
+ } else {
86
+ playerViewController.exitFullscreen()
87
+ }
88
+ }
82
89
  }
@@ -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",
@@ -29,6 +29,8 @@ RCT_EXPORT_VIEW_PROPERTY(captionLanguage, NSDictionary *)
29
29
  RCT_EXPORT_VIEW_PROPERTY(disableCaptions, int)
30
30
  RCT_EXPORT_VIEW_PROPERTY(videoQuality, NSDictionary *)
31
31
  RCT_EXPORT_VIEW_PROPERTY(adaptiveVideo, BOOL)
32
+ RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL)
33
+ RCT_EXPORT_VIEW_PROPERTY(screenFocused, BOOL)
32
34
 
33
35
  - (VdoCipherRNView *)view
34
36
  {
@@ -5,7 +5,7 @@ import VdoFramework
5
5
  @objc(VdocipherRnBridge)
6
6
  class VdocipherRnBridge: RCTViewManager {
7
7
 
8
- static let vdocipherRnBridgeVersionString = "1.20.6"
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.6",
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",
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  s.dependency "React-Core"
20
- s.dependency "VdoFramework", "2.5.8"
20
+ s.dependency "VdoFramework", "2.6.0"
21
21
 
22
22
  # Don't install the dependencies when we run `pod install` in the old architecture.
23
23
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then