vdocipher-rn-bridge 1.20.11 → 1.21.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.
@@ -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.11"
22
- def releaseVersionCode = 43
21
+ def releaseVersionName = "1.21.0"
22
+ def releaseVersionCode = 45
23
23
 
24
24
  android {
25
25
  compileSdkVersion 35
@@ -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.28.6'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.28.8'
90
90
  }
@@ -0,0 +1,7 @@
1
+ package com.vdocipher.rnbridge;
2
+
3
+ public interface Constants {
4
+ String VDO_SHARED_PREFS = "com.vdocipher.rnbridge.sharedprefs";
5
+ String VDO_PLAYBACK_MODE = "vdoPlaybackMode";
6
+
7
+ }
@@ -43,6 +43,15 @@ import com.vdocipher.aegis.ui.view.FullScreenActionListener;
43
43
  import com.vdocipher.aegis.media.PlayerOption;
44
44
  import com.vdocipher.aegis.player.VdoTimeLine;
45
45
 
46
+ import com.vdocipher.aegis.player.VdoPlayerSetting;
47
+ import static com.vdocipher.rnbridge.Constants.VDO_SHARED_PREFS;
48
+ import static com.vdocipher.rnbridge.Constants.VDO_PLAYBACK_MODE;
49
+
50
+ import android.content.Context;
51
+ import android.content.SharedPreferences;
52
+
53
+ import java.util.UUID;
54
+
46
55
 
47
56
  public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEventListener {
48
57
  private static final String TAG = "ReactVdoPlayerUIView";
@@ -74,6 +83,9 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
74
83
 
75
84
  private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
76
85
 
86
+ String playbackMode = "default";
87
+ SharedPreferences sharedPreferences;
88
+
77
89
  public ReactVdoPlayerUIView(ThemedReactContext context) {
78
90
  super(context);
79
91
  themedReactContext = context;
@@ -83,16 +95,18 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
83
95
  setGravity(Gravity.CENTER);
84
96
  setBackgroundColor(Color.BLACK);
85
97
 
98
+ sharedPreferences = themedReactContext.getSharedPreferences(VDO_SHARED_PREFS, Context.MODE_PRIVATE);
86
99
 
87
- FrameLayout frameLayout = LayoutInflater.from(context).inflate(R.layout.vdo_frame_layout, null).findViewById(R.id.vdo_player_frame_layout);
88
- frameLayoutId = frameLayout.getId();
89
-
100
+ FrameLayout frameLayout = new FrameLayout(context);
101
+ frameLayoutId = UUID.randomUUID().toString().hashCode();
102
+ frameLayout.setId(frameLayoutId);
90
103
  addView(frameLayout);
91
104
 
92
105
  frameLayout.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
93
106
  @Override
94
107
  public void onViewAttachedToWindow(View v) {
95
- if (vdoPlayerUIFragment == null) {
108
+ Log.d(TAG, "onViewAttachedToWindow");
109
+ if (vdoPlayerUIFragment == null) {
96
110
  vdoPlayerUIFragment = new VdoPlayerUIFragment();
97
111
  Bundle bundle = new Bundle();
98
112
  bundle.putBoolean("showControls", true);
@@ -100,10 +114,22 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
100
114
  fragmentManager = activity.getSupportFragmentManager();
101
115
  initializePlayer();
102
116
  }
117
+
118
+ playbackMode = sharedPreferences.getString(VDO_PLAYBACK_MODE, null);
119
+ if (playWhenReady && vdoPlayer != null && VdoPlayerSetting.VdoPlaybackMode.DEFAULT == vdoPlaybackModeFromName(playbackMode)) {
120
+ if (vdoPlayer != null) {
121
+ vdoPlayer.setPlayWhenReady(true);
122
+ }
123
+ }
103
124
  }
104
125
 
105
126
  @Override
106
127
  public void onViewDetachedFromWindow(View v) {
128
+ Log.d(TAG, "onViewDetachedFromWindow");
129
+ playbackMode = sharedPreferences.getString(VDO_PLAYBACK_MODE, null);
130
+ if (vdoPlayer != null && VdoPlayerSetting.VdoPlaybackMode.DEFAULT == vdoPlaybackModeFromName(playbackMode)) {
131
+ vdoPlayer.setPlayWhenReady(false);
132
+ }
107
133
  }
108
134
  });
109
135
 
@@ -115,7 +141,6 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
115
141
 
116
142
  setPictureInPictureSupport();
117
143
  setFullscreenActionListener();
118
-
119
144
  }
120
145
 
