vdocipher-rn-bridge 1.12.3 → 1.13.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,9 @@
1
1
  ## Changelog
2
+ ### 1.13.0
3
+ * Updated VdoCipher android sdk dependency to 1.19.3
4
+ * Added support for setting aspect ratio and resize mode
5
+
6
+
2
7
  ### 1.12.3
3
8
  * Adding typescript support
4
9
 
@@ -70,6 +70,18 @@ class VdoPlayerSupportView extends Component<MyProps> {
70
70
  }
71
71
  }
72
72
 
73
+ setResizeMode = (resizeMode: String) => {
74
+ if (this._root) {
75
+ this._root.setNativeProps({resizeMode: resizeMode});
76
+ }
77
+ }
78
+
79
+ setAspectRatio = (aspectRatio: number) => {
80
+ if (this._root) {
81
+ this._root.setNativeProps({aspectRatio: aspectRatio});
82
+ }
83
+ }
84
+
73
85
  render() {
74
86
  return (
75
87
  <RCTVdoPlayerView ref={(component: any) => this._root = component}
@@ -99,6 +99,18 @@
99
99
  }
100
100
  }
101
101
 
102
+ setResizeMode = (resizeMode: String) => {
103
+ if (this._root) {
104
+ this._root.setNativeProps({resizeMode: resizeMode});
105
+ }
106
+ }
107
+
108
+ setAspectRatio = (aspectRatio: number) => {
109
+ if (this._root) {
110
+ this._root.setNativeProps({aspectRatio: aspectRatio});
111
+ }
112
+ }
113
+
102
114
  render() {
103
115
  return (
104
116
  <RCTVdoPlayerUIView ref={(component: any) => this._root = component}
package/VdoPlayerView.tsx CHANGED
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import React, { Component, Fragment } from 'react';
5
5
  import { InferProps } from 'prop-types';
6
- import { BackHandler, NativeModules} from 'react-native';
6
+ import { BackHandler, NativeModules, StyleSheet, Dimensions} from 'react-native';
7
7
  import VdoPlayerSupportView from './VdoPlayerSupportView';
8
8
  import VdoPlayerUIView from './VdoPlayerUIView';
9
9
  import * as VdoType from './type';
@@ -36,6 +36,9 @@ class VdoPlayerView extends Component<MyProps, MyState> {
36
36
 
37
37
  componentDidMount() {
38
38
  BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
39
+ if (this.props.style?.resizeMode) {
40
+ this._vdoPlayerView.setResizeMode(this.props.style.resizeMode);
41
+ }
39
42
  }
40
43
 
41
44
  componentWillUnmount() {
@@ -146,6 +149,12 @@ class VdoPlayerView extends Component<MyProps, MyState> {
146
149
  });
147
150
  }
148
151
 
152
+ setAspectRatio = (aspectRatio: number) => {
153
+ if (this._vdoPlayerView) {
154
+ this._vdoPlayerView.setAspectRatio(aspectRatio);
155
+ }
156
+ }
157
+
149
158
  _onInitSuccess = (event: any) => {
150
159
  if (this.props.onInitializationSuccess) {
151
160
  this.props.onInitializationSuccess(event.nativeEvent);
@@ -288,6 +297,7 @@ class VdoPlayerView extends Component<MyProps, MyState> {
288
297
  (
289
298
  <VdoPlayerUIView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
290
299
  {...this.props}
300
+ style={this.props.style ? [this.props.style, styles.playerWithUserStyles] : styles.player}
291
301
  onInitSuccess={this._onInitSuccess}
292
302
  onInitFailure={this._onInitFailure}
293
303
  onVdoLoading={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
@@ -316,3 +326,13 @@ class VdoPlayerView extends Component<MyProps, MyState> {
316
326
  VdoPlayerView.propTypes = VdoViewPropTypes;
317
327
 
318
328
  export default VdoPlayerView;
329
+
330
+ const styles = StyleSheet.create({
331
+ player: {
332
+ minHeight: (Dimensions.get('window').width / 16) * 9,
333
+ width: '100%',
334
+ },
335
+ playerWithUserStyles: {
336
+ minHeight: (Dimensions.get('window').width / 16) * 9
337
+ }
338
+ });
@@ -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.12.3"
22
- def releaseVersionCode = 14
21
+ def releaseVersionName = "1.13.0"
22
+ def releaseVersionCode = 15
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.1'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.19.3'
90
90
  }
@@ -24,9 +24,11 @@ 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
27
  import androidx.core.util.Consumer;
29
28
  import android.graphics.Color;
29
+ import static com.vdocipher.rnbridge.Utils.*;
30
+ import com.vdocipher.aegis.player.PlayerHost;
31
+ import androidx.core.app.PictureInPictureModeChangedInfo;
30
32
 
31
33
 
32
34
  public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
@@ -50,6 +52,8 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
50
52
 
51
53
  private Consumer<PictureInPictureModeChangedInfo> pictureModeChangedInfoConsumer;
52
54
 
55
+ private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
56
+
53
57
  public ReactVdoPlayerUIView(ThemedReactContext context) {
54
58
  super(context);
55
59
  themedReactContext = context;
@@ -67,18 +71,21 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
67
71
  eventEmitter.isInitialPortrait();
68
72
  }
69
73
 
74
+ setPictureInPictureSupport();
75
+
70
76
  }
71
77
 
72
78
  private void initializePlayer() {
73
79
  if (vdoPlayerUIFragment != null) {
74
80
  new Handler().postDelayed(() -> {
75
81
  if (fragmentManager != null && !fragmentManager.isDestroyed()) {
76
- fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, VdoPlayerUIFragment.class.getName()).commitNow();
82
+ fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitNow();
77
83
  }
78
84
  vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
79
85
  // initialize the playerFragment; a VdoPlayer instance will be received
80
86
  // in onInitializationSuccess() callback
81
87
  vdoPlayerUIFragment.initialize(initializationListener);
88
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
82
89
  }, 200);
83
90
  }
84
91
  }
@@ -138,15 +145,23 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
138
145
  }
139
146
 
140
147
  public void setPictureInPictureSupport() {
141
- if (vdoPlayerUIFragment != null) {
142
- vdoPlayerUIFragment.setPictureInPictureSupport(true);
148
+ if (!isRunningOnTv(activity)) {
143
149
  pictureModeChangedInfoConsumer = pictureInPictureModeChangedInfo ->
144
150
  {
145
151
  eventEmitter.onPictureInPictureModeChanged(pictureInPictureModeChangedInfo.isInPictureInPictureMode());
146
152
  };
147
-
148
153
  activity.addOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
149
154
  }
155
+ }
156
+
157
+ public void setResizeMode(String resizeModeName) {
158
+ this.resizeMode = resizeModeIntFromName(resizeModeName);
159
+ }
160
+
161
+ public void setAspectRatio(float aspectRatio) {
162
+ if( vdoPlayerUIFragment != null) {
163
+ vdoPlayerUIFragment.setAspectRatio(aspectRatio);
164
+ }
150
165
  }
151
166
 
152
167
  @Override
@@ -232,7 +247,6 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
232
247
  Log.d(TAG, "init success");
233
248
  vdoPlayer = player;
234
249
  vdoPlayer.addPlaybackEventListener(playbackListener);
235
-
236
250
  eventEmitter.initSuccess(restored);
237
251
 
238
252
  // load pending params
@@ -63,7 +63,6 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
63
63
  embedInfo.getString("safetyNetApiKey") : null;
64
64
  boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
65
65
  embedInfo.getBoolean("allowAdbDebugging");
66
- boolean setPictureInPictureSupport = embedInfo.hasKey("setPictureInPictureSupport") && embedInfo.getBoolean("setPictureInPictureSupport");
67
66
 
68
67
  VdoInitParams.Builder builder = new VdoInitParams.Builder();
69
68
 
@@ -115,10 +114,6 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
115
114
  }
116
115
 
117
116
  initParams = builder.build();
118
-
119
- if (setPictureInPictureSupport) {
120
- vdoPlayerView.setPictureInPictureSupport();
121
- }
122
117
 
123
118
  vdoPlayerView.load(initParams);
124
119
  }
@@ -153,4 +148,14 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
153
148
  public void setKeyDownEvent(ReactVdoPlayerUIView vdoPlayerView, ReadableMap eventMap) {
154
149
  vdoPlayerView.setKeyDownEvent(new KeyEvent(eventMap.getInt("action"), eventMap.getInt("code")));
155
150
  }
151
+
152
+ @ReactProp(name = "resizeMode")
153
+ public void setResizeMode(ReactVdoPlayerUIView vdoPlayerView, String resizeMode) {
154
+ vdoPlayerView.setResizeMode(resizeMode);
155
+ }
156
+
157
+ @ReactProp(name = "aspectRatio")
158
+ public void setAspectRatio(ReactVdoPlayerUIView vdoPlayerView, float aspectRatio) {
159
+ vdoPlayerView.setAspectRatio(aspectRatio);
160
+ }
156
161
  }
@@ -22,7 +22,6 @@ import com.vdocipher.aegis.player.VdoPlayer.PlaybackEventListener;
22
22
  import com.vdocipher.aegis.player.VdoInitParams;
23
23
  import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
24
24
  import android.media.AudioManager;
25
- import android.app.UiModeManager;
26
25
  import android.content.Context;
27
26
 
28
27
  import androidx.core.app.PictureInPictureModeChangedInfo;
@@ -59,7 +58,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
59
58
  private float pendingPlaybackSpeed = 0;
60
59
  private boolean fullscreen = false;
61
60
 
62
- private boolean hasPictureInPictureSupport = false;
63
61
  private MediaSessionCompat mSession;
64
62
  public static final long MEDIA_ACTIONS_PLAY_PAUSE =
65
63
  PlaybackStateCompat.ACTION_PLAY
@@ -76,6 +74,8 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
76
74
  private Track[] selectedTracks;
77
75
  private Handler mainHandler;
78
76
 
77
+ private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
78
+
79
79
  public ReactVdoPlayerView(ThemedReactContext context) {
80
80
  super(context);
81
81
  context.addLifecycleEventListener(this);
@@ -93,6 +93,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
93
93
  eventEmitter.isInitialPortrait();
94
94
  }
95
95
 
96
+ setPictureInPictureSupport();
96
97
  audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
97
98
 
98
99
  }
@@ -106,6 +107,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
106
107
  // initialize the playerFragment; a VdoPlayer instance will be received
107
108
  // in onInitializationSuccess() callback
108
109
  vdoPlayerUIFragment.initialize(initializationListener);
110
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
109
111
  }, 200);
