vdocipher-rn-bridge 1.10.1 → 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 +8 -0
- package/README.md +26 -7
- package/VdoPlayerSupportView.js +3 -2
- package/VdoPlayerView.js +0 -8
- package/android/build.gradle +5 -5
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +33 -9
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +83 -46
- package/package.json +1 -1
- package/android/src/main/res/layout/activity_vdo_player_ui.xml +0 -12
- package/android/src/main/res/layout/activity_vdo_player_ui_custom.xml +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
## Changelog
|
|
2
|
+
|
|
3
|
+
### 1.11.0
|
|
4
|
+
* Updated VdoCipher android sdk dependency to 1.19.0
|
|
5
|
+
|
|
6
|
+
### 1.10.2
|
|
7
|
+
* Updated VdoCipher android sdk dependency to 1.18.2
|
|
8
|
+
* Updated compileSdkVersion to 33 and targetSdkVersion to 32
|
|
9
|
+
|
|
2
10
|
### 1.10.1
|
|
3
11
|
* Updated VdoCipher android sdk dependency to 1.18.1
|
|
4
12
|
* Updated player with built-in controls to use Player-UI provided by native sdk
|
package/README.md
CHANGED
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
## Note:
|
|
6
6
|
|
|
7
|
-
1.
|
|
8
|
-
using it in your application
|
|
9
|
-
2. IOS is not supported. Only Android support available. IOS support will be
|
|
7
|
+
1. IOS is not supported. Only Android support available. IOS support will be
|
|
10
8
|
added in future.
|
|
11
|
-
|
|
9
|
+
2. Currently, it is not possible to get any events or callbacks from Android
|
|
12
10
|
player activity. The video will open in a new _native_ activity outside of
|
|
13
11
|
the react native setup. Back button will take the user from the player
|
|
14
12
|
activity to home activity.
|
|
@@ -77,6 +75,8 @@ development machine, and run the example app:
|
|
|
77
75
|
|
|
78
76
|
## Usage
|
|
79
77
|
|
|
78
|
+
For detailed usage of the library, refer the link [here.](https://www.vdocipher.com/docs/mobile/react-native/getting-started)
|
|
79
|
+
|
|
80
80
|
### Launch a video in a fullscreen player
|
|
81
81
|
|
|
82
82
|
```javascript
|
|
@@ -124,9 +124,11 @@ const embedInfo = {otp: 'some-otp', playbackInfo: 'some-playbackInfo'};
|
|
|
124
124
|
* [onEnterFullscreen](#onenterfullscreen)
|
|
125
125
|
* [onExitFullscreen](#onexitfullscreen)
|
|
126
126
|
* [onPlaybackProperties](#onplaybackproperties)
|
|
127
|
+
* [onPictureInPictureModeChanged](#onPictureInPictureModeChanged)
|
|
127
128
|
|
|
128
129
|
### VdoPlayerView methods
|
|
129
130
|
|
|
131
|
+
* [seek](#seek)
|
|
130
132
|
* [enterFullscreen](#enterfullscreen)
|
|
131
133
|
* [exitFullscreen](#exitfullscreen)
|
|
132
134
|
* [getPlaybackProperties](#getplaybackproperties)
|
|
@@ -139,11 +141,15 @@ Property | Type | Description
|
|
|
139
141
|
--- | --- | ---
|
|
140
142
|
otp | string | a valid otp
|
|
141
143
|
playbackInfo | string | a valid playbackInfo
|
|
142
|
-
forceLowestBitrate | boolean | whether to force lowest bitrate; default false
|
|
143
|
-
forceHighestSupportedBitrate | boolean | whether to force highest supported bitrate; default false
|
|
144
|
+
forceLowestBitrate | boolean | whether to force lowest bitrate; default: `false`
|
|
145
|
+
forceHighestSupportedBitrate | boolean | whether to force highest supported bitrate; default: `false`
|
|
144
146
|
maxVideoBitrateKbps | number | maximum allowed video bitrate in kbps
|
|
145
147
|
bufferingGoalMs | number | buffering goal in milliseconds, NOT recommended to change this value for most use cases; cannot be set to a value less than 15000
|
|
146
|
-
enableAutoResume | boolean | whether to auto resume from last saved position
|
|
148
|
+
enableAutoResume | boolean | whether to auto resume from last saved position or play from the beginning, default: `false`.
|
|
149
|
+
safetyNetApiKey | string | safetynet api key to be used for safetynet verification
|
|
150
|
+
preferredCaptionsLanguage | string | language code for the preferred captions language
|
|
151
|
+
playerConfig | string | player configuration id from dashboard to be used for player
|
|
152
|
+
setPictureInPictureSupport | boolean | whether to enable picture in picture support, default: `false`.
|
|
147
153
|
|
|
148
154
|
#### showNativeControls
|
|
149
155
|
|
|
@@ -305,6 +311,15 @@ Callback function invoked when the player exits fullscreen.
|
|
|
305
311
|
#### onPlaybackProperties
|
|
306
312
|
Callback function invoked when additional playback properties are requested using the `getPlaybackProperties` method.
|
|
307
313
|
|
|
314
|
+
#### onPictureInPictureModeChanged
|
|
315
|
+
Callback function invoked to handle UI when the player enters or exits pip mode
|
|
316
|
+
|
|
317
|
+
Payload:
|
|
318
|
+
|
|
319
|
+
Property | Type | Description
|
|
320
|
+
--- | --- | ---
|
|
321
|
+
isInPictureInPictureMode | boolean | is player in pip mode
|
|
322
|
+
|
|
308
323
|
### Methods
|
|
309
324
|
|
|
310
325
|
Methods operate on a ref to the VdoPlayerView element. You can create a ref like this:
|
|
@@ -312,6 +327,10 @@ Methods operate on a ref to the VdoPlayerView element. You can create a ref like
|
|
|
312
327
|
<VdoPlayerView ref={player => this._player = player}
|
|
313
328
|
```
|
|
314
329
|
|
|
330
|
+
#### seek
|
|
331
|
+
`seek(seekTargetMs)`
|
|
332
|
+
Set the seek target in milli seconds
|
|
333
|
+
|
|
315
334
|
#### enterFullscreen
|
|
316
335
|
`enterFullscreen()`
|
|
317
336
|
|
package/VdoPlayerSupportView.js
CHANGED
|
@@ -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
|
-
|
|
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,
|
package/android/build.gradle
CHANGED
|
@@ -18,15 +18,15 @@ 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.11.0"
|
|
22
|
+
def releaseVersionCode = 10
|
|
23
23
|
|
|
24
24
|
android {
|
|
25
|
-
compileSdkVersion
|
|
25
|
+
compileSdkVersion 33
|
|
26
26
|
|
|
27
27
|
defaultConfig {
|
|
28
28
|
minSdkVersion 18
|
|
29
|
-
targetSdkVersion
|
|
29
|
+
targetSdkVersion 32
|
|
30
30
|
|
|
31
31
|
// Generate BuildConfig fields for library version info
|
|
32
32
|
buildConfigField "int", "VDO_VERSION_CODE", "${releaseVersionCode}"
|
|
@@ -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.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 =
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
140
|
-
|
|
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.
|
|
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
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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 (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
282
|
-
|
|
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
|
-
|
|
344
|
+
public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
|
|
312
345
|
Log.d(TAG, "init success");
|
|
313
|
-
|
|
314
|
-
vdoPlayer.addPlaybackEventListener(
|
|
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,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>
|