121
146
  private void initializePlayer() {
@@ -134,7 +159,7 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
134
159
  vdoPlayerUIFragment.setResizeMode(this.resizeMode);
135
160
  vdoPlayerUIFragment.setFullscreenActionListener(fullscreenToggleListener);
136
161
  } catch(Exception e) {
137
- e.printStackTrace();
162
+ Log.e(TAG, Log.getStackTraceString(e));
138
163
  }
139
164
  }
140
165
  }, 200);
@@ -150,7 +175,9 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
150
175
  if (pictureModeChangedInfoConsumer != null) {
151
176
  activity.removeOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
152
177
  }
153
- if (vdoPlayer != null) {
178
+
179
+ playbackMode = sharedPreferences.getString(VDO_PLAYBACK_MODE, null);
180
+ if (vdoPlayer != null && VdoPlayerSetting.VdoPlaybackMode.DEFAULT == vdoPlaybackModeFromName(playbackMode)) {
154
181
  vdoPlayer.stop();
155
182
  }
156
183
  if (fragmentManager != null && !fragmentManager.isDestroyed()) {
@@ -160,7 +187,7 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
160
187
  fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
161
188
  }
162
189
  } catch(IllegalStateException e) {
163
- e.printStackTrace();
190
+ Log.e(TAG, Log.getStackTraceString(e));
164
191
  }
165
192
  }
166
193
  vdoPlayerUIFragment = null;
@@ -363,19 +390,11 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
363
390
  protected void onAttachedToWindow() {
364
391
  Log.d(TAG, "onAttachedToWindow");
365
392
  super.onAttachedToWindow();
366
- if (playWhenReady) {
367
- if (vdoPlayer != null) {
368
- vdoPlayer.setPlayWhenReady(true);
369
- }
370
- }
371
393
  }
372
394
 
373
395
  @Override
374
396
  protected void onDetachedFromWindow() {
375
397
  Log.d(TAG, "onDetachedFromWindow");
376
- if (vdoPlayer != null) {
377
- vdoPlayer.setPlayWhenReady(false);
378
- }
379
398
  super.onDetachedFromWindow();
380
399
  }
381
400
 
@@ -545,14 +564,13 @@ public class ReactVdoPlayerUIView extends LinearLayout implements LifecycleEvent
545
564
  Log.i(TAG, "onMediaEnded");
546
565
  eventEmitter.mediaEnded(vdoInitParams);
547
566
  }
548
-
549
567
  @Override
550
- public void onMetaDataLoaded(PlayerOption playerOption) {
568
+ public void onMetaDataLoaded(PlayerOption playerOption) {
551
569
  Log.i(TAG, "onMetaDataLoaded");
552
570
  }
553
571
 
554
572
  @Override
555
- public void onTimelineChanged(VdoTimeLine a,int b) {
573
+ public void onTimelineChanged(VdoTimeLine a, int b) {
556
574
  Log.i(TAG, "onTimelineChanged");
557
575
  }
558
576
  };
@@ -97,6 +97,8 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
97
97
  String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
98
98
  String token = embedInfo.hasKey("token") ? embedInfo.getString("token") : null;
99
99
  String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
100
+ String mediaUrl = embedInfo.hasKey("mediaUrl") ? embedInfo.getString("mediaUrl") : null;
101
+ String licenseUrl = embedInfo.hasKey("licenseUrl") ? embedInfo.getString("licenseUrl") : null;
100
102
  boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
101
103
  && embedInfo.getBoolean("forceLowestBitrate");
102
104
  boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
@@ -117,7 +119,9 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
117
119
  } else if (otp != null && playbackInfo != null) {
118
120
  builder.setOtp(otp)
119
121
  .setPlaybackInfo(playbackInfo);
120
- }
122
+ } else if (mediaUrl != null) {
123
+ builder.configureMediaSource(mediaUrl, licenseUrl);
124
+ }
121
125
 
122
126
  builder.setAllowAdbDebugging(allowAdbDebugging)
123
127
  .setForceLowestBitrate(forceLowestBitrate)
@@ -50,6 +50,12 @@ import android.widget.LinearLayout;
50
50
  import com.vdocipher.aegis.media.PlayerOption;
51
51
  import com.vdocipher.aegis.player.VdoTimeLine;
52
52
 