110
112
  }
111
113
  }
@@ -115,7 +117,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
115
117
  */
116
118
  public void cleanUp() {
117
119
  themedReactContext.removeLifecycleEventListener(this);
118
- if (hasPictureInPictureSupport && pictureModeChangedInfoConsumer != null) {
120
+ if (pictureModeChangedInfoConsumer != null) {
119
121
  activity.removeOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
120
122
  }
121
123
  if (vdoPlayer != null) {
@@ -195,8 +197,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
195
197
  }
196
198
 
197
199
  public void setPictureInPictureSupport() {
198
- if (!isRunningOnTv()) {
199
- hasPictureInPictureSupport = true;
200
+ if (!isRunningOnTv(activity)) {
200
201
  pictureModeChangedInfoConsumer = pictureInPictureModeChangedInfo ->
201
202
  {
202
203
  eventEmitter.onPictureInPictureModeChanged(pictureInPictureModeChangedInfo.isInPictureInPictureMode());
@@ -206,6 +207,16 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
206
207
  }
207
208
  }
208
209
 
210
+ public void setResizeMode(String resizeModeName) {
211
+ this.resizeMode = resizeModeIntFromName(resizeModeName);
212
+ }
213
+
214
+ public void setAspectRatio(float aspectRatio) {
215
+ if( vdoPlayerUIFragment != null) {
216
+ vdoPlayerUIFragment.setAspectRatio(aspectRatio);
217
+ }
218
+ }
219
+
209
220
  private void initializeMediaSession() {
210
221
  mSession = new MediaSessionCompat(activity, TAG);
211
222
  mSession.setActive(true);
@@ -384,11 +395,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
384
395
  eventEmitter.setViewId(id);
385
396
  }
386
397
 
387
- private boolean isRunningOnTv() {
388
- UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
389
- return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
390
- }
391
-
392
398
  @Override
393
399
  protected void onAttachedToWindow() {
394
400
  Log.d(TAG, "onAttachedToWindow");
@@ -469,9 +475,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
469
475
  pendingInitParams = null;
470
476
  }
471
477
 
472
- if (hasPictureInPictureSupport) {
473
- initializeMediaSession();
474
- }
478
+ initializeMediaSession();
475
479
  }
476
480
 
477
481
  @Override
@@ -528,9 +532,7 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
528
532
  // We are playing the video now. Update the media session state and the PiP
529
533
  // window will update the actions.
530
534
 
531
- if (hasPictureInPictureSupport) {
532
- updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
533
- }
535
+ updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
534
536
 
535
537
  if (playing) {
536
538
  //Request audio focus and notify other players to stop playback.
@@ -70,7 +70,6 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
70
70
  embedInfo.getString("safetyNetApiKey") : null;
71
71
  boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
72
72
  embedInfo.getBoolean("allowAdbDebugging");
73
- boolean setPictureInPictureSupport = embedInfo.hasKey("setPictureInPictureSupport") && embedInfo.getBoolean("setPictureInPictureSupport");
74
73
 
75
74
  VdoInitParams.Builder builder = new VdoInitParams.Builder();
76
75
 
@@ -119,10 +118,6 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
119
118
  }
120
119
 
121
120
  initParams = builder.build();
122
-
123
- if (setPictureInPictureSupport) {
124
- vdoPlayerView.setPictureInPictureSupport();
125
- }
126
121
 
127
122
  vdoPlayerView.load(initParams);
128
123
  }
@@ -177,4 +172,14 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
177
172
  void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView);
178
173
  }
