vdocipher-rn-bridge 1.15.0 → 1.17.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/VdoPlayerSupportView.tsx +6 -4
  3. package/VdoPlayerUIView.tsx +21 -9
  4. package/VdoPlayerView.tsx +184 -58
  5. package/android/build.gradle +3 -3
  6. package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +47 -32
  7. package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +5 -0
  8. package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +10 -10
  9. package/android/src/main/java/com/vdocipher/rnbridge/VdoDownloadModule.java +67 -0
  10. package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +1 -10
  11. package/downloadMonitor.ts +2 -2
  12. package/downloads.ts +63 -1
  13. package/index.ts +4 -1
  14. package/ios/Podfile +10 -0
  15. package/ios/Podfile.lock +3 -0
  16. package/ios/Pods/Manifest.lock +3 -0
  17. package/ios/Pods/Pods.xcodeproj/project.pbxproj +397 -0
  18. package/ios/Pods/Pods.xcodeproj/xcuserdata/mansisharma.xcuserdatad/xcschemes/Pods-VdocipherRnBridge.xcscheme +58 -0
  19. package/ios/Pods/Pods.xcodeproj/xcuserdata/mansisharma.xcuserdatad/xcschemes/xcschememanagement.plist +16 -0
  20. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-Info.plist +26 -0
  21. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-acknowledgements.markdown +3 -0
  22. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-acknowledgements.plist +29 -0
  23. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-dummy.m +5 -0
  24. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-umbrella.h +16 -0
  25. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.debug.xcconfig +8 -0
  26. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.modulemap +6 -0
  27. package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.release.xcconfig +8 -0
  28. package/ios/RCTVdoPlayerUIView.h +19 -0
  29. package/ios/RCTVdoPlayerUIView.swift +74 -0
  30. package/ios/RCTVdoPlayerView.h +18 -0
  31. package/ios/RCTVdoPlayerView.swift +84 -0
  32. package/ios/TrackSelection.swift +64 -0
  33. package/ios/VdoCipherRNView.h +18 -0
  34. package/ios/VdoCipherRNView.swift +312 -0
  35. package/ios/VdoDownload.swift +103 -0
  36. package/ios/VdoEventEmitter.swift +157 -0
  37. package/ios/VdoPlaybackProperties.h +19 -0
  38. package/ios/VdoPlaybackProperties.swift +21 -0
  39. package/ios/VdocipherRnBridge.h +2 -10
  40. package/ios/VdocipherRnBridgeViewManager.m +99 -0
  41. package/ios/VdocipherRnBridgeViewManager.swift +90 -0
  42. package/package.json +3 -2
  43. package/react-native-vdocipher-rn-bridge.podspec +36 -0
  44. package/type.ts +23 -1
  45. package/ios/VdocipherRnBridge.m +0 -13
  46. package/ios/VdocipherRnBridge.xcodeproj/project.pbxproj +0 -259
  47. package/ios/VdocipherRnBridge.xcworkspace/contents.xcworkspacedata +0 -9
package/CHANGELOG.md CHANGED
@@ -1,4 +1,31 @@
1
1
  ## Changelog