53
+ import java.util.UUID;
54
+ import com.vdocipher.aegis.player.VdoPlayerSetting;
55
+ import static com.vdocipher.rnbridge.Constants.VDO_SHARED_PREFS;
56
+ import static com.vdocipher.rnbridge.Constants.VDO_PLAYBACK_MODE;
57
+ import android.content.SharedPreferences;
58
+
53
59
  public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventListener {
54
60
  private static final String TAG = "ReactVdoPlayerView";
55
61
 
@@ -86,11 +92,18 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
86
92
 
87
93
  private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
88
94
 
95
+ String playbackMode = "default";
96
+ SharedPreferences sharedPreferences;
97
+
89
98
  public ReactVdoPlayerView(ThemedReactContext context) {
90
99
  super(context);
91
100
  context.addLifecycleEventListener(this);
92
101
  themedReactContext = context;
93
102
  activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
103
+
104
+ sharedPreferences = themedReactContext.getSharedPreferences(VDO_SHARED_PREFS, Context.MODE_PRIVATE);
105
+
106
+
94
107
  // Get a handler that can be used to post to the main thread
95
108
  mainHandler = new Handler(Looper.getMainLooper());
96
109
  setKeepScreenOn(true);
@@ -98,13 +111,15 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
98
111
  setGravity(Gravity.CENTER);
99
112
  setBackgroundColor(Color.BLACK);
100
113
 
101
- FrameLayout frameLayout = LayoutInflater.from(context).inflate(R.layout.vdo_frame_layout, null).findViewById(R.id.vdo_player_frame_layout);
102
- frameLayoutId = frameLayout.getId();
114
+ FrameLayout frameLayout = new FrameLayout(context);
115
+ frameLayoutId = UUID.randomUUID().toString().hashCode();
116
+ frameLayout.setId(frameLayoutId);
103
117
  addView(frameLayout);
104
118
 
105
119
  frameLayout.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
106
120
  @Override
107
121
  public void onViewAttachedToWindow(View v) {
122
+ Log.d(TAG, "onViewAttachedToWindow");
108
123
  if (vdoPlayerUIFragment == null) {
109
124
  vdoPlayerUIFragment = new VdoPlayerUIFragment();
110
125
  Bundle bundle = new Bundle();
@@ -113,10 +128,22 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
113
128
  fragmentManager = activity.getSupportFragmentManager();
114
129
  initializePlayer();
115
130
  }
131
+
132
+ playbackMode = sharedPreferences.getString(VDO_PLAYBACK_MODE, null);
133
+ if (playWhenReady && vdoPlayer != null && VdoPlayerSetting.VdoPlaybackMode.DEFAULT == vdoPlaybackModeFromName(playbackMode)) {
134
+ if (vdoPlayer != null) {
135
+ vdoPlayer.setPlayWhenReady(true);
136
+ }
137
+ }
116
138
  }
117
139
 
118
140
  @Override
119
141
  public void onViewDetachedFromWindow(View v) {
142
+ Log.d(TAG, "onViewDetachedFromWindow");
143
+ playbackMode = sharedPreferences.getString(VDO_PLAYBACK_MODE, null);
144
+ if (vdoPlayer != null && VdoPlayerSetting.VdoPlaybackMode.DEFAULT == vdoPlaybackModeFromName(playbackMode)) {
145
+ vdoPlayer.setPlayWhenReady(false);
146
+ }
120
147
  }
121
148
  });
122
149
 
@@ -139,7 +166,7 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
139
166
  vdoPlayerUIFragment.initialize(initializationListener);
140
167
  vdoPlayerUIFragment.setResizeMode(this.resizeMode);
141
168
  } catch(IllegalStateException e) {
142
- e.printStackTrace();
169
+ Log.e(TAG, Log.getStackTraceString(e));
143
170
  }
144
171
  }
145
172
  }, 200);
@@ -154,7 +181,9 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
154
181
  if (pictureModeChangedInfoConsumer != null) {
155
182
  activity.removeOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
156
183
  }
157
- if (vdoPlayer != null) {
184
+
185
+ playbackMode = sharedPreferences.getString(VDO_PLAYBACK_MODE, null);
186
+ if (vdoPlayer != null && VdoPlayerSetting.VdoPlaybackMode.DEFAULT == vdoPlaybackModeFromName(playbackMode)) {
158
187
  vdoPlayer.stop();
159
188
  }
160
189
  if (fragmentManager != null && !fragmentManager.isDestroyed()) {
@@ -164,7 +193,7 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
164
193
  fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
165
194
  }
166
195
  } catch(IllegalStateException e) {
167
- e.printStackTrace();
196
+ Log.e(TAG, Log.getStackTraceString(e));
168
197
  }
169
198
  }
170
199
  vdoPlayerUIFragment = null;
@@ -464,19 +493,11 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
464
493
  protected void onAttachedToWindow() {
465
494
  Log.d(TAG, "onAttachedToWindow");
466
495
  super.onAttachedToWindow();
467
- if (playWhenReady) {
468
- if (vdoPlayer != null) {
469
- vdoPlayer.setPlayWhenReady(true);
470
- }
471
- }
472
496
  }
473
497
 
474
498
  @Override
