vdocipher-rn-bridge 1.10.2 → 1.11.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,8 @@
1
1
  ## Changelog
2
+
3
+ ### 1.11.0
4
+ * Updated VdoCipher android sdk dependency to 1.19.0
5
+
2
6
  ### 1.10.2
3
7
  * Updated VdoCipher android sdk dependency to 1.18.2
4
8
  * Updated compileSdkVersion to 33 and targetSdkVersion to 32
@@ -139,7 +139,7 @@ class VdoPlayerSupportView extends Component {
139
139
 
140
140
  _onPictureInPictureModeChanged = (event) => {
141
141
  if (this.props.onPictureInPictureModeChanged) {
142
- this.props.onPictureInPictureModeChanged(event);
142
+ this.props.onPictureInPictureModeChanged(event.nativeEvent);
143
143
  }
144
144
  }
145
145
 
@@ -162,7 +162,7 @@ class VdoPlayerSupportView extends Component {
162
162
  onVdoEnterFullscreen={this._onEnterFullscreen}
163
163
  onVdoExitFullscreen={this._onExitFullscreen}
164
164
  onIsInitialPortrait={this._onIsInitialPortrait}
165
- onPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
165
+ onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
166
166
  {...this.props}
167
167
  />
168
168
  )
@@ -190,6 +190,7 @@ VdoPlayerSupportView.propTypes = {
190
190
  onVdoEnterFullscreen: PropTypes.func,
191
191
  onVdoExitFullscreen: PropTypes.func,
192
192
  onIsInitialPortrait: PropTypes.func,
193
+ onVdoPictureInPictureModeChanged: PropTypes.func,
193
194
 
194
195
  /* Wrapper component public api */
195
196
  embedInfo: PropTypes.object,
package/VdoPlayerView.js CHANGED
@@ -163,12 +163,6 @@
163
163
  });
164
164
  }
165
165
 
166
- _onPictureInPictureModeChanged = (event) => {
167
- if (this.props.onPictureInPictureModeChanged) {
168
- this.props.onPictureInPictureModeChanged(event);
169
- }
170
- }
171
-
172
166
  render() {
173
167
  return (
174
168
  <Fragment>
@@ -212,7 +206,6 @@
212
206
  onVdoEnterFullscreen={this._onEnterFullscreen}
213
207
  onVdoExitFullscreen={this._onExitFullscreen}
214
208
  onIsInitialPortrait={this._onIsInitialPortrait}
215
- onPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
216
209
  {...this.props}
217
210
  />
218
211
  )
@@ -264,7 +257,6 @@
264
257
  onPlaybackProperties: PropTypes.func,
265
258
  onEnterFullscreen: PropTypes.func,
266
259
  onExitFullscreen: PropTypes.func,
267
- onPictureInPictureModeChanged: PropTypes.func,
268
260
 
269
261
  /* Required */
270
262
  ...ViewPropTypes,
@@ -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.10.2"
22
- def releaseVersionCode = 9
21
+ def releaseVersionName = "1.11.0"
22
+ def releaseVersionCode = 10
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.18.2'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.19.0'
90
90
  }
@@ -21,6 +21,8 @@ import com.vdocipher.aegis.player.PlayerHost;
21
21
  import com.vdocipher.aegis.player.VdoInitParams;
22
22
  import com.vdocipher.aegis.ui.view.VdoPlayerControlView;
23
23
  import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
24
+ import android.os.Handler;
25
+ import android.os.Bundle;
24
26
 
25
27
 
26
28
  public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
@@ -40,19 +42,25 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
40
42
  private VdoInitParams vdoParams;
41
43
  private AppCompatActivity activity;
42
44
 