179
174
 
175
+ @ReactProp(name = "resizeMode")
176
+ public void setResizeMode(ReactVdoPlayerView vdoPlayerView, String resizeMode) {
177
+ vdoPlayerView.setResizeMode(resizeMode);
178
+ }
179
+
180
+ @ReactProp(name = "aspectRatio")
181
+ public void setAspectRatio(ReactVdoPlayerView vdoPlayerView, float aspectRatio) {
182
+ vdoPlayerView.setAspectRatio(aspectRatio);
183
+ }
184
+
180
185
  }
@@ -12,6 +12,11 @@ import com.vdocipher.aegis.offline.DownloadOptions;
12
12
  import com.vdocipher.aegis.offline.DownloadStatus;
13
13
  import com.vdocipher.aegis.offline.VdoDownloadManager;
14
14
  import com.vdocipher.aegis.player.VdoPlayer;
15
+ import com.vdocipher.aegis.player.PlayerHost;
16
+ import android.app.UiModeManager;
17
+ import android.content.Context;
18
+ import android.content.res.Configuration;
19
+ import androidx.appcompat.app.AppCompatActivity;
15
20
 
16
21
  import java.util.List;
17
22
 
@@ -284,6 +289,19 @@ public class Utils {
284
289
  }
285
290
  }