475
499
  protected void onDetachedFromWindow() {
476
500
  Log.d(TAG, "onDetachedFromWindow");
477
- if (vdoPlayer != null) {
478
- vdoPlayer.setPlayWhenReady(false);
479
- }
480
501
  if (audioFocusManager != null) {
481
502
  audioFocusManager.abandonAudioFocus();
482
503
  }
@@ -524,34 +545,34 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
524
545
  // InitializationListener impl
525
546
 
526
547
  PlayerHost.InitializationListener initializationListener = new PlayerHost.InitializationListener() {
527
- @Override
528
- public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
529
- Log.d(TAG, "init success");
530
- vdoPlayer = player;
531
- availableTracks = vdoPlayer.getAvailableTracks();
532
- selectedTracks = vdoPlayer.getSelectedTracks();
533
- vdoPlayer.addPlaybackEventListener(playbackListener);
534
- eventEmitter.initSuccess(restored);
535
-
536
- // load pending params
537
- if (pendingInitParams != null) {
538
- Log.d(TAG, "load pending params");
539
- load(pendingInitParams);
540
- pendingInitParams = null;
541
- }
548
+ @Override
549
+ public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
550
+ Log.d(TAG, "init success");
551
+ vdoPlayer = player;
552
+ availableTracks = vdoPlayer.getAvailableTracks();
553
+ selectedTracks = vdoPlayer.getSelectedTracks();
554
+ vdoPlayer.addPlaybackEventListener(playbackListener);
555
+ eventEmitter.initSuccess(restored);
542
556
 
557
+ // load pending params
558
+ if (pendingInitParams != null) {
559
+ Log.d(TAG, "load pending params");
560
+ load(pendingInitParams);
561
+ pendingInitParams = null;
543
562
  }
544
563
 
545
- @Override
546
- public void onInitializationFailure(PlayerHost playerHost, ErrorDescription errorDescription) {
547
- Log.e(TAG, "init failure: " + errorDescription.toString());
548
- eventEmitter.initFailure(errorDescription);
549
- }
564
+ }
550
565
 
551
- @Override
552
- public void onDeInitializationSuccess() {
566
+ @Override
567
+ public void onInitializationFailure(PlayerHost playerHost, ErrorDescription errorDescription) {
568
+ Log.e(TAG, "init failure: " + errorDescription.toString());
569
+ eventEmitter.initFailure(errorDescription);
570
+ }
553
571
 
554
- }
572
+ @Override
573
+ public void onDeInitializationSuccess() {
574
+
575
+ }
555
576
 
556
577
  };
557
578
 
@@ -674,13 +695,13 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
674
695
  }
675
696
 
676
697
  @Override
677
- public void onMetaDataLoaded(PlayerOption playerOption) {
678
- Log.i(TAG, "onMetaDataLoaded");
679
- }
698
+ public void onMetaDataLoaded(PlayerOption playerOption) {
699
+ Log.i(TAG, "onMetaDataLoaded");
700
+ }
680
701
 
681
- @Override
682
- public void onTimelineChanged(VdoTimeLine a,int b) {
683
- Log.i(TAG, "onTimelineChanged");
684
- }
702
+ @Override
703
+ public void onTimelineChanged(VdoTimeLine a,int b) {
704
+ Log.i(TAG, "onTimelineChanged");
705
+ }
685
706
  };
686
707
  }
@@ -98,6 +98,8 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
98
98
  String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
99
99
  String token = embedInfo.hasKey("token") ? embedInfo.getString("token") : null;
100
100
  String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
101
+ String mediaUrl = embedInfo.hasKey("mediaUrl") ? embedInfo.getString("mediaUrl") : null;
102
+ String licenseUrl = embedInfo.hasKey("licenseUrl") ? embedInfo.getString("licenseUrl") : null;
101
103
  boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
102
104
  && embedInfo.getBoolean("forceLowestBitrate");
103
105
  boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
@@ -112,7 +114,9 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
112
114
  } else if (otp != null && playbackInfo != null) {
113
115
  builder.setOtp(otp)
114
116
  .setPlaybackInfo(playbackInfo);
115
- }
117
+ } else if (mediaUrl != null) {
118
+ builder.configureMediaSource(mediaUrl, licenseUrl);
119
+ }
116
120
 
117
121
  builder.setAllowAdbDebugging(allowAdbDebugging)
118
122
  .setForceLowestBitrate(forceLowestBitrate)
@@ -17,6 +17,7 @@ import android.app.UiModeManager;
17
17
  import android.content.Context;
18
18
  import android.content.res.Configuration;
19
19
  import androidx.appcompat.app.AppCompatActivity;
20
+ import com.vdocipher.aegis.player.VdoPlayerSetting.VdoPlaybackMode;
20
21
 
21
22
  import java.util.List;
22
23
 
@@ -302,6 +303,21 @@ public class Utils {
302
303
  }
303
304
  }