2
+ ### 1.17.0
3
+ * Added support for iOS with native iOS sdk version as 2.4.3
4
+ * Updated VdoCipher Android SDK dependency to 1.22.1.
5
+ * Added option to pause and resume downloads.
6
+ * Bug fixes:
7
+ * minHeight getting overridden by sdk.
8
+ * NullPointerException when downloading using invalid params.
9
+ * IllegalStateException when opening new screen from player screen and coming back.
10
+ * NullPointerException on some devices when going fullscreen by using prop method in PlayerUI.
11
+ * ForegroundServiceStartNotAllowedException coming in Android 12 and above.
12
+
13
+ ### 1.16.0
14
+ * Updated VdoCipher Android SDK dependency to 1.21.0.
15
+ * Added support for `windowLayoutInDisplayCutoutMode` with inbuilt player UI.
16
+ * Improved feedback of double tap to skip forward and backward.
17
+ * Fullscreen Changes for Player UI:
18
+ * Fixed auto rotate lock while going into fullscreen mode.
19
+ * Implemented fullscreen behavior based on aspect ratio:
20
+ * Vertical videos will go fullscreen in portrait mode.
21
+ * Horizontal videos will go fullscreen in landscape mode.
22
+ * Deprecated `enterFullscreen` and `exitFullscreen` APIs.
23
+ * Added `enterFullscreenV2` and `exitFullscreenV2` APIs with aspect ratio-based fullscreen rotation.
24
+ * Fullscreen Changes for Player with Custom Controls:
25
+ * Deprecated `enterFullscreen` and `exitFullscreen` APIs.
26
+ * Removed the option to go back to portrait mode when the back button is pressed while in fullscreen mode.
27
+ * Fullscreen-related changes need to be performed manually.
28
+
2
29
  ### 1.15.0
3
30
  * Updated VdoCipher android sdk dependency to 1.19.6
4
31
  * 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,17 +75,29 @@
75
75
  }
76
76
  }
77
77
 