286
291
 
292
+ public static int resizeModeIntFromName(String resizeModeName) {
293
+ switch (resizeModeName) {
294
+ case "contain":
295
+ return PlayerHost.RESIZE_MODE_FIT;
296
+ case "cover":
297
+ return PlayerHost.RESIZE_MODE_ZOOM;
298
+ case "stretch":
299
+ return PlayerHost.RESIZE_MODE_FILL;
300
+ default:
301
+ return PlayerHost.RESIZE_MODE_FIT;
302
+ }
303
+ }
304
+
287
305
  public static String digitalClockTime(int timeInMilliSeconds) {
288
306
  int totalSeconds = timeInMilliSeconds/1000;
289
307
  int hours = totalSeconds / (60 * 60);
@@ -366,4 +384,9 @@ public class Utils {
366
384
  return null;
367
385
  }
368
386
  }
387
+
388
+ public static boolean isRunningOnTv(AppCompatActivity activity) {
389
+ UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
390
+ return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
391
+ }
369
392
  }
package/index.ts CHANGED
@@ -9,19 +9,20 @@
9
9
  * }
10
10
  * })
11
11
  */
12
- import { NativeModules } from 'react-native';
13
- import VdoPlayerView from './VdoPlayerView';
14
- import VdoDownload from './downloads';
15
- import { EmbedInfo } from './type';
16
-
17
- const { VdocipherRnBridge } = NativeModules;
18
-
19
- const startVideoScreen = (params: {embedInfo: EmbedInfo}) => {
20
- VdocipherRnBridge.startVideoScreen(params);
21
- }
22
-
23
- export {
24
- startVideoScreen,
25
- VdoPlayerView,
26
- VdoDownload
27
- }
12
+ import { NativeModules } from 'react-native';
13
+ import VdoPlayerView from './VdoPlayerView';
14
+ import VdoDownload from './downloads';
15
+ import { EmbedInfo } from './type';
16
+
17
+ const { VdocipherRnBridge } = NativeModules;
18
+
19
+ const startVideoScreen = (params: {embedInfo: EmbedInfo}) => {
20
+ VdocipherRnBridge.startVideoScreen(params);
21
+ }
22
+
23
+ export {
24
+ startVideoScreen,
25
+ VdoPlayerView,
26
+ VdoDownload
27
+ }
28
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.12.3",
3
+ "version": "1.13.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
@@ -11,6 +11,11 @@ export interface EmbedInfo {
11
11
  safetyNetApiKey?: string | null;
12
12
  preferredCaptionsLanguage?: string | null;
13
13
  playerConfig?: string | null;
14
+ /**
15
+ * @deprecated
16
+ * This property is no longer required to enable PIP mode.
17
+ * Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
18
+ */
14
19
  setPictureInPictureSupport?: boolean | null;
15
20
  }
16
21
 
@@ -117,7 +122,6 @@ export const VdoPropTypes = {
117
122
  safetyNetApiKey: PropTypes.string,
118
123
  preferredCaptionsLanguage: PropTypes.string,
119
124
  playerConfig: PropTypes.string,
120
- setPictureInPictureSupport: PropTypes.bool,
121
125
  }),
122
126
  PropTypes.shape({
123
127
  offline: PropTypes.bool.isRequired,
@@ -126,9 +130,9 @@ export const VdoPropTypes = {
126
130
  safetyNetApiKey: PropTypes.string,
127
131
  preferredCaptionsLanguage: PropTypes.string,
128
132
  playerConfig: PropTypes.string,
129
- setPictureInPictureSupport: PropTypes.bool,
130
133
  })
131
134
  ]).isRequired,
135
+ style: PropTypes.object,
132
136
  showNativeControls: PropTypes.bool,
133
137
  playWhenReady: PropTypes.bool,
134
138
  playbackSpeed: PropTypes.number,