304
305
 
306
+ public static VdoPlaybackMode vdoPlaybackModeFromName(String playbackMode) {
307
+ if (playbackMode == null)
308
+ {
309
+ return VdoPlaybackMode.DEFAULT;
310
+ }
311
+ switch (playbackMode) {
312
+ case "continue_playback_on_back_press":
313
+ return VdoPlaybackMode.CONTINUE_PLAYBACK_ON_BACK_PRESS;
314
+ case "continue_playback_on_app_exit":
315
+ return VdoPlaybackMode.CONTINUE_PLAYBACK_ON_APP_EXIT;
316
+ default:
317
+ return VdoPlaybackMode.DEFAULT;
318
+ }
319
+ }
320
+
305
321
  public static String digitalClockTime(int timeInMilliSeconds) {
306
322
  int totalSeconds = timeInMilliSeconds/1000;
307
323
  int hours = totalSeconds / (60 * 60);
@@ -109,7 +109,10 @@ class VdoEventEmitter {
109
109
  }
110
110
 
111
111
  void loaded(VdoInitParams vdoInitParams, MediaInfo mediaInfo) {
112
- WritableMap mInfo = makeMediaInfoMap(mediaInfo);
112
+ WritableMap mInfo = Arguments.createMap();
113
+
114
+ if (mediaInfo != null)
115
+ mInfo = makeMediaInfoMap(mediaInfo);
113
116
 
114
117
  WritableMap event = Arguments.createMap();
115
118
  event.putMap(EVENT_PROP_MEDIA_INFO, mInfo);
@@ -198,7 +198,7 @@ public class VdoPlayerActivity extends AppCompatActivity implements PlayerHost.I
198
198
  }
199
199
 
200
200
  @Override
201
- public void onMetaDataLoaded(PlayerOption playerOption) {
201
+ public void onMetaDataLoaded(PlayerOption playerOption) {
202
202
  Log.i(TAG, "onMetaDataLoaded");
203
203
  }
204
204
 
@@ -572,7 +572,7 @@ public class VdoPlayerControlView extends FrameLayout {
572
572
  public void onTracksChanged(Track[] availableTracks, Track[] selectedTracks) {}
573
573
 
574
574
  @Override
575
- public void onMetaDataLoaded(PlayerOption playerOption) {
575
+ public void onMetaDataLoaded(PlayerOption playerOption) {
576
576
  Log.i(TAG, "onMetaDataLoaded");
577
577
  }
578
578
 
@@ -0,0 +1,56 @@
1
+ package com.vdocipher.rnbridge;
2
+
3
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+ import com.facebook.react.bridge.ReactMethod;
6
+ import com.facebook.react.bridge.ReadableMap;
7
+ import com.facebook.react.bridge.Callback;
8
+ import android.util.Log;
9
+ import com.facebook.react.uimanager.annotations.ReactProp;
10
+ import com.vdocipher.aegis.player.VdoPlayerSetting;
11
+ import static com.vdocipher.rnbridge.Utils.*;
12
+ import static com.vdocipher.rnbridge.Constants.VDO_SHARED_PREFS;
13
+ import static com.vdocipher.rnbridge.Constants.VDO_PLAYBACK_MODE;
14
+
15
+ import android.content.Context;
16
+ import android.content.SharedPreferences;
17
+
18
+ public class VdoPlayerSettingsModule extends ReactContextBaseJavaModule {
19
+ private static final String TAG = "VdoPlayerSettingsModule";
20
+ private ReactApplicationContext context;
21
+
22
+ @Override
23
+ public String getName() {
24
+ return "VdoPlayerSettings";
25
+ }
26
+
27
+ public VdoPlayerSettingsModule(ReactApplicationContext reactContext) {
28
+ super(reactContext);
29
+ context = reactContext;
30
+ }
31
+
32
+ @ReactMethod()
33
+ public void applySettings(ReadableMap playerSettings) {
34
+
35
+ String playbackMode = playerSettings.hasKey("vdoPlaybackModeAndroid") ?
36
+ playerSettings.getString("vdoPlaybackModeAndroid") : "default";
37
+ int bufferingGoalMs = playerSettings.hasKey("bufferingGoalMs") ?
38
+ playerSettings.getInt("bufferingGoalMs") : 0;
39
+
40
+ VdoPlayerSetting.VdoPlaybackMode vdoPlaybackMode = vdoPlaybackModeFromName(playbackMode);
41
+
42
+ VdoPlayerSetting.Builder settingsBuilder = new VdoPlayerSetting.Builder()
43
+ .setPlaybackBehavior(vdoPlaybackMode);
44
+
45
+ if (bufferingGoalMs > 0) {
46
+ settingsBuilder.setMaxBufferMs(bufferingGoalMs);
47
+ }
48
+
49
+ settingsBuilder.build()
50
+ .applySettings(context);
51
+
52
+ SharedPreferences sharedPreferences = context.getSharedPreferences(VDO_SHARED_PREFS, Context.MODE_PRIVATE);
53
+ sharedPreferences.edit().putString(VDO_PLAYBACK_MODE, playbackMode).apply();
54
+ }
55
+
56
+ }
@@ -0,0 +1,61 @@
1
+ package com.vdocipher.rnbridge;
2
+
3
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+ import com.facebook.react.bridge.ReactMethod;
6
+ import com.facebook.react.bridge.ReadableMap;
7
+ import com.facebook.react.bridge.Callback;
8
+ import android.util.Log;
9
+ import com.facebook.react.uimanager.annotations.ReactProp;
10
+ import com.vdocipher.aegis.player.cache.Config;
11
+ import com.vdocipher.aegis.player.cache.VdoPreCacheManager;
12
+ import android.content.Context;
13
+ import android.content.SharedPreferences;
14
+
15
+ public class VdoPreCacheManagerModule extends ReactContextBaseJavaModule {
16
+ private static final String TAG = "VdoPlayerSettingsModule";
17
+ private ReactApplicationContext context;
18
+
19
+ @Override
20
+ public String getName() {
21
+ return "VdoPreCacheManager";
22
+ }
23
+
24
+ public VdoPreCacheManagerModule(ReactApplicationContext reactContext) {
25
+ super(reactContext);
26
+ context = reactContext;
27
+ }
28
+
29
+ @ReactMethod()
30
+ public void cacheVideo(ReadableMap preCacheSettings) {
31
+
32
+ String mediaId = preCacheSettings.hasKey("mediaId") ?
33
+ preCacheSettings.getString("mediaId") : null;
34
+
35
+ if (mediaId == null) {
36
+ return;
37
+ }
38
+
39
+ String customPlayerId = preCacheSettings.hasKey("customPlayerId") ?
40
+ preCacheSettings.getString("customPlayerId") : null;
41
+ String languageCode = preCacheSettings.hasKey("languageCode") ?
42
+ preCacheSettings.getString("languageCode") : null;
43
+ int cacheSize = preCacheSettings.hasKey("cacheSize") ?
44
+ preCacheSettings.getInt("cacheSize") : -1;
45
+
46
+ Config config = new Config();
47
+ if (cacheSize != -1) {
48
+ config.setCacheSize(cacheSize);
49
+ }
50
+ VdoPreCacheManager vdoPreCacheManager = VdoPreCacheManager.getInstance(context, config);
51
+ vdoPreCacheManager.cacheVideo(mediaId, customPlayerId, languageCode);
52
+
53
+ }
54
+
55
+ @ReactMethod()
56
+ public void clearCache() {
57
+ VdoPreCacheManager videoPreCache = VdoPreCacheManager.getInstance(context);
58
+ videoPreCache.clearCache();
59
+ }
60
+
61
+ }
@@ -73,6 +73,8 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
73
73
  String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
74
74
  String token = embedInfo.hasKey("token") ? embedInfo.getString("token") : null;
75
75
  String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
76
+ String mediaUrl = embedInfo.hasKey("mediaUrl") ? embedInfo.getString("mediaUrl") : null;
77
+ String licenseUrl = embedInfo.hasKey("licenseUrl") ? embedInfo.getString("licenseUrl") : null;
76
78
  boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
77
79
  && embedInfo.getBoolean("forceLowestBitrate");
78
80
  boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
@@ -93,6 +95,8 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
93
95
  } else if (otp != null && playbackInfo != null) {
94
96
  builder.setOtp(otp)
95
97
  .setPlaybackInfo(playbackInfo);
98
+ } else if (mediaUrl != null) {
99
+ builder.configureMediaSource(mediaUrl, licenseUrl);
96
100
  }
97
101
 
98
102
  builder.setAllowAdbDebugging(allowAdbDebugging)
@@ -26,7 +26,9 @@ public class VdocipherRnBridgePackage implements ReactPackage {
26
26
  new VdocipherRnBridgeModule(reactContext),
27
27
  new VdoDownloadModule(reactContext),
28
28
  new TrackSelectionModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager),
29
- new VdoPlayerModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager));
29
+ new VdoPlayerModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager),
30
+ new VdoPlayerSettingsModule(reactContext),
31
+ new VdoPreCacheManagerModule(reactContext));
30
32
  }