78
- enterFullscreen = () => {
79
- if (this._root) {
80
- this._root.setNativeProps({fullscreen: true});
78
+ /**
79
+ * @deprecated
80
+ * Use {@link enterFullscreenV2} instead.
81
+ */
82
+ enterFullscreen = () => {}
83
+
84
+ enterFullscreenV2 = () => {
85
+ if (this._root) {
86
+ this._root.setNativeProps({fullscreen: true});
87
+ }
81
88
  }
82
- }
83
89
 
84
- exitFullscreen = () => {
85
- if (this._root) {
86
- this._root.setNativeProps({fullscreen: false});
90
+ /**
91
+ * @deprecated
92
+ * Use {@link exitFullscreenV2} instead.
93
+ */
94
+ exitFullscreen = () => {}
95
+
96
+ exitFullscreenV2 = () => {
97
+ if (this._root) {
98
+ this._root.setNativeProps({fullscreen: false});
99
+ }
87
100
  }
88
- }
89
101
 
90
102
  getPlaybackProperties = () => {
91
103
  if (this._root) {
package/VdoPlayerView.tsx CHANGED
@@ -3,18 +3,17 @@
3
3
  */
4
4
  import React, { Component, Fragment } from 'react';
5
5
  import { InferProps } from 'prop-types';
6
- import { BackHandler, NativeModules, StyleSheet, Dimensions} from 'react-native';
6
+ import { BackHandler, NativeModules, StyleSheet, Dimensions, NativeEventEmitter, Platform} from 'react-native';
7
7
  import VdoPlayerSupportView from './VdoPlayerSupportView';
8
8
  import VdoPlayerUIView from './VdoPlayerUIView';
9
9
  import * as VdoType from './type';
10
- const { TrackSelection, VdoPlayer } = NativeModules;
10
+ const { TrackSelection, VdoPlayer, VdoEventEmitter } = NativeModules;
11
11
 
12
12
  const VdoViewPropTypes = VdoType.VdoPropTypes;
13
13
 
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
 
@@ -22,16 +21,17 @@ class VdoPlayerView extends Component<MyProps, MyState> {
22
21
  _propRef: number;
23
22
  _vdoPlayerView: any;
24
23
  static propTypes: typeof VdoViewPropTypes;
24
+ eventEmitter: NativeEventEmitter;
25
25
 
26
26
  constructor(props: MyProps) {
27
27
  super(props);
28
28
  this.state = {
29
29
  fullscreen: false,
30
- isInitialPortrait: true,
31
30
  isInPictureInPictureMode: false
32
31
  }
33
32
  this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
34
33
  this._propRef = 1;
34
+ this.eventEmitter = new NativeEventEmitter(VdoEventEmitter);
35
35
  }
36
36
 
37
37
  componentDidMount() {
@@ -39,44 +39,151 @@ class VdoPlayerView extends Component<MyProps, MyState> {
39
39
  if (this.props.style?.resizeMode) {
40
40
  this._vdoPlayerView.setResizeMode(this.props.style.resizeMode);
41
41
  }
42
+
43
+ this.eventEmitter.addListener('onInitSuccess', this._onInitSuccess)
44
+
45
+ this.eventEmitter.addListener('onVdoLoading', (data) => {
46
+ this._onLoading(this.props.embedInfo, data);
47
+ })
48
+
49
+ this.eventEmitter.addListener('onVdoLoadError', (data) => {
50
+ this._onLoadError(this.props.embedInfo, data);
51
+ })
52
+
53
+ this.eventEmitter.addListener('onVdoProgress', this._onProgress)
54
+ this.eventEmitter.addListener('onVdoLoaded', (data) => {
55
+ this._onLoaded(this.props.embedInfo, data);
56
+ })
57
+
58
+ this.eventEmitter.addListener('onVdoTracksChanged', (data) => {
59
+ this._onTracksChanged(data);
60
+ })
61
+
62
+ this.eventEmitter.addListener('onVdoMediaEnded', (data) => {
63
+ this._onMediaEnded(this.props.embedInfo, data);
64
+ })
65
+
66
+ this.eventEmitter.addListener('onVdoPlayerStateChanged', (data) => {
67
+ this._onPlayerStateChanged(data);
68
+ })
69
+
70
+ this.eventEmitter.addListener('onVdoEnterFullscreen', this._onEnterFullscreen)
71
+
72
+ this.eventEmitter.addListener('onVdoExitFullscreen', this._onExitFullscreen)
73
+
74
+ this.eventEmitter.addListener('onVdoPlaybackSpeedChanged', (data) => {
75
+ this._onPlaybackSpeedChanged(data);
76
+ })
42
77
  }
43
78
 
44
79
  componentWillUnmount() {
45
80
  BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
81
+ this.eventEmitter.removeAllListeners('onInitSuccess');
82
+ this.eventEmitter.removeAllListeners('onVdoLoading');
83
+ this.eventEmitter.removeAllListeners('onVdoLoadError');
84
+ this.eventEmitter.removeAllListeners('onVdoLoaded');
85
+ this.eventEmitter.removeAllListeners('onVdoProgress');
86
+ this.eventEmitter.removeAllListeners('onVdoTracksChanged');
87
+ this.eventEmitter.removeAllListeners('onVdoMediaEnded');
88
+ this.eventEmitter.removeAllListeners('onVdoPlayerStateChanged');
89
+ this.eventEmitter.removeAllListeners('onVdoEnterFullscreen');
90
+ this.eventEmitter.removeAllListeners('onVdoExitFullscreen');
91
+ this.eventEmitter.removeAllListeners('onVdoPlaybackSpeedChanged');
46
92
  }
47
93
 
48
94
  handleBackButtonClick() {
49
- if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.state.isInitialPortrait) {
50
- this._vdoPlayerView.handleBackButtonClick();
51
- return true;
52
- }
95
+ if (!this.state.isInPictureInPictureMode && this.state.fullscreen && !(this.props.showNativeControls === false)) {
96
+ this._vdoPlayerView.handleBackButtonClick();
97
+ return true;
98
+ }
53
99
  }
54
100
 
55
101
  seek = (seekTargetMs: number) => {
56
- if (this._vdoPlayerView) {
57
- this._vdoPlayerView.seek(seekTargetMs);
102
+ if (this._vdoPlayerView) {
103
+ this._vdoPlayerView.seek(seekTargetMs);
104
+ }
58
105
  }
59
- }
60
106
 
107
+ /**
108
+ * @deprecated
109
+ * Use {@link enterFullscreenV2} instead.
110
+ */
61
111
  enterFullscreen = () => {
62
- if (this._vdoPlayerView) {
63
- this._vdoPlayerView.enterFullscreen();
64
- }
65
- }
112
+ if (Platform.OS == "ios" ) {
113
+ console.warn("Method not supported for iOS");
114
+ return;
115
+ }
116
+ if (this.props.showNativeControls === false) {
117
+ console.warn('enterFullscreen method is deprecated. We advise handling fullscreen changes manually or utilizing our player with native controls which handles fullscreen automatically.');
118
+ } else {
119
+ console.warn('enterFullscreen method is deprecated. Please use enterFullscreenV2 instead.');
120
+ }
121
+ if (this._vdoPlayerView) {
122
+ this._vdoPlayerView.enterFullscreen();
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Works only with player with native controls
128
+ */
129
+ enterFullscreenV2 = () => {
130
+ if (Platform.OS == "ios" ) {
131
+ console.warn("Method not supported for iOS");
132
+ return;
133
+ }
134
+ if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
135
+ this._vdoPlayerView.enterFullscreenV2();
136
+ }
137
+ }
66
138
 
139
+ /**
140
+ * @deprecated
141
+ * Use {@link exitFullscreenV2} instead.
142
+ */
67
143
  exitFullscreen = () => {
68
- if (this._vdoPlayerView) {
69
- this._vdoPlayerView.exitFullscreen();
70
- }
71
- }
144
+ if (Platform.OS == "ios" ) {
145
+ console.warn("Method not supported for iOS");
146
+ return;
147
+ }
148
+ if (this.props.showNativeControls === false) {
149
+ console.warn('exitFullscreen method is deprecated. We advise handling fullscreen changes manually or utilizing our player with native controls which handles fullscreen automatically.');
150
+ } else {
151
+ console.warn('exitFullscreen method is deprecated. Please use exitFullscreenV2 instead.');
152
+ }
153
+ if (this._vdoPlayerView) {
154
+ this._vdoPlayerView.exitFullscreen();
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Works only with player with native controls
160
+ */
161
+ exitFullscreenV2 = () => {
162
+ if (Platform.OS == "ios" ) {
163
+ console.warn("Method not supported for iOS");
164
+ return;
165
+ }
166
+ if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
167
+ this._vdoPlayerView.exitFullscreenV2();
168
+ }
169
+ }
72
170
 
73
171
  getPlaybackProperties = () => {
74
- if (this._vdoPlayerView) {
75
- this._vdoPlayerView.getPlaybackProperties();
76
- }
77
- }
172
+ if (Platform.OS == "ios" ) {
173
+ console.warn("Method not supported for iOS");
174
+ return;
175
+ }
176
+ if (this._vdoPlayerView) {
177
+ this._vdoPlayerView.getPlaybackProperties();
178
+ }
179
+ }
78
180
 
79
181
  isAdaptive = async() => {
182
+ if (Platform.OS == "ios" ) {
183
+ return new Promise(function(resolve, reject) {
184
+ reject("Method not supported for iOS");
185
+ });
186
+ }
80
187
  return new Promise(async(resolve) => { await TrackSelection.isAdaptive((isAdaptive: boolean) => {
81
188
  resolve(isAdaptive);
82
189
  });
@@ -84,37 +191,60 @@ class VdoPlayerView extends Component<MyProps, MyState> {
84
191
  }
85
192
 
86
193
  getVideoQualities = async() => {
87
- return new Promise(async(resolve) => { await TrackSelection.getVideoQualities((videoQualities: Array<VdoType.VideoQuality>) => {
88
- resolve(videoQualities);
89
- });
90
- });
91
- }
194
+ if (Platform.OS == "ios" ) {
195
+ return new Promise(function(resolve, reject) {
196
+ reject("Method not supported for iOS");
197
+ });
198
+ }
199
+ return new Promise(async(resolve) => { await TrackSelection.getVideoQualities((videoQualities: Array<VdoType.VideoQuality>) => {
200
+ resolve(videoQualities);
201
+ });
202
+ });
203
+ }
92
204
 
93
205
  getSelectedVideoQuality = async() => {
94
- return new Promise(async(resolve) => { await TrackSelection.getSelectedVideoQuality((selectedVideoQuality: VdoType.VideoQuality) => {
95
- resolve(selectedVideoQuality);
96
- });
97
- });
98
- }
206
+ if (Platform.OS == "ios" ) {
207
+ return new Promise(function(resolve, reject) {
208
+ reject("Method not supported for iOS");
209
+ });
210
+ }
211
+ return new Promise(async(resolve) => { await TrackSelection.getSelectedVideoQuality((selectedVideoQuality: VdoType.VideoQuality) => {
212
+ resolve(selectedVideoQuality);
213
+ });
214
+ });
215
+ }
99
216
 
100
217
  setVideoQuality = (videoQuality: VdoType.VideoQuality) => {
101
- if (this._vdoPlayerView) {
102
- this._vdoPlayerView.setVideoQuality(videoQuality);
103
- }
104
- }
218
+ if (Platform.OS == "ios" ) {
219
+ console.warn("Method not supported for iOS");
220
+ return;
221
+ }
222
+ if (this._vdoPlayerView) {
223
+ this._vdoPlayerView.setVideoQuality(videoQuality);
224
+ }
225
+ }
105
226
 
106
227
  enableAdaptiveVideo = () => {
107
- if (this._vdoPlayerView) {
108
- this._vdoPlayerView.enableAdaptiveVideo();
109
- }
110
- }
228
+ if (Platform.OS == "ios" ) {
229
+ console.warn("Method not supported for iOS");
230
+ return;
231
+ }
232
+ if (this._vdoPlayerView) {
233
+ this._vdoPlayerView.enableAdaptiveVideo();
234
+ }
235
+ }
111
236
 
112
237
  getSelectedAudioQuality = async() => {
113
- return new Promise(async(resolve) => { await TrackSelection.getSelectedAudioQuality((selectedAudioQuality: VdoType.AudioQuality) => {
114
- resolve(selectedAudioQuality);
115
- });
116
- });
117
- }
238
+ if (Platform.OS == "ios" ) {
239
+ return new Promise(function(resolve, reject) {
240
+ reject("Method not supported for iOS");
241
+ });
242
+ }
243
+ return new Promise(async(resolve) => { await TrackSelection.getSelectedAudioQuality((selectedAudioQuality: VdoType.AudioQuality) => {
244
+ resolve(selectedAudioQuality);
245
+ });
246
+ });
247
+ }
118
248
 
119
249
  getCaptionLanguages = async() => {
120
250
  return new Promise(async(resolve) => { await TrackSelection.getCaptionLanguages((captionLanguages: Array<VdoType.CaptionLanguage>) => {
@@ -150,10 +280,14 @@ class VdoPlayerView extends Component<MyProps, MyState> {
150
280
  }
151
281
 
152
282
  setAspectRatio = (aspectRatio: number) => {
153
- if (this._vdoPlayerView) {
154
- this._vdoPlayerView.setAspectRatio(aspectRatio);
283
+ if (Platform.OS == "ios" ) {
284
+ console.warn("Method not supported for iOS");
285
+ return;
286
+ }
287
+ if (this._vdoPlayerView) {
288
+ this._vdoPlayerView.setAspectRatio(aspectRatio);
289
+ }
155
290
  }
156
- }
157
291
 
158
292
  getPlaybackPropertiesV2 = async() => {
159
293
  return new Promise(async(resolve) => { await VdoPlayer.getPlaybackPropertiesV2((playbackProperties: VdoType.PlaybackProperty) => {
@@ -260,12 +394,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
260
394
  }
261
395
  }
262
396
 
263
- _onIsInitialPortrait =(event: any) => {
264
- this.setState({
265
- isInitialPortrait: event.nativeEvent.isInitialPortrait
266
- });
267
- }
268
-
269
397
  _onPictureInPictureModeChanged = (event: any) => {
270
398
  this.setState({
271
399
  isInPictureInPictureMode: event.nativeEvent.isInPictureInPictureMode
@@ -297,14 +425,13 @@ class VdoPlayerView extends Component<MyProps, MyState> {
297
425
  onVdoPlaybackProperties={this._onPlaybackProperties}
298
426
  onVdoEnterFullscreen={this._onEnterFullscreen}
299
427
  onVdoExitFullscreen={this._onExitFullscreen}
300
- onIsInitialPortrait={this._onIsInitialPortrait}
301
428
  onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
302
429
  />
303
430
  ) :
304
431
  (
305
432
  <VdoPlayerUIView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
306
433
  {...this.props}
307
- style={this.props.style ? [this.props.style, styles.playerWithUserStyles] : styles.player}
434
+ style={this.props.style ? [styles.playerWithUserStyles, this.props.style] : styles.player}
308
435
  onInitSuccess={this._onInitSuccess}
309
436
  onInitFailure={this._onInitFailure}
310
437
  onVdoLoading={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
@@ -320,7 +447,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
320
447
  onVdoPlaybackProperties={this._onPlaybackProperties}
321
448
  onVdoEnterFullscreen={this._onEnterFullscreen}
322
449
  onVdoExitFullscreen={this._onExitFullscreen}
323
- onIsInitialPortrait={this._onIsInitialPortrait}
324
450
  onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
325
451
  />
326
452
  )
@@ -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.17.0"
22
+ def releaseVersionCode = 21
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.22.1'
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,21 @@ 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
+ if (isRunningOnTv(activity)) {
95
+ vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
96
+ }
97
+ // initialize the playerFragment; a VdoPlayer instance will be received
98
+ // in onInitializationSuccess() callback
99
+ vdoPlayerUIFragment.initialize(initializationListener);
100
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
101
+ vdoPlayerUIFragment.setFullscreenActionListener(fullscreenToggleListener);
102
+ } catch(Exception e) {
103
+ e.printStackTrace();
104
+ }
96
105
  }
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
106
  }, 200);
103
107
  }
104
108
  }
@@ -176,7 +180,7 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
176
180
  }
177
181
 
178
182
  public void setKeyDownEvent(KeyEvent event) {
179
- if (! vdoPlayerControlView.controllerVisible()) {
183
+ if (vdoPlayerControlView != null && ! vdoPlayerControlView.controllerVisible()) {
180
184
  vdoPlayerControlView.onKeyDown(event.getKeyCode(), event);
181
185
  }
182
186
  }
@@ -189,7 +193,20 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
189
193
  };
190
194
  activity.addOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
191
195
  }
192
- }
196
+ }
197
+
198
+ private void setFullscreenActionListener() {
199
+ fullscreenToggleListener = isFullscreen -> {
200
+
201
+ if (isFullscreen) {
202
+ eventEmitter.enterFullscreen();
203
+ } else {
204
+ eventEmitter.exitFullscreen();
205
+ }
206
+
207
+ return false;
208
+ };
209
+ }
193
210
 
194
211
  public void setResizeMode(String resizeModeName) {
195
212
  this.resizeMode = resizeModeIntFromName(resizeModeName);
@@ -364,11 +381,20 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
364
381
  layout(getLeft(), getTop(), getRight(), getBottom());
365
382
  };
366
383
 
384
+
367
385
  public void setFullscreen(boolean setFullscreen) {
368
- if (!setFullscreen) {
369
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
370
- } else {
371
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
386
+ if (vdoPlayerUIFragment != null) {
387
+ if (setFullscreen) {
388
+ vdoPlayerUIFragment.enterFullScreen();
389
+ } else {
390
+ vdoPlayerUIFragment.exitFullScreen();
391
+ }
392
+ }
393
+ }
394
+
395
+ public void setBackpressCalled() {
396
+ if (vdoPlayerUIFragment != null) {
397
+ vdoPlayerUIFragment.setBackPressCalled();
372
398
  }
373
399
  }
374
400
 
@@ -481,16 +507,5 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
481
507
  }
482
508
  };
483
509
 
484
- @Override
485
- public void accept(Configuration configuration) {
486
- int newOrientation = configuration.orientation;
487
510
 
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
511
  }
@@ -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
  }