vdocipher-rn-bridge 1.14.0 → 1.15.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 +7 -0
- package/android/build.gradle +3 -3
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/java/com/vdocipher/rnbridge/AudioFocusManager.java +59 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +10 -2
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +28 -13
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerActivity.java +19 -129
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +36 -35
- package/android/src/main/res/layout/activity_vdo_player.xml +1 -9
- package/index.ts +3 -3
- package/ios/.DS_Store +0 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
## Changelog
|
|
2
|
+
### 1.15.0
|
|
3
|
+
* Updated VdoCipher android sdk dependency to 1.19.6
|
|
4
|
+
* Added PlayerUI for fullscreen player
|
|
5
|
+
* Added PIP support for fullscreen player
|
|
6
|
+
* Added range for react-native peer dependency
|
|
7
|
+
|
|
8
|
+
|
|
2
9
|
### 1.14.0
|
|
3
10
|
* Added `getPlaybackPropertiesV2` method to get totalPlayed and totalCovered properties
|
|
4
11
|
* Added track selection APIs for Player UI
|
package/android/build.gradle
CHANGED
|
@@ -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.
|
|
22
|
-
def releaseVersionCode =
|
|
21
|
+
def releaseVersionName = "1.15.0"
|
|
22
|
+
def releaseVersionCode = 19
|
|
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.
|
|
89
|
+
implementation 'com.vdocipher.aegis:vdocipher-android:1.19.6'
|
|
90
90
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<activity android:name=".VdoPlayerActivity"
|
|
7
7
|
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
|
8
8
|
android:screenOrientation="sensorLandscape"
|
|
9
|
-
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
9
|
+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
|
|
10
|
+
android:supportsPictureInPicture="true"/>
|
|
10
11
|
</application>
|
|
11
12
|
</manifest>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.vdocipher.aegis.ui.view.internal;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.media.AudioAttributes;
|
|
5
|
+
import android.media.AudioFocusRequest;
|
|
6
|
+
import android.media.AudioManager;
|
|
7
|
+
import android.os.Build;
|
|
8
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
|
|
12
|
+
import java.lang.ref.WeakReference;
|
|
13
|
+
|
|
14
|
+
public class AudioFocusManager {
|
|
15
|
+
private final WeakReference<AudioManager> audioManager;
|
|
16
|
+
private final AudioManager.OnAudioFocusChangeListener audioFocusChangeListener;
|
|
17
|
+
private AudioFocusRequest audioFocusRequest;
|
|
18
|
+
|
|
19
|
+
public AudioFocusManager(@NonNull AppCompatActivity activity, AudioManager.OnAudioFocusChangeListener audioFocusChangeListener) {
|
|
20
|
+
AudioManager am = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
|
|
21
|
+
audioManager = new WeakReference<>(am);
|
|
22
|
+
this.audioFocusChangeListener = audioFocusChangeListener;
|
|
23
|
+
init();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private void init() {
|
|
27
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
28
|
+
AudioAttributes audioAttributes = new AudioAttributes.Builder()
|
|
29
|
+
.setUsage(AudioAttributes.USAGE_MEDIA)
|
|
30
|
+
.setContentType(AudioAttributes.CONTENT_TYPE_MOVIE)
|
|
31
|
+
.build();
|
|
32
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
33
|
+
audioFocusRequest = new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
|
|
34
|
+
.setAudioAttributes(audioAttributes)
|
|
35
|
+
.setAcceptsDelayedFocusGain(true)
|
|
36
|
+
.setOnAudioFocusChangeListener(audioFocusChangeListener)
|
|
37
|
+
.build();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public boolean requestAudioFocus() {
|
|
43
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
44
|
+
//must supply an AudioFocusRequest parameter
|
|
45
|
+
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == audioManager.get().requestAudioFocus(audioFocusRequest);
|
|
46
|
+
} else {
|
|
47
|
+
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == audioManager.get().requestAudioFocus(audioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void abandonAudioFocus() {
|
|
52
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
53
|
+
audioManager.get().abandonAudioFocusRequest(audioFocusRequest);
|
|
54
|
+
} else {
|
|
55
|
+
audioManager.get().abandonAudioFocus(audioFocusChangeListener);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
@@ -3,6 +3,7 @@ package com.vdocipher.rnbridge;
|
|
|
3
3
|
import androidx.appcompat.app.AppCompatActivity;
|
|
4
4
|
import androidx.core.util.Consumer;
|
|
5
5
|
import androidx.fragment.app.FragmentManager;
|
|
6
|
+
import androidx.fragment.app.Fragment;
|
|
6
7
|
|
|
7
8
|
import android.content.res.Configuration;
|
|
8
9
|
import android.util.Log;
|
|
@@ -115,9 +116,16 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
115
116
|
vdoPlayer.stop();
|
|
116
117
|
}
|
|
117
118
|
if (fragmentManager != null && !fragmentManager.isDestroyed()) {
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
try {
|
|
120
|
+
Fragment fragment = fragmentManager.findFragmentById(vdoPlayerUIFragment.getId());
|
|
121
|
+
if (fragment != null) {
|
|
122
|
+
fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
123
|
+
}
|
|
124
|
+
} catch(IllegalStateException e) {
|
|
125
|
+
e.printStackTrace();
|
|
126
|
+
}
|
|
120
127
|
}
|
|
128
|
+
vdoPlayerUIFragment = null;
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
public void getPlaybackProperties() {
|
|
@@ -7,6 +7,7 @@ import android.widget.FrameLayout;
|
|
|
7
7
|
import android.content.pm.ActivityInfo;
|
|
8
8
|
import androidx.appcompat.app.AppCompatActivity;
|
|
9
9
|
import androidx.fragment.app.FragmentManager;
|
|
10
|
+
import androidx.fragment.app.Fragment;
|
|
10
11
|
|
|
11
12
|
import android.view.LayoutInflater;
|
|
12
13
|
|
|
@@ -22,6 +23,7 @@ import com.vdocipher.aegis.player.VdoPlayer.PlaybackEventListener;
|
|
|
22
23
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
23
24
|
import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
|
|
24
25
|
import android.media.AudioManager;
|
|
26
|
+
import com.vdocipher.aegis.ui.view.internal.AudioFocusManager;
|
|
25
27
|
import android.content.Context;
|
|
26
28
|
|
|
27
29
|
import androidx.core.app.PictureInPictureModeChangedInfo;
|
|
@@ -48,7 +50,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
48
50
|
private final ThemedReactContext themedReactContext;
|
|
49
51
|
private final VdoEventEmitter eventEmitter;
|
|
50
52
|
private VdoPlayerUIFragment vdoPlayerUIFragment;
|
|
51
|
-
private
|
|
53
|
+
private AudioFocusManager audioFocusManager;
|
|
52
54
|
private FragmentManager fragmentManager;
|
|
53
55
|
|
|
54
56
|
private VdoPlayer vdoPlayer;
|
|
@@ -68,7 +70,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
68
70
|
|
|
69
71
|
private AppCompatActivity activity;
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
private Consumer<PictureInPictureModeChangedInfo> pictureModeChangedInfoConsumer;
|
|
72
74
|
|
|
73
75
|
private Track[] availableTracks;
|
|
74
76
|
private Track[] selectedTracks;
|
|
@@ -94,7 +96,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
setPictureInPictureSupport();
|
|
97
|
-
|
|
99
|
+
audioFocusManager = new AudioFocusManager(activity, audioFocusChangeListener);
|
|
98
100
|
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -124,9 +126,16 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
124
126
|
vdoPlayer.stop();
|
|
125
127
|
}
|
|
126
128
|
if (fragmentManager != null && !fragmentManager.isDestroyed()) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
try {
|
|
130
|
+
Fragment fragment = fragmentManager.findFragmentById(vdoPlayerUIFragment.getId());
|
|
131
|
+
if (fragment != null) {
|
|
132
|
+
fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
133
|
+
}
|
|
134
|
+
} catch(IllegalStateException e) {
|
|
135
|
+
e.printStackTrace();
|
|
136
|
+
}
|
|
129
137
|
}
|
|
138
|
+
vdoPlayerUIFragment = null;
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
public boolean setFullscreen(boolean enterFullscreen) {
|
|
@@ -262,12 +271,14 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
262
271
|
*/
|
|
263
272
|
private void updatePlaybackState(
|
|
264
273
|
@PlaybackStateCompat.State int state, long position, float playBackSpeed) {
|
|
274
|
+
if (mSession == null) return;
|
|
265
275
|
long actions = mSession.getController().getPlaybackState().getActions();
|
|
266
276
|
updatePlaybackState(state, actions, position, playBackSpeed);
|
|
267
277
|
}
|
|
268
278
|
|
|
269
279
|
private void updatePlaybackState(
|
|
270
280
|
@PlaybackStateCompat.State int state, long playbackActions, long position, float playBackSpeed) {
|
|
281
|
+
if (mSession == null) return;
|
|
271
282
|
PlaybackStateCompat.Builder builder =
|
|
272
283
|
new PlaybackStateCompat.Builder()
|
|
273
284
|
.setActions(playbackActions)
|
|
@@ -437,6 +448,14 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
437
448
|
if (vdoPlayer != null) {
|
|
438
449
|
vdoPlayer.setPlayWhenReady(false);
|
|
439
450
|
}
|
|
451
|
+
if (audioFocusManager != null) {
|
|
452
|
+
audioFocusManager.abandonAudioFocus();
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (mSession != null) {
|
|
456
|
+
//release media session
|
|
457
|
+
mSession.release();
|
|
458
|
+
}
|
|
440
459
|
super.onDetachedFromWindow();
|
|
441
460
|
}
|
|
442
461
|
|
|
@@ -492,7 +511,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
492
511
|
pendingInitParams = null;
|
|
493
512
|
}
|
|
494
513
|
|
|
495
|
-
initializeMediaSession();
|
|
496
514
|
}
|
|
497
515
|
|
|
498
516
|
@Override
|
|
@@ -511,10 +529,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
511
529
|
}
|
|
512
530
|
}
|
|
513
531
|
|
|
514
|
-
private boolean requestAudioFocus(AudioManager audioManager) {
|
|
515
|
-
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == audioManager.requestAudioFocus(audioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
532
|
private final AudioManager.OnAudioFocusChangeListener audioFocusChangeListener = new AudioManager.OnAudioFocusChangeListener() {
|
|
519
533
|
@Override
|
|
520
534
|
public void onAudioFocusChange(int focusChange) {
|
|
@@ -553,12 +567,12 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
|
|
|
553
567
|
|
|
554
568
|
if (playing) {
|
|
555
569
|
//Request audio focus and notify other players to stop playback.
|
|
556
|
-
if (
|
|
570
|
+
if ((audioFocusManager != null && audioFocusManager.requestAudioFocus())) {
|
|
557
571
|
Log.i(TAG, "Audio focus not granted");
|
|
558
572
|
}
|
|
559
|
-
} else if (playerState == VdoPlayer.STATE_ENDED) {
|
|
573
|
+
} else if (playerState == VdoPlayer.STATE_ENDED && audioFocusManager != null) {
|
|
560
574
|
// Abandon audio focus when playback complete
|
|
561
|
-
|
|
575
|
+
audioFocusManager.abandonAudioFocus();
|
|
562
576
|
}
|
|
563
577
|
eventEmitter.playerStateChanged(playWhenReady, playerState);
|
|
564
578
|
}
|
|
@@ -595,6 +609,7 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
|
|
|
595
609
|
vdoPlayer.setPlaybackSpeed(pendingPlaybackSpeed);
|
|
596
610
|
pendingPlaybackSpeed = 0;
|
|
597
611
|
}
|
|
612
|
+
initializeMediaSession();
|
|
598
613
|
eventEmitter.loaded(vdoInitParams, vdoPlayer.getCurrentMedia());
|
|
599
614
|
}
|
|
600
615
|
|
|
@@ -18,26 +18,31 @@ import com.vdocipher.aegis.media.Track;
|
|
|
18
18
|
import com.vdocipher.aegis.player.VdoPlayer;
|
|
19
19
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
20
20
|
import com.vdocipher.aegis.player.PlayerHost;
|
|
21
|
-
import com.vdocipher.aegis.
|
|
21
|
+
import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
|
|
22
|
+
|
|
23
|
+
import androidx.annotation.RequiresApi;
|
|
24
|
+
import android.app.PictureInPictureParams;
|
|
22
25
|
|
|
23
26
|
public class VdoPlayerActivity extends AppCompatActivity implements PlayerHost.InitializationListener {
|
|
24
27
|
|
|
25
28
|
private static final String TAG = "VdoPlayerActivity";
|
|
26
29
|
|
|
27
30
|
private static final String EXTRA_VDOPARAMS = "vdoparams";
|
|
31
|
+
private static final String PIP_SUPPORT = "pipsupport";
|
|
28
32
|
|
|
29
33
|
private VdoPlayer player;
|
|
30
|
-
private
|
|
31
|
-
private VdoPlayerControlView playerControlView;
|
|
34
|
+
private VdoPlayerUIFragment playerFragment;
|
|
32
35
|
private String eventLogString = "";
|
|
33
36
|
|
|
34
37
|
private int currentOrientation;
|
|
35
38
|
|
|
36
39
|
private VdoInitParams vdoParams;
|
|
40
|
+
private boolean setPictureInPictureSupport = false;
|
|
37
41
|
|
|
38
|
-
public static Intent getStartIntent(Context context, VdoInitParams vdoParams) {
|
|
42
|
+
public static Intent getStartIntent(Context context, VdoInitParams vdoParams, boolean setPictureInPictureSupport) {
|
|
39
43
|
Intent intent = new Intent(context, VdoPlayerActivity.class);
|
|
40
44
|
intent.putExtra(EXTRA_VDOPARAMS, vdoParams);
|
|
45
|
+
intent.putExtra(PIP_SUPPORT, setPictureInPictureSupport);
|
|
41
46
|
return intent;
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -47,30 +52,22 @@ public class VdoPlayerActivity extends AppCompatActivity implements PlayerHost.I
|
|
|
47
52
|
Log.v(TAG, "onCreate called");
|
|
48
53
|
setContentView(R.layout.activity_vdo_player);
|
|
49
54
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
50
|
-
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(uiVisibilityListener);
|
|
51
55
|
|
|
52
56
|
if (getSupportActionBar() != null) {
|
|
53
57
|
getSupportActionBar().hide();
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
// first check if otp and playbackInfo are already available from a previous instance
|
|
57
|
-
if (savedInstanceState != null) {
|
|
58
|
-
vdoParams = savedInstanceState.getParcelable(EXTRA_VDOPARAMS);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
60
|
// expect in intent if not obtained yet
|
|
62
61
|
if (vdoParams == null) {
|
|
63
62
|
Intent intent = getIntent();
|
|
64
63
|
vdoParams = intent.getParcelableExtra(EXTRA_VDOPARAMS);
|
|
64
|
+
setPictureInPictureSupport = intent.getBooleanExtra(PIP_SUPPORT, false);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
playerFragment = (
|
|
68
|
-
playerControlView = (VdoPlayerControlView)findViewById(R.id.player_control_view);
|
|
67
|
+
playerFragment = (VdoPlayerUIFragment)getSupportFragmentManager().findFragmentById(R.id.online_vdo_player_fragment);
|
|
69
68
|
|
|
70
69
|
currentOrientation = getResources().getConfiguration().orientation;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
playerControlView.setFullscreenState(currentOrientation == Configuration.ORIENTATION_LANDSCAPE);
|
|
70
|
+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
|
74
71
|
|
|
75
72
|
initializePlayer();
|
|
76
73
|
}
|
|
@@ -84,7 +81,6 @@ public class VdoPlayerActivity extends AppCompatActivity implements PlayerHost.I
|
|
|
84
81
|
@Override
|
|
85
82
|
protected void onStop() {
|
|
86
83
|
Log.v(TAG, "onStop called");
|
|
87
|
-
disablePlayerUI();
|
|
88
84
|
super.onStop();
|
|
89
85
|
}
|
|
90
86
|
|
|
@@ -118,30 +114,12 @@ public class VdoPlayerActivity extends AppCompatActivity implements PlayerHost.I
|
|
|
118
114
|
eventLogString += (msg + "\n");
|
|
119
115
|
}
|
|
120
116
|
|
|
121
|
-
private void showControls(boolean show) {
|
|
122
|
-
Log.v(TAG, (show ? "show" : "hide") + " controls");
|
|
123
|
-
if (show) {
|
|
124
|
-
playerControlView.show();
|
|
125
|
-
} else {
|
|
126
|
-
playerControlView.hide();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private void disablePlayerUI() {
|
|
131
|
-
// showControls(false);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
117
|
@Override
|
|
135
118
|
public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean wasRestored) {
|
|
136
119
|
Log.i(TAG, "onInitializationSuccess");
|
|
137
120
|
log("onInitializationSuccess");
|
|
138
121
|
this.player = player;
|
|
139
122
|
player.addPlaybackEventListener(playbackListener);
|
|
140
|
-
playerControlView.setPlayer(player);
|
|
141
|
-
showControls(true);
|
|
142
|
-
|
|
143
|
-
playerControlView.setFullscreenActionListener(fullscreenToggleListener);
|
|
144
|
-
playerControlView.setControllerVisibilityListener(visibilityListener);
|
|
145
123
|
|
|
146
124
|
// load a media to the player
|
|
147
125
|
player.load(vdoParams);
|
|
@@ -212,107 +190,19 @@ public class VdoPlayerActivity extends AppCompatActivity implements PlayerHost.I
|
|
|
212
190
|
}
|
|
213
191
|
};
|
|
214
192
|
|
|
215
|
-
private VdoPlayerControlView.FullscreenActionListener fullscreenToggleListener = new VdoPlayerControlView.FullscreenActionListener() {
|
|
216
|
-
@Override
|
|
217
|
-
public boolean onFullscreenAction(boolean enterFullscreen) {
|
|
218
|
-
showFullScreen(enterFullscreen);
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
private VdoPlayerControlView.ControllerVisibilityListener visibilityListener = new VdoPlayerControlView.ControllerVisibilityListener() {
|
|
224
|
-
@Override
|
|
225
|
-
public void onControllerVisibilityChange(int visibility) {
|
|
226
|
-
Log.i(TAG, "controller visibility " + visibility);
|
|
227
|
-
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
228
|
-
if (visibility != View.VISIBLE) {
|
|
229
|
-
showSystemUi(false);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
@Override
|
|
236
|
-
public void onConfigurationChanged(Configuration newConfig) {
|
|
237
|
-
final int newOrientation = newConfig.orientation;
|
|
238
|
-
final int oldOrientation = currentOrientation;
|
|
239
|
-
currentOrientation = newOrientation;
|
|
240
|
-
Log.i(TAG, "new orientation " +
|
|
241
|
-
(newOrientation == Configuration.ORIENTATION_PORTRAIT ? "PORTRAIT" :
|
|
242
|
-
newOrientation == Configuration.ORIENTATION_LANDSCAPE ? "LANDSCAPE" : "UNKNOWN"));
|
|
243
|
-
super.onConfigurationChanged(newConfig);
|
|
244
|
-
if (newOrientation == oldOrientation) {
|
|
245
|
-
Log.i(TAG, "orientation unchanged");
|
|
246
|
-
} else if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
247
|
-
setLayout(true);
|
|
248
|
-
// hide system windows
|
|
249
|
-
showSystemUi(false);
|
|
250
|
-
showControls(false);
|
|
251
|
-
} else {
|
|
252
|
-
setLayout(false);
|
|
253
|
-
// show system windows
|
|
254
|
-
showSystemUi(true);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
private void setLayout(boolean landscape) {
|
|
259
|
-
if (landscape) {
|
|
260
|
-
// hide other views
|
|
261
|
-
(findViewById(R.id.online_vdo_player_fragment)).setLayoutParams(new RelativeLayout.LayoutParams(
|
|
262
|
-
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
|
|
263
|
-
playerControlView.setFitsSystemWindows(true);
|
|
264
|
-
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
265
|
-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
266
|
-
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
|
267
|
-
} else {
|
|
268
|
-
// show other views
|
|
269
|
-
(findViewById(R.id.online_vdo_player_fragment)).setLayoutParams(new RelativeLayout.LayoutParams(
|
|
270
|
-
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
|
|
271
|
-
playerControlView.setFitsSystemWindows(false);
|
|
272
|
-
playerControlView.setPadding(0,0,0,0);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
193
|
@Override
|
|
277
194
|
public void onBackPressed() {
|
|
278
195
|
super.onBackPressed();
|
|
279
196
|
}
|
|
280
197
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
private void showSystemUi(boolean show) {
|
|
293
|
-
Log.v(TAG, (show ? "show" : "hide") + " system ui");
|
|
294
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
295
|
-
if (!show) {
|
|
296
|
-
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
297
|
-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
298
|
-
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
299
|
-
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
300
|
-
| View.SYSTEM_UI_FLAG_FULLSCREEN);
|
|
301
|
-
} else {
|
|
302
|
-
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
303
|
-
}
|
|
198
|
+
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
199
|
+
@Override
|
|
200
|
+
protected void onUserLeaveHint() {
|
|
201
|
+
super.onUserLeaveHint();
|
|
202
|
+
// switch to PiP mode if the user presses the home or recent button,
|
|
203
|
+
if (setPictureInPictureSupport) {
|
|
204
|
+
enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
|
|
304
205
|
}
|
|
305
206
|
}
|
|
306
207
|
|
|
307
|
-
private View.OnSystemUiVisibilityChangeListener uiVisibilityListener = new View.OnSystemUiVisibilityChangeListener() {
|
|
308
|
-
@Override
|
|
309
|
-
public void onSystemUiVisibilityChange(int visibility) {
|
|
310
|
-
Log.v(TAG, "onSystemUiVisibilityChange");
|
|
311
|
-
// show player controls when system ui is showing
|
|
312
|
-
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
|
|
313
|
-
Log.v(TAG, "system ui visible, making controls visible");
|
|
314
|
-
showControls(true);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
208
|
}
|
|
@@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
10
10
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
11
11
|
|
|
12
12
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
13
|
+
import java.util.HashMap;
|
|
13
14
|
|
|
14
15
|
public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
15
16
|
|
|
@@ -32,7 +33,7 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
32
33
|
|
|
33
34
|
// todo error event handling
|
|
34
35
|
@ReactMethod
|
|
35
|
-
public void startVideoScreen(ReadableMap embedParams) {
|
|
36
|
+
public void startVideoScreen(ReadableMap embedParams, boolean setPictureInPictureSupport) {
|
|
36
37
|
ReadableMap embedInfo = embedParams.getMap("embedInfo");
|
|
37
38
|
Activity currentActivity = getCurrentActivity();
|
|
38
39
|
if (currentActivity == null) {
|
|
@@ -42,30 +43,30 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
42
43
|
final VdoInitParams vdoParams;
|
|
43
44
|
boolean enableAutoResume = embedInfo.hasKey("enableAutoResume") && embedInfo.getBoolean("enableAutoResume");
|
|
44
45
|
String preferredCaptionsLanguage = embedInfo.hasKey("preferredCaptionsLanguage") ?
|
|
45
|
-
|
|
46
|
+
embedInfo.getString("preferredCaptionsLanguage") : null;
|
|
47
|
+
String safetyNetApiKey = embedInfo.hasKey("safetyNetApiKey") ?
|
|
48
|
+
embedInfo.getString("safetyNetApiKey") : null;
|
|
49
|
+
boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
|
|
50
|
+
embedInfo.getBoolean("allowAdbDebugging");
|
|
51
|
+
|
|
52
|
+
VdoInitParams.Builder builder = new VdoInitParams.Builder();
|
|
53
|
+
|
|
54
|
+
if (enableAutoResume) {
|
|
55
|
+
builder.enableAutoResume();
|
|
56
|
+
}
|
|
57
|
+
if (safetyNetApiKey != null) {
|
|
58
|
+
builder.setSafetyNetApiKey(safetyNetApiKey);
|
|
59
|
+
}
|
|
60
|
+
if (preferredCaptionsLanguage != null) {
|
|
61
|
+
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
62
|
+
}
|
|
46
63
|
|
|
47
64
|
if (offline) {
|
|
48
65
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
49
|
-
String safetyNetApiKey = embedInfo.hasKey("safetyNetApiKey") ?
|
|
50
|
-
embedInfo.getString("safetyNetApiKey") : null;
|
|
51
|
-
boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
|
|
52
|
-
embedInfo.getBoolean("allowAdbDebugging");
|
|
53
|
-
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
.setOfflinePlayback(mediaId)
|
|
67
|
+
builder.setOfflinePlayback(mediaId)
|
|
57
68
|
.setAllowAdbDebugging(allowAdbDebugging);
|
|
58
69
|
|
|
59
|
-
if (enableAutoResume) {
|
|
60
|
-
builder.enableAutoResume();
|
|
61
|
-
}
|
|
62
|
-
if (safetyNetApiKey != null) {
|
|
63
|
-
builder.setSafetyNetApiKey(safetyNetApiKey);
|
|
64
|
-
}
|
|
65
|
-
if (preferredCaptionsLanguage != null) {
|
|
66
|
-
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
67
|
-
}
|
|
68
|
-
vdoParams = builder.build();
|
|
69
70
|
} else {
|
|
70
71
|
String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
|
|
71
72
|
String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
|
|
@@ -78,38 +79,38 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
78
79
|
int bufferingGoalMs = embedInfo.hasKey("bufferingGoalMs") ?
|
|
79
80
|
embedInfo.getInt("bufferingGoalMs") : 0;
|
|
80
81
|
String[] overrides = getTechOverride(embedInfo);
|
|
81
|
-
String
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
String customPlayerId = null;
|
|
83
|
+
if (embedInfo.hasKey("customPlayerId")) {
|
|
84
|
+
customPlayerId = embedInfo.getString("customPlayerId");
|
|
85
|
+
} else if (embedInfo.hasKey("playerConfig")) {
|
|
86
|
+
customPlayerId = embedInfo.getString("playerConfig");
|
|
87
|
+
}
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
.setOtp(otp)
|
|
89
|
+
builder.setOtp(otp)
|
|
88
90
|
.setPlaybackInfo(playbackInfo)
|
|
89
91
|
.setAllowAdbDebugging(allowAdbDebugging)
|
|
90
92
|
.setForceLowestBitrate(forceLowestBitrate)
|
|
91
93
|
.setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
|
|
92
94
|
.setMaxVideoBitrateKbps(maxVideoBitrateKbps);
|
|
93
95
|
|
|
94
|
-
if (enableAutoResume) {
|
|
95
|
-
builder.enableAutoResume();
|
|
96
|
-
}
|
|
97
96
|
if (bufferingGoalMs > 0) {
|
|
98
97
|
builder.setBufferingGoalMs(bufferingGoalMs);
|
|
99
98
|
}
|
|
100
99
|
if (overrides != null) {
|
|
101
100
|
builder.setTechOverride(overrides);
|
|
102
101
|
}
|
|
103
|
-
if (
|
|
104
|
-
builder.
|
|
105
|
-
}
|
|
106
|
-
if (preferredCaptionsLanguage != null) {
|
|
107
|
-
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
102
|
+
if (customPlayerId != null) {
|
|
103
|
+
builder.setCustomPlayer(customPlayerId);
|
|
108
104
|
}
|
|
109
|
-
vdoParams = builder.build();
|
|
110
105
|
}
|
|
111
106
|
|
|
112
|
-
|
|
107
|
+
HashMap<String, Object> map = new HashMap<>();
|
|
108
|
+
map.put("showFullScreen", false);
|
|
109
|
+
builder.updateConfig(map);
|
|
110
|
+
|
|
111
|
+
vdoParams = builder.build();
|
|
112
|
+
|
|
113
|
+
Intent intent = VdoPlayerActivity.getStartIntent(currentActivity, vdoParams, setPictureInPictureSupport);
|
|
113
114
|
currentActivity.startActivity(intent);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
@@ -12,20 +12,12 @@
|
|
|
12
12
|
android:layout_width="match_parent"
|
|
13
13
|
android:layout_height="wrap_content">
|
|
14
14
|
<fragment
|
|
15
|
-
android:name="com.vdocipher.aegis.
|
|
15
|
+
android:name="com.vdocipher.aegis.ui.view.VdoPlayerUIFragment"
|
|
16
16
|
android:id="@+id/online_vdo_player_fragment"
|
|
17
17
|
android:layout_width="match_parent"
|
|
18
18
|
android:layout_height="wrap_content"
|
|
19
19
|
android:layout_gravity="center"
|
|
20
20
|
android:keepScreenOn="true"/>
|
|
21
|
-
<com.vdocipher.rnbridge.VdoPlayerControlView
|
|
22
|
-
android:id="@+id/player_control_view"
|
|
23
|
-
android:layout_alignTop="@id/online_vdo_player_fragment"
|
|
24
|
-
android:layout_alignBottom="@id/online_vdo_player_fragment"
|
|
25
|
-
android:layout_alignLeft="@id/online_vdo_player_fragment"
|
|
26
|
-
android:layout_alignRight="@id/online_vdo_player_fragment"
|
|
27
|
-
android:layout_width="match_parent"
|
|
28
|
-
android:layout_height="wrap_content" />
|
|
29
21
|
</RelativeLayout>
|
|
30
22
|
|
|
31
23
|
</LinearLayout>
|
package/index.ts
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
const { VdocipherRnBridge } = NativeModules;
|
|
18
18
|
|
|
19
|
-
const startVideoScreen = (params: {embedInfo: EmbedInfo}) => {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const startVideoScreen = (params: {embedInfo: EmbedInfo}, setPictureInPictureSupport: boolean = false) => {
|
|
20
|
+
VdocipherRnBridge.startVideoScreen(params, setPictureInPictureSupport);
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
export {
|
|
24
24
|
startVideoScreen,
|
package/ios/.DS_Store
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdocipher-rn-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.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": "
|
|
15
|
+
"react-native": "0.68 - 0.71"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"deprecated-react-native-prop-types": "^2.3.0",
|