31
33
 
32
34
  // Deprecated from RN 0.47
@@ -0,0 +1,18 @@
1
+ //
2
+ // VdoPlayerSettings.swift
3
+ //
4
+ //
5
+
6
+ import UIKit
7
+ import VdoFramework
8
+
9
+ @objc(VdoPlayerSettings)
10
+ class VdoPlayerSettings: NSObject {
11
+
12
+ @objc func applySettings(_ playerSettings: [String: Any]) {
13
+ guard let vdoPlaybackMode = playerSettings["vdoPlaybackModeiOS"] as? Bool else {
14
+ return
15
+ }
16
+ VdoCipher.getVdoPlayerViewController().setBackgroundMode(vdoPlaybackMode)
17
+ }
18
+ }
@@ -0,0 +1,19 @@
1
+ //
2
+ // VdoPreCacheManager.swift
3
+ //
4
+ //
5
+
6
+ import UIKit
7
+ import VdoFramework
8
+
9
+ @objc(VdoPreCacheManager)
10
+ class VdoPreCacheManager: NSObject {
11
+
12
+ @objc func cacheVideo(_ playerSettings: [String: Any]) {
13
+ print("cacheVideo method not supported in iOS")
14
+ }
15
+
16
+ @objc func clearCache(_ playerSettings: [String: Any]) {
17
+ print("clearCache method not supported in iOS")
18
+ }
19
+ }
@@ -112,4 +112,15 @@ RCT_EXTERN_METHOD(isAdaptive: (RCTResponseSenderBlock) callback)
112
112
 