45
+ private FragmentManager fragmentManager;
46
+
43
47
  public ReactVdoPlayerUIView(ThemedReactContext context) {
44
48
  super(context);
45
49
  themedReactContext = context;
46
50
  activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
51
+ setKeepScreenOn(true);
47
52
 
48
53
  context.addLifecycleEventListener(this);
49
54
  activity.addOnConfigurationChangedListener(this);
50
55
 
51
56
  eventEmitter = new VdoEventEmitter(context);
52
57
 
53
- LayoutInflater.from(context).inflate(R.layout.activity_vdo_player_ui, this);
54
58
 
55
- vdoPlayerUIFragment = (VdoPlayerUIFragment) activity.getSupportFragmentManager().findFragmentById(R.id.online_vdo_player_ui_fragment);
59
+ vdoPlayerUIFragment = new VdoPlayerUIFragment();
60
+ Bundle bundle = new Bundle();
61
+ bundle.putBoolean("showControls", true);
62
+ vdoPlayerUIFragment.setArguments(bundle);
63
+ fragmentManager = this.activity.getSupportFragmentManager();
56
64
  initializePlayer();
57
65
 
58
66
  int orientation = getResources().getConfiguration().orientation;
@@ -64,9 +72,15 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
64
72
 
65
73
  private void initializePlayer() {
66
74
  if (vdoPlayerUIFragment != null) {
67
- // initialize the playerFragment; a VdoPlayer instance will be received
68
- // in onInitializationSuccess() callback
69
- vdoPlayerUIFragment.initialize(initializationListener);
75
+ new Handler().postDelayed(() -> {
76
+ if (fragmentManager != null && !fragmentManager.isDestroyed()) {
77
+ fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, VdoPlayerUIFragment.class.getName()).commitNow();
78
+ }
79
+ vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
80
+ // initialize the playerFragment; a VdoPlayer instance will be received
81
+ // in onInitializationSuccess() callback
82
+ vdoPlayerUIFragment.initialize(initializationListener);
83
+ }, 200);
70
84
  }
71
85
  }
72
86
 
@@ -76,6 +90,13 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
76
90
  */
77
91
  public void cleanUp() {
78
92
  themedReactContext.removeLifecycleEventListener(this);
93
+ if (vdoPlayer != null) {
94
+ vdoPlayer.stop();
95
+ }
96
+ if (fragmentManager != null && !fragmentManager.isDestroyed()) {
97
+ fragmentManager.beginTransaction().remove(fragmentManager.findFragmentById(vdoPlayerUIFragment.getId())).commitNow();
98
+ vdoPlayerUIFragment = null;
99
+ }
79
100
  }
80
101
 
81
102
  public void getPlaybackProperties() {
@@ -130,15 +151,18 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
130
151
  protected void onAttachedToWindow() {
131
152
  Log.d(TAG, "onAttachedToWindow");
132
153
  super.onAttachedToWindow();
133
- vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.player_control_view);
154
+ if (playWhenReady) {
155
+ if (vdoPlayer != null) {
156
+ vdoPlayer.setPlayWhenReady(true);
157
+ }
158
+ }
134
159
  }
135
160
 
136
161
  @Override
