vdocipher-rn-bridge 1.14.0 → 1.16.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 +23 -0
- package/VdoPlayerSupportView.tsx +6 -4
- package/VdoPlayerUIView.tsx +15 -3
- package/VdoPlayerView.tsx +43 -17
- 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 +49 -32
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +5 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +38 -23
- package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +1 -10
- 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/type.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
## Changelog
|
|
2
|
+
### 1.16.0
|
|
3
|
+
* Updated VdoCipher Android SDK dependency to 1.21.0.
|
|
4
|
+
* Added support for `windowLayoutInDisplayCutoutMode` with inbuilt player UI.
|
|
5
|
+
* Improved feedback of double tap to skip forward and backward.
|
|
6
|
+
* Fullscreen Changes for Player UI:
|
|
7
|
+
* Fixed auto rotate lock while going into fullscreen mode.
|
|
8
|
+
* Implemented fullscreen behavior based on aspect ratio:
|
|
9
|
+
* Vertical videos will go fullscreen in portrait mode.
|
|
10
|
+
* Horizontal videos will go fullscreen in landscape mode.
|
|
11
|
+
* Deprecated `enterFullscreen` and `exitFullscreen` APIs.
|
|
12
|
+
* Added `enterFullscreenV2` and `exitFullscreenV2` APIs with aspect ratio-based fullscreen rotation.
|
|
13
|
+
* Fullscreen Changes for Player with Custom Controls:
|
|
14
|
+
* Deprecated `enterFullscreen` and `exitFullscreen` APIs.
|
|
15
|
+
* Removed the option to go back to portrait mode when the back button is pressed while in fullscreen mode.
|
|
16
|
+
* Fullscreen-related changes need to be performed manually.
|
|
17
|
+
|
|
18
|
+
### 1.15.0
|
|
19
|
+
* Updated VdoCipher android sdk dependency to 1.19.6
|
|
20
|
+
* Added PlayerUI for fullscreen player
|
|
21
|
+
* Added PIP support for fullscreen player
|
|
22
|
+
* Added range for react-native peer dependency
|
|
23
|
+
|
|
24
|
+
|
|
2
25
|
### 1.14.0
|
|
3
26
|
* Added `getPlaybackPropertiesV2` method to get totalPlayed and totalCovered properties
|
|
4
27
|
* Added track selection APIs for Player UI
|
package/VdoPlayerSupportView.tsx
CHANGED
|
@@ -18,22 +18,24 @@ class VdoPlayerSupportView extends Component<MyProps> {
|
|
|
18
18
|
this._propRef = 1;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
handleBackButtonClick() {
|
|
22
|
-
this._root.setNativeProps({fullscreen: false});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
21
|
seek = (seekTargetMs: number) => {
|
|
26
22
|
if (this._root) {
|
|
27
23
|
this._root.setNativeProps({seek: seekTargetMs});
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
31
30
|
enterFullscreen = () => {
|
|
32
31
|
if (this._root) {
|
|
33
32
|
this._root.setNativeProps({fullscreen: true});
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
37
39
|
exitFullscreen = () => {
|
|
38
40
|
if (this._root) {
|
|
39
41
|
this._root.setNativeProps({fullscreen: false});
|
package/VdoPlayerUIView.tsx
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
handleBackButtonClick() {
|
|
69
|
-
this._root.setNativeProps({
|
|
69
|
+
this._root.setNativeProps({backpressCalled: this._propRef++});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
seek = (seekTargetMs: number) => {
|
|
@@ -75,13 +75,25 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated
|
|
80
|
+
* Use {@link enterFullscreenV2} instead.
|
|
81
|
+
*/
|
|
82
|
+
enterFullscreen = () => {}
|
|
83
|
+
|
|
84
|
+
enterFullscreenV2 = () => {
|
|
79
85
|
if (this._root) {
|
|
80
86
|
this._root.setNativeProps({fullscreen: true});
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated
|
|
92
|
+
* Use {@link exitFullscreenV2} instead.
|
|
93
|
+
*/
|
|
94
|
+
exitFullscreen = () => {}
|
|
95
|
+
|
|
96
|
+
exitFullscreenV2 = () => {
|
|
85
97
|
if (this._root) {
|
|
86
98
|
this._root.setNativeProps({fullscreen: false});
|
|
87
99
|
}
|
package/VdoPlayerView.tsx
CHANGED
|
@@ -14,7 +14,6 @@ const VdoViewPropTypes = VdoType.VdoPropTypes;
|
|
|
14
14
|
type MyProps = InferProps<typeof VdoViewPropTypes>;
|
|
15
15
|
type MyState = {
|
|
16
16
|
fullscreen: boolean;
|
|
17
|
-
isInitialPortrait: boolean;
|
|
18
17
|
isInPictureInPictureMode: false;
|
|
19
18
|
};
|
|
20
19
|
|
|
@@ -27,7 +26,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
27
26
|
super(props);
|
|
28
27
|
this.state = {
|
|
29
28
|
fullscreen: false,
|
|
30
|
-
isInitialPortrait: true,
|
|
31
29
|
isInPictureInPictureMode: false
|
|
32
30
|
}
|
|
33
31
|
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
|
|
@@ -46,10 +44,10 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
handleBackButtonClick() {
|
|
49
|
-
if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if (!this.state.isInPictureInPictureMode && this.state.fullscreen && !(this.props.showNativeControls === false)) {
|
|
48
|
+
this._vdoPlayerView.handleBackButtonClick();
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
seek = (seekTargetMs: number) => {
|
|
@@ -58,15 +56,51 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated
|
|
61
|
+
* Use {@link enterFullscreenV2} instead.
|
|
62
|
+
*/
|
|
61
63
|
enterFullscreen = () => {
|
|
62
|
-
|
|
64
|
+
if (this.props.showNativeControls === false) {
|
|
65
|
+
console.warn('enterFullscreen method is deprecated. We advise handling fullscreen changes manually or utilizing our player with native controls which handles fullscreen automatically.');
|
|
66
|
+
} else {
|
|
67
|
+
console.warn('enterFullscreen method is deprecated. Please use enterFullscreenV2 instead.');
|
|
68
|
+
}
|
|
69
|
+
if (this._vdoPlayerView) {
|
|
63
70
|
this._vdoPlayerView.enterFullscreen();
|
|
64
|
-
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Works only with player with native controls
|
|
76
|
+
*/
|
|
77
|
+
enterFullscreenV2 = () => {
|
|
78
|
+
if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
|
|
79
|
+
this._vdoPlayerView.enterFullscreenV2();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated
|
|
85
|
+
* Use {@link exitFullscreenV2} instead.
|
|
86
|
+
*/
|
|
67
87
|
exitFullscreen = () => {
|
|
68
|
-
|
|
88
|
+
if (this.props.showNativeControls === false) {
|
|
89
|
+
console.warn('exitFullscreen method is deprecated. We advise handling fullscreen changes manually or utilizing our player with native controls which handles fullscreen automatically.');
|
|
90
|
+
} else {
|
|
91
|
+
console.warn('exitFullscreen method is deprecated. Please use exitFullscreenV2 instead.');
|
|
92
|
+
}
|
|
93
|
+
if (this._vdoPlayerView) {
|
|
69
94
|
this._vdoPlayerView.exitFullscreen();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Works only with player with native controls
|
|
100
|
+
*/
|
|
101
|
+
exitFullscreenV2 = () => {
|
|
102
|
+
if (this._vdoPlayerView && !(this.props.showNativeControls === false)) {
|
|
103
|
+
this._vdoPlayerView.exitFullscreenV2();
|
|
70
104
|
}
|
|
71
105
|
}
|
|
72
106
|
|
|
@@ -260,12 +294,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
260
294
|
}
|
|
261
295
|
}
|
|
262
296
|
|
|
263
|
-
_onIsInitialPortrait =(event: any) => {
|
|
264
|
-
this.setState({
|
|
265
|
-
isInitialPortrait: event.nativeEvent.isInitialPortrait
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
297
|
_onPictureInPictureModeChanged = (event: any) => {
|
|
270
298
|
this.setState({
|
|
271
299
|
isInPictureInPictureMode: event.nativeEvent.isInPictureInPictureMode
|
|
@@ -297,7 +325,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
297
325
|
onVdoPlaybackProperties={this._onPlaybackProperties}
|
|
298
326
|
onVdoEnterFullscreen={this._onEnterFullscreen}
|
|
299
327
|
onVdoExitFullscreen={this._onExitFullscreen}
|
|
300
|
-
onIsInitialPortrait={this._onIsInitialPortrait}
|
|
301
328
|
onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
|
|
302
329
|
/>
|
|
303
330
|
) :
|
|
@@ -320,7 +347,6 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
320
347
|
onVdoPlaybackProperties={this._onPlaybackProperties}
|
|
321
348
|
onVdoEnterFullscreen={this._onEnterFullscreen}
|
|
322
349
|
onVdoExitFullscreen={this._onExitFullscreen}
|
|
323
|
-
onIsInitialPortrait={this._onIsInitialPortrait}
|
|
324
350
|
onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
|
|
325
351
|
/>
|
|
326
352
|
)
|
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.16.0"
|
|
22
|
+
def releaseVersionCode = 20
|
|
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.
|
|
89
|
+
implementation 'com.vdocipher.aegis:vdocipher-android:1.21.0'
|
|
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
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
package com.vdocipher.rnbridge;
|
|
2
2
|
|
|
3
3
|
import androidx.appcompat.app.AppCompatActivity;
|
|
4
|
-
import androidx.core.util.Consumer;
|
|
5
4
|
import androidx.fragment.app.FragmentManager;
|
|
5
|
+
import androidx.fragment.app.Fragment;
|
|
6
6
|
|
|
7
|
-
import android.content.res.Configuration;
|
|
8
7
|
import android.util.Log;
|
|
9
8
|
import android.view.KeyEvent;
|
|
10
9
|
import android.view.ViewGroup;
|
|
@@ -36,12 +35,15 @@ import com.facebook.react.bridge.Arguments;
|
|
|
36
35
|
import com.facebook.react.bridge.WritableArray;
|
|
37
36
|
import com.facebook.react.bridge.ReadableMap;
|
|
38
37
|
|
|
38
|
+
import com.vdocipher.aegis.ui.view.FullScreenActionListener;
|
|
39
|
+
|
|
39
40
|
|
|
40
|
-
public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener
|
|
41
|
+
public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener {
|
|
41
42
|
private static final String TAG = "ReactVdoPlayerUIView";
|
|
42
43
|
|
|
43
44
|
private final ThemedReactContext themedReactContext;
|
|
44
45
|
private final VdoEventEmitter eventEmitter;
|
|
46
|
+
private FullScreenActionListener fullscreenToggleListener;
|
|
45
47
|
private VdoPlayerUIFragment vdoPlayerUIFragment;
|
|
46
48
|
private VdoPlayerControlView vdoPlayerControlView;
|
|
47
49
|
|
|
@@ -72,18 +74,13 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
72
74
|
setBackgroundColor(Color.BLACK);
|
|
73
75
|
|
|
74
76
|
context.addLifecycleEventListener(this);
|
|
75
|
-
activity.addOnConfigurationChangedListener(this);
|
|
76
77
|
|
|
77
78
|
mainHandler = new Handler(Looper.getMainLooper());
|
|
78
79
|
|
|
79
80
|
eventEmitter = new VdoEventEmitter(context);
|
|
80
81
|
|
|
81
|
-
int orientation = getResources().getConfiguration().orientation;
|
|
82
|
-
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
83
|
-
eventEmitter.isInitialPortrait();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
82
|
setPictureInPictureSupport();
|
|
83
|
+
setFullscreenActionListener();
|
|
87
84
|
|
|
88
85
|
}
|
|
89
86
|
|
|
@@ -91,13 +88,19 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
91
88
|
if (vdoPlayerUIFragment != null) {
|
|
92
89
|
new Handler().postDelayed(() -> {
|
|
93
90
|
if (fragmentManager != null && !fragmentManager.isDestroyed()) {
|
|
94
|
-
|
|
91
|
+
try {
|
|
92
|
+
fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitAllowingStateLoss();
|
|
93
|
+
fragmentManager.executePendingTransactions();
|
|
94
|
+
vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
|
|
95
|
+
// initialize the playerFragment; a VdoPlayer instance will be received
|
|
96
|
+
// in onInitializationSuccess() callback
|
|
97
|
+
vdoPlayerUIFragment.initialize(initializationListener);
|
|
98
|
+
vdoPlayerUIFragment.setResizeMode(this.resizeMode);
|
|
99
|
+
vdoPlayerUIFragment.setFullscreenActionListener(fullscreenToggleListener);
|
|
100
|
+
} catch(Exception e) {
|
|
101
|
+
e.printStackTrace();
|
|
102
|
+
}
|
|
95
103
|
}
|
|
96
|
-
vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
|
|
97
|
-
// initialize the playerFragment; a VdoPlayer instance will be received
|
|
98
|
-
// in onInitializationSuccess() callback
|
|
99
|
-
vdoPlayerUIFragment.initialize(initializationListener);
|
|
100
|
-
vdoPlayerUIFragment.setResizeMode(this.resizeMode);
|
|
101
104
|
}, 200);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
@@ -115,9 +118,16 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
115
118
|
vdoPlayer.stop();
|
|
116
119
|
}
|
|
117
120
|
if (fragmentManager != null && !fragmentManager.isDestroyed()) {
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
try {
|
|
122
|
+
Fragment fragment = fragmentManager.findFragmentById(vdoPlayerUIFragment.getId());
|
|
123
|
+
if (fragment != null) {
|
|
124
|
+
fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
125
|
+
}
|
|
126
|
+
} catch(IllegalStateException e) {
|
|
127
|
+
e.printStackTrace();
|
|
128
|
+
}
|
|
120
129
|
}
|
|
130
|
+
vdoPlayerUIFragment = null;
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
public void getPlaybackProperties() {
|
|
@@ -181,7 +191,20 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
181
191
|
};
|
|
182
192
|
activity.addOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
|
|
183
193
|
}
|
|
184
|
-
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private void setFullscreenActionListener() {
|
|
197
|
+
fullscreenToggleListener = isFullscreen -> {
|
|
198
|
+
|
|
199
|
+
if (isFullscreen) {
|
|
200
|
+
eventEmitter.enterFullscreen();
|
|
201
|
+
} else {
|
|
202
|
+
eventEmitter.exitFullscreen();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return false;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
185
208
|
|
|
186
209
|
public void setResizeMode(String resizeModeName) {
|
|
187
210
|
this.resizeMode = resizeModeIntFromName(resizeModeName);
|
|
@@ -356,14 +379,19 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
356
379
|
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
357
380
|
};
|
|
358
381
|
|
|
382
|
+
|
|
359
383
|
public void setFullscreen(boolean setFullscreen) {
|
|
360
|
-
if (
|
|
361
|
-
|
|
384
|
+
if (setFullscreen) {
|
|
385
|
+
vdoPlayerUIFragment.enterFullScreen();
|
|
362
386
|
} else {
|
|
363
|
-
|
|
387
|
+
vdoPlayerUIFragment.exitFullScreen();
|
|
364
388
|
}
|
|
365
389
|
}
|
|
366
390
|
|
|
391
|
+
public void setBackpressCalled() {
|
|
392
|
+
vdoPlayerUIFragment.setBackPressCalled();
|
|
393
|
+
}
|
|
394
|
+
|
|
367
395
|
// InitializationListener impl
|
|
368
396
|
|
|
369
397
|
PlayerHost.InitializationListener initializationListener = new PlayerHost.InitializationListener() {
|
|
@@ -473,16 +501,5 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
473
501
|
}
|
|
474
502
|
};
|
|
475
503
|
|
|
476
|
-
@Override
|
|
477
|
-
public void accept(Configuration configuration) {
|
|
478
|
-
int newOrientation = configuration.orientation;
|
|
479
504
|
|
|
480
|
-
if (newOrientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
481
|
-
vdoPlayerControlView.setFullscreenState(false);
|
|
482
|
-
eventEmitter.exitFullscreen();
|
|
483
|
-
} else if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
484
|
-
vdoPlayerControlView.setFullscreenState(true);
|
|
485
|
-
eventEmitter.enterFullscreen();
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
505
|
}
|
|
@@ -194,6 +194,11 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
194
194
|
vdoPlayerView.disableCaptions();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
@ReactProp(name = "backpressCalled")
|
|
198
|
+
public void setBackpressCalled(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
199
|
+
vdoPlayerView.setBackpressCalled();
|
|
200
|
+
}
|
|
201
|
+
|
|
197
202
|
public interface Listener {
|
|
198
203
|
void onVideoPlayerViewInitialised(ReactVdoPlayerUIView vdoPlayerView);
|
|
199
204
|
}
|
|
@@ -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;
|
|
@@ -88,13 +90,8 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
88
90
|
|
|
89
91
|
eventEmitter = new VdoEventEmitter(context);
|
|
90
92
|
|
|
91
|
-
int orientation = getResources().getConfiguration().orientation;
|
|
92
|
-
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
93
|
-
eventEmitter.isInitialPortrait();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
93
|
setPictureInPictureSupport();
|
|
97
|
-
|
|
94
|
+
audioFocusManager = new AudioFocusManager(activity, audioFocusChangeListener);
|
|
98
95
|
|
|
99
96
|
}
|
|
100
97
|
|
|
@@ -102,12 +99,17 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
102
99
|
if (vdoPlayerUIFragment != null) {
|
|
103
100
|
new Handler().postDelayed(() -> {
|
|
104
101
|
if (fragmentManager != null && !fragmentManager.isDestroyed()) {
|
|
105
|
-
|
|
102
|
+
try {
|
|
103
|
+
fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitAllowingStateLoss();
|
|
104
|
+
fragmentManager.executePendingTransactions();
|
|
105
|
+
// initialize the playerFragment; a VdoPlayer instance will be received
|
|
106
|
+
// in onInitializationSuccess() callback
|
|
107
|
+
vdoPlayerUIFragment.initialize(initializationListener);
|
|
108
|
+
vdoPlayerUIFragment.setResizeMode(this.resizeMode);
|
|
109
|
+
} catch(IllegalStateException e) {
|
|
110
|
+
e.printStackTrace();
|
|
111
|
+
}
|
|
106
112
|
}
|
|
107
|
-
// initialize the playerFragment; a VdoPlayer instance will be received
|
|
108
|
-
// in onInitializationSuccess() callback
|
|
109
|
-
vdoPlayerUIFragment.initialize(initializationListener);
|
|
110
|
-
vdoPlayerUIFragment.setResizeMode(this.resizeMode);
|
|
111
113
|
}, 200);
|
|
112
114
|
}
|
|
113
115
|
}
|
|
@@ -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
|
|
|
@@ -33,7 +33,6 @@ class VdoEventEmitter {
|
|
|
33
33
|
private static final String EVENT_PLAYBACK_PROPERTIES = "onVdoPlaybackProperties";
|
|
34
34
|
private static final String EVENT_ENTER_FULLSCREEN = "onVdoEnterFullscreen";
|
|
35
35
|
private static final String EVENT_EXIT_FULLSCREEN = "onVdoExitFullscreen";
|
|
36
|
-
private static final String EVENT_IS_INITIAL_PORTRAIT = "onIsInitialPortrait";
|
|
37
36
|
private static final String EVENT_PICTURE_IN_PICTURE_MODE_CHANGED ="onVdoPictureInPictureModeChanged";
|
|
38
37
|
|
|
39
38
|
|
|
@@ -47,7 +46,6 @@ class VdoEventEmitter {
|
|
|
47
46
|
EVENT_ERROR,
|
|
48
47
|
EVENT_PLAYBACK_PROPERTIES,
|
|
49
48
|
EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
|
|
50
|
-
EVENT_IS_INITIAL_PORTRAIT,
|
|
51
49
|
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED
|
|
52
50
|
};
|
|
53
51
|
|
|
@@ -61,7 +59,7 @@ class VdoEventEmitter {
|
|
|
61
59
|
EVENT_ERROR,
|
|
62
60
|
EVENT_PLAYBACK_PROPERTIES,
|
|
63
61
|
EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
|
|
64
|
-
|
|
62
|
+
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED})
|
|
65
63
|
@interface VdoEvent {}
|
|
66
64
|
|
|
67
65
|
private static final String EVENT_PROP_RESTORED = "restored";
|
|
@@ -77,7 +75,6 @@ class VdoEventEmitter {
|
|
|
77
75
|
private static final String EVENT_PROP_PLAY_WHEN_READY = "playWhenReady";
|
|
78
76
|
private static final String EVENT_PROP_PLAYER_STATE = "playerState";
|
|
79
77
|
private static final String EVENT_PROP_PLAYBACK_SPEED = "playbackSpeed";
|
|
80
|
-
private static final String EVENT_PROP_IS_INITIAL_PORTRAIT = "isInitialPortrait";
|
|
81
78
|
private static final String EVENT_PROP_IS_IN_PICTURE_IN_PICTURE_MODE = "isInPictureInPictureMode";
|
|
82
79
|
|
|
83
80
|
private static final String EVENT_PROP_ERROR_DESCRIPTION = "errorDescription";
|
|
@@ -197,12 +194,6 @@ class VdoEventEmitter {
|
|
|
197
194
|
receiveEvent(EVENT_PLAYBACK_PROPERTIES, event);
|
|
198
195
|
}
|
|
199
196
|
|
|
200
|
-
void isInitialPortrait() {
|
|
201
|
-
WritableMap event = Arguments.createMap();
|
|
202
|
-
event.putBoolean(EVENT_PROP_IS_INITIAL_PORTRAIT, true);
|
|
203
|
-
receiveEvent(EVENT_IS_INITIAL_PORTRAIT, event);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
197
|
private void receiveEvent(@VdoEvent String type, WritableMap event) {
|
|
207
198
|
eventEmitter.receiveEvent(viewId, type, event);
|
|
208
199
|
}
|
|
@@ -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.16.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",
|
package/type.ts
CHANGED
|
@@ -126,7 +126,6 @@ export const VdoPropTypes = {
|
|
|
126
126
|
fullscreen: PropTypes.bool,
|
|
127
127
|
onVdoEnterFullscreen: PropTypes.func,
|
|
128
128
|
onVdoExitFullscreen: PropTypes.func,
|
|
129
|
-
onIsInitialPortrait: PropTypes.func,
|
|
130
129
|
onVdoPictureInPictureModeChanged: PropTypes.func,
|
|
131
130
|
|
|
132
131
|
/* Wrapper component public api */
|