113
113
  @end
114
114
 
115
+ @interface RCT_EXTERN_MODULE(VdoPlayerSettings, NSObject)
115
116
 
117
+ RCT_EXTERN_METHOD(applySettings: (NSDictionary *) playerSettings)
118
+
119
+ @end
120
+
121
+ @interface RCT_EXTERN_MODULE(VdoPreCacheManager, NSObject)
122
+
123
+ RCT_EXTERN_METHOD(cacheVideo: (NSDictionary *) preCacheSettings)
124
+ RCT_EXTERN_METHOD(clearCache)
125
+
126
+ @end
@@ -5,7 +5,7 @@ import VdoFramework
5
5
  @objc(VdocipherRnBridge)
6
6
  class VdocipherRnBridge: RCTViewManager {
7
7
 
8
- static let vdocipherRnBridgeVersionString = "1.20.11"
8
+ static let vdocipherRnBridgeVersionString = "1.21.0"
9
9
 
10
10
  @objc override static func requiresMainQueueSetup() -> Bool {
11
11
  return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.20.11",
3
+ "version": "1.21.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": {
@@ -12,7 +12,7 @@
12
12
  "author": "",
13
13
  "license": "",
14
14
  "peerDependencies": {
15
- "react-native": "0.68 - 0.75"
15
+ "react-native": "0.68 - 0.76"
16
16
  },
17
17
  "dependencies": {
18
18
  "deprecated-react-native-prop-types": "^2.3.0",
package/type.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
 
3
- export type EmbedInfo = OtpEmbedInfo | TokenEmbedInfo;
3
+ export type EmbedInfo = OtpEmbedInfo | TokenEmbedInfo |ExternalEmbedInfo;
4
4
 
5
5
  export interface OtpEmbedInfo {
6
6
  otp: string;
@@ -17,10 +17,6 @@ export interface OtpEmbedInfo {
17
17
  * Not supported in iOS
18
18
  */
19
19
  maxVideoBitrateKbps?: number | null;
20
- /**
21
- * Not supported in iOS
22
- */
23
- bufferingGoalMs?: number | null;
24
20
  enableAutoResume?: boolean | null;
25
21
  preferredCaptionsLanguage?: string | null;
26
22
  /**
@@ -36,6 +32,10 @@ export interface OtpEmbedInfo {
36
32
  */
37
33
  setPictureInPictureSupport?: boolean | null;
38
34
  resumeTimeMs?: number | null;
35
+ /**
36
+ * Not supported in iOS
37
+ */
38
+ allowAdbDebugging?: boolean;
39
39
  }
40
40
 
41
41
  export interface TokenEmbedInfo {
@@ -53,10 +53,6 @@ export interface TokenEmbedInfo {
53
53
  * Not supported in iOS
54
54
  */
55
55
  maxVideoBitrateKbps?: number | null;
56
- /**
57
- * Not supported in iOS
58
- */
59
- bufferingGoalMs?: number | null;
60
56
  enableAutoResume?: boolean | null;
61
57
  preferredCaptionsLanguage?: string | null;
62
58
  /**
@@ -71,6 +67,27 @@ export interface TokenEmbedInfo {
71
67
  * Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
72
68
  */
73
69
  setPictureInPictureSupport?: boolean | null;
70
+ resumeTimeMs?: number | null;
71
+ /**
72
+ * Not supported in iOS
73
+ */
74
+ allowAdbDebugging?: boolean;
75
+ }
76
+
77
+ /**
78
+ * Not supported in iOS
79
+ */
80
+ export interface ExternalEmbedInfo {
81
+ mediaUrl: string;
82
+ licenseUrl?: string | null;
83
+ forceLowestBitrate?: boolean | null;
84
+ forceHighestSupportedBitrate?: boolean | null;
85
+ maxVideoBitrateKbps?: number | null;
86
+ enableAutoResume?: boolean | null;
87
+ preferredCaptionsLanguage?: string | null;
88
+ customPlayerId?: string | null;
89
+ resumeTimeMs?: number | null;
90
+ allowAdbDebugging?: boolean;
74
91
  }
75
92
 
76
93
  export type OfflineEmbedInfo = {
@@ -90,6 +107,10 @@ export type OfflineEmbedInfo = {
90
107
  */
91
108
  setPictureInPictureSupport?: boolean | null;
92
109
  resumeTimeMs?: number | null;
110
+ /**
111
+ * Not supported in iOS
112
+ */
113
+ allowAdbDebugging?: boolean;
93
114
  }
94
115
 
95
116
  export type OfflineOptionParams = {
@@ -162,6 +183,19 @@ export interface PlaybackProperty {
162
183
  totalCovered: number;
163
184
  }
164
185
 
186
+ export interface PlayerSettings {
187
+ vdoPlaybackModeAndroid?: string;
188
+ vdoPlaybackModeiOS?: boolean;
189
+ bufferingGoalMs?: number;
190
+ }
191
+
192
+ export interface PreCacheSettings {
193
+ mediaId: string;
194
+ customPlayerId?: string;
195
+ languageCode?: string;
196
+ cacheSize?: number;
197
+ }
198
+
165
199
  export const VdoPropTypes = {
166
200
  /* Native only */
167
201
  onInitSuccess: PropTypes.func,
@@ -192,12 +226,12 @@ export const VdoPropTypes = {
192
226
  forceLowestBitrate: PropTypes.bool,
193
227
  forceHighestSupportedBitrate: PropTypes.bool,
194
228
  maxVideoBitrateKbps: PropTypes.number,
195
- bufferingGoalMs: PropTypes.number,
196
229
  enableAutoResume: PropTypes.bool,
197
230
  preferredCaptionsLanguage: PropTypes.string,
198
231
  playerConfig: PropTypes.string,
199
232
  customPlayerId: PropTypes.string,
200
233
  resumeTimeMs: PropTypes.number,
234
+ allowAdbDebugging: PropTypes.bool,
201
235
  }),
202
236
  PropTypes.shape({
203
237
  token: PropTypes.string.isRequired,
@@ -205,11 +239,25 @@ export const VdoPropTypes = {
205
239
  forceLowestBitrate: PropTypes.bool,
206
240
  forceHighestSupportedBitrate: PropTypes.bool,
207
241
  maxVideoBitrateKbps: PropTypes.number,
208
- bufferingGoalMs: PropTypes.number,
209
242
  enableAutoResume: PropTypes.bool,
210
243
  preferredCaptionsLanguage: PropTypes.string,
211
244
  playerConfig: PropTypes.string,
212
245
  customPlayerId: PropTypes.string,
246
+ resumeTimeMs: PropTypes.number,
247
+ allowAdbDebugging: PropTypes.bool,
248
+ }),
249
+ PropTypes.shape({
250
+ mediaUrl: PropTypes.string.isRequired,
251
+ licenseUrl: PropTypes.string,
252
+ forceLowestBitrate: PropTypes.bool,
253
+ forceHighestSupportedBitrate: PropTypes.bool,
254
+ maxVideoBitrateKbps: PropTypes.number,
255
+ enableAutoResume: PropTypes.bool,
256
+ preferredCaptionsLanguage: PropTypes.string,
257
+ playerConfig: PropTypes.string,
258
+ customPlayerId: PropTypes.string,
259
+ resumeTimeMs: PropTypes.number,
260
+ allowAdbDebugging: PropTypes.bool,
213
261
  }),
214
262
  PropTypes.shape({
215
263
  offline: PropTypes.bool.isRequired,
@@ -218,6 +266,7 @@ export const VdoPropTypes = {
218
266
  preferredCaptionsLanguage: PropTypes.string,
219
267
  playerConfig: PropTypes.string,
220
268
  resumeTimeMs: PropTypes.number,
269
+ allowAdbDebugging: PropTypes.bool,
221
270
  })
222
271
  ]).isRequired,
223
272
  style: PropTypes.shape({
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
- android:id="@+id/vdo_player_frame_layout"
4
- android:layout_width="match_parent"
5
- android:layout_height="wrap_content"
6
- android:keepScreenOn="true"/>