137
162
  protected void onDetachedFromWindow() {
138
163
  Log.d(TAG, "onDetachedFromWindow");
139
- FragmentManager fragmentManager = this.activity.getSupportFragmentManager();
140
- if (fragmentManager != null && !fragmentManager.isDestroyed()) {
141
- fragmentManager.beginTransaction().remove(vdoPlayerUIFragment).commitNow();
164
+ if (vdoPlayer != null) {
165
+ vdoPlayer.setPlayWhenReady(false);
142
166
  }
143
167
  super.onDetachedFromWindow();
144
168
  }
@@ -1,6 +1,5 @@
1
1
  package com.vdocipher.rnbridge;
2
2
 
3
- import android.app.Activity;
4
3
  import android.os.Build;
5
4
  import android.util.Log;
6
5
  import android.view.View;
@@ -21,7 +20,7 @@ import com.vdocipher.aegis.player.PlayerHost;
21
20
  import com.vdocipher.aegis.player.PlayerHost.InitializationListener;
22
21
  import com.vdocipher.aegis.player.VdoPlayer.PlaybackEventListener;
23
22
  import com.vdocipher.aegis.player.VdoInitParams;
24
- import com.vdocipher.aegis.player.VdoPlayerSupportFragment;
23
+ import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
25
24
  import android.media.AudioManager;
26
25
  import android.app.UiModeManager;
27
26
  import android.content.Context;
@@ -32,15 +31,17 @@ import android.support.v4.media.MediaMetadataCompat;
32
31
  import android.support.v4.media.session.MediaControllerCompat;
33
32
  import android.support.v4.media.session.MediaSessionCompat;
34
33
  import android.support.v4.media.session.PlaybackStateCompat;
34
+ import android.os.Handler;
35
+ import android.os.Bundle;
35
36
 
36
- public class ReactVdoPlayerView extends FrameLayout implements InitializationListener,
37
- PlaybackEventListener, LifecycleEventListener {
37
+ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventListener {
38
38
  private static final String TAG = "ReactVdoPlayerView";
39
39
 
40
40
  private final ThemedReactContext themedReactContext;
41
- private VdoPlayerSupportFragment vdoPlayerFragment;
42
41
  private final VdoEventEmitter eventEmitter;
42
+ private VdoPlayerUIFragment vdoPlayerUIFragment;
43
43
  private AudioManager audioManager;
44
+ private FragmentManager fragmentManager;
44
45
 
45
46
  private VdoPlayer vdoPlayer;
46
47
 
@@ -66,14 +67,16 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
66
67
  super(context);
67
68
  context.addLifecycleEventListener(this);
68
69
  themedReactContext = context;
70
+ activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
71
+ setKeepScreenOn(true);
69
72
 
70
73
  eventEmitter = new VdoEventEmitter(context);
71
74
 
72
- LayoutInflater.from(context).inflate(R.layout.activity_vdo_player_ui_custom, this);
73
-
74
- activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
75
- vdoPlayerFragment = (VdoPlayerSupportFragment) activity.getSupportFragmentManager().findFragmentById(R.id.online_vdo_player_support_fragment);
76
-
75
+ vdoPlayerUIFragment = new VdoPlayerUIFragment();
76
+ Bundle bundle = new Bundle();
77
+ bundle.putBoolean("showControls", false);
78
+ vdoPlayerUIFragment.setArguments(bundle);
79
+ fragmentManager = activity.getSupportFragmentManager();
77
80
  initializePlayer();
78
81
 
79
82
  int orientation = getResources().getConfiguration().orientation;
@@ -86,10 +89,15 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
86
89
  }
87
90
 
88
91
  private void initializePlayer() {
89
- if (vdoPlayerFragment != null) {
90
- // initialize the playerFragment; a VdoPlayer instance will be received
91
- // in onInitializationSuccess() callback
92
- vdoPlayerFragment.initialize(this);
92
+ if (vdoPlayerUIFragment != null) {
93
+ new Handler().postDelayed(() -> {
94
+ if (fragmentManager != null && !fragmentManager.isDestroyed()) {
95
+ fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitNow();
96
+ }
97
+ // initialize the playerFragment; a VdoPlayer instance will be received
98
+ // in onInitializationSuccess() callback
99
+ vdoPlayerUIFragment.initialize(initializationListener);
100
+ }, 200);
93
101
  }
94
102
  }
95
103
 
@@ -101,6 +109,13 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
101
109
  if (hasPictureInPictureSupport && pictureModeChangedInfoConsumer != null) {
102
110
  activity.removeOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
103
111
  }
112
+ if (vdoPlayer != null) {
113
+ vdoPlayer.stop();
114
+ }
115
+ if (fragmentManager != null && !fragmentManager.isDestroyed()) {
116
+ fragmentManager.beginTransaction().remove(fragmentManager.findFragmentById(vdoPlayerUIFragment.getId())).commitNow();
117
+ vdoPlayerUIFragment = null;
118
+ }
104
119
  }
105
120
 
106
121
  public boolean setFullscreen(boolean enterFullscreen) {
@@ -158,7 +173,7 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
158
173
  }
159
174
 
160
175
  public void setPlaybackSpeed(float playbackSpeed) {
161
- pendingPlaybackSpeed = playbackSpeed;
176
+ this.pendingPlaybackSpeed = playbackSpeed;
162
177
  if (vdoPlayer != null) {
163
178
  vdoPlayer.setPlaybackSpeed(playbackSpeed);
164
179
  }
@@ -273,14 +288,18 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
273
288
  protected void onAttachedToWindow() {
274
289
  Log.d(TAG, "onAttachedToWindow");
275
290
  super.onAttachedToWindow();
291
+ if (playWhenReady) {
292
+ if (vdoPlayer != null) {
293
+ vdoPlayer.setPlayWhenReady(true);
294
+ }
295
+ }
276
296
  }
277
297
 
278
298
  @Override
279
299
  protected void onDetachedFromWindow() {
280
300
  Log.d(TAG, "onDetachedFromWindow");
281
- FragmentManager fragmentManager = activity.getSupportFragmentManager();
282
- if (fragmentManager != null && !fragmentManager.isDestroyed()) {
283
- fragmentManager.beginTransaction().remove(vdoPlayerFragment).commitNow();
301
+ if (vdoPlayer != null) {
302
+ vdoPlayer.setPlayWhenReady(false);
284
303
  }
285
304
  super.onDetachedFromWindow();
286
305
  }
@@ -304,14 +323,28 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
304
323
  // already unregistered as a lifecycle listener
305
324
  }
306
325
 
326
+ @Override
327
+ public void requestLayout() {
328
+ super.requestLayout();
329
+ post(measureAndLayout);
330
+ }
331
+
332
+ private final Runnable measureAndLayout = () -> {
333
+ measure(
334
+ MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
335
+ MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
336
+ layout(getLeft(), getTop(), getRight(), getBottom());
337
+ };
338
+
307
339
 
308
340
  // InitializationListener impl
309
341
 
342
+ PlayerHost.InitializationListener initializationListener = new PlayerHost.InitializationListener() {
310
343
  @Override
311
- public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer vdoPlayer, boolean restored) {
344
+ public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
312
345
  Log.d(TAG, "init success");
313
- this.vdoPlayer = vdoPlayer;
314
- vdoPlayer.addPlaybackEventListener(this);
346
+ vdoPlayer = player;
347
+ vdoPlayer.addPlaybackEventListener(playbackListener);
315
348
  eventEmitter.initSuccess(restored);
316
349
 
317
350
  // load pending params
@@ -332,6 +365,8 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
332
365
  eventEmitter.initFailure(errorDescription);
333
366
  }
334
367
 
368
+ };
369
+
335
370
  public void load(VdoInitParams params) {
336
371
  if (vdoPlayer != null && params != null) {
337
372
  vdoPlayer.load(params);
@@ -340,31 +375,6 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
340
375
  }
341
376
  }
342
377
 
343
- // PlaybackEventListener impl
344
-
345
- @Override
346
- public void onPlayerStateChanged(boolean playWhenReady, int playerState) {
347
- boolean playing = playerState != VdoPlayer.STATE_IDLE && playerState != VdoPlayer.STATE_ENDED && playWhenReady;
348
-
349
- // We are playing the video now. Update the media session state and the PiP
350
- // window will update the actions.
351
-
352
- if (hasPictureInPictureSupport) {
353
- updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
354
- }
355
-
356
- if (playing) {
357
- //Request audio focus and notify other players to stop playback.
358
- if (!requestAudioFocus(audioManager)) {
359
- Log.i(TAG, "Audio focus not granted");
360
- }
361
- } else if (playerState == VdoPlayer.STATE_ENDED) {
362
- // Abandon audio focus when playback complete
363
- audioManager.abandonAudioFocus(audioFocusChangeListener);
364
- }
365
- eventEmitter.playerStateChanged(playWhenReady, playerState);
366
- }
367
-
368
378
  private boolean requestAudioFocus(AudioManager audioManager) {
369
379
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == audioManager.requestAudioFocus(audioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
370
380
  }
@@ -393,6 +403,32 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
393
403
  }
394
404
  };
395
405
 
406
+ // PlaybackEventListener impl
407
+
408
+ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.PlaybackEventListener() {
409
+ @Override
410
+ public void onPlayerStateChanged(boolean playWhenReady, int playerState) {
411
+ boolean playing = playerState != VdoPlayer.STATE_IDLE && playerState != VdoPlayer.STATE_ENDED && playWhenReady;
412
+
413
+ // We are playing the video now. Update the media session state and the PiP
414
+ // window will update the actions.
415
+
416
+ if (hasPictureInPictureSupport) {
417
+ updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
418
+ }
419
+
420
+ if (playing) {
421
+ //Request audio focus and notify other players to stop playback.
422
+ if (!requestAudioFocus(audioManager)) {
423
+ Log.i(TAG, "Audio focus not granted");
424
+ }
425
+ } else if (playerState == VdoPlayer.STATE_ENDED) {
426
+ // Abandon audio focus when playback complete
427
+ audioManager.abandonAudioFocus(audioFocusChangeListener);
428
+ }
429
+ eventEmitter.playerStateChanged(playWhenReady, playerState);
430
+ }
431
+
396
432
  @Override
397
433
  public void onSeekTo(long timeMs) {
398
434
  eventEmitter.seekTo(timeMs);
@@ -447,4 +483,5 @@ public class ReactVdoPlayerView extends FrameLayout implements InitializationLis
447
483
  public void onTracksChanged(Track[] availableTracks, Track[] selectedTracks) {
448
484
  eventEmitter.tracksChanged(availableTracks, selectedTracks);
449
485
  }
486
+ };
450
487
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "description": "React native bridge library that delegates to vdocipher native android SDK",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
- android:layout_width="match_parent"
4
- android:layout_height="match_parent">
5
- <fragment
6
- android:name="com.vdocipher.aegis.ui.view.VdoPlayerUIFragment"
7
- android:id="@+id/online_vdo_player_ui_fragment"
8
- android:layout_width="match_parent"
9
- android:layout_height="wrap_content"
10
- android:layout_gravity="center"
11
- android:keepScreenOn="true"/>
12
- </FrameLayout>
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
- android:layout_width="match_parent"
4
- android:layout_height="match_parent">
5
- <fragment
6
- android:name="com.vdocipher.aegis.player.VdoPlayerSupportFragment"
7
- android:id="@+id/online_vdo_player_support_fragment"
8
- android:layout_width="match_parent"
9
- android:layout_height="wrap_content"
10
- android:layout_gravity="center"
11
- android:keepScreenOn="true"/>
12
- </FrameLayout>