vdocipher-rn-bridge 1.9.1 → 1.10.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 +16 -0
- package/VdoPlayerSupportView.js +226 -0
- package/VdoPlayerUIView.js +271 -0
- package/VdoPlayerView.js +265 -202
- package/android/build.gradle +4 -5
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +306 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +156 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +200 -61
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +34 -38
- package/android/src/main/java/com/vdocipher/rnbridge/Utils.java +8 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdoDownloadModule.java +6 -5
- package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +22 -2
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgePackage.java +2 -1
- package/android/src/main/res/layout/activity_vdo_player_ui.xml +12 -0
- package/android/src/main/res/layout/activity_vdo_player_ui_custom.xml +12 -0
- package/downloadMonitor.js +2 -2
- package/package.json +4 -2
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
4
|
+
import androidx.core.util.Consumer;
|
|
5
|
+
import androidx.fragment.app.FragmentManager;
|
|
6
|
+
|
|
7
|
+
import android.content.res.Configuration;
|
|
8
|
+
import android.util.Log;
|
|
9
|
+
import android.view.KeyEvent;
|
|
10
|
+
import android.view.ViewGroup;
|
|
11
|
+
import android.widget.FrameLayout;
|
|
12
|
+
import android.content.pm.ActivityInfo;
|
|
13
|
+
import android.view.LayoutInflater;
|
|
14
|
+
|
|
15
|
+
import com.facebook.react.bridge.LifecycleEventListener;
|
|
16
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
17
|
+
import com.vdocipher.aegis.media.ErrorDescription;
|
|
18
|
+
import com.vdocipher.aegis.media.Track;
|
|
19
|
+
import com.vdocipher.aegis.player.VdoPlayer;
|
|
20
|
+
import com.vdocipher.aegis.player.PlayerHost;
|
|
21
|
+
import com.vdocipher.aegis.player.VdoInitParams;
|
|
22
|
+
import com.vdocipher.aegis.ui.view.VdoPlayerControlView;
|
|
23
|
+
import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
|
|
27
|
+
private static final String TAG = "ReactVdoPlayerUIView";
|
|
28
|
+
|
|
29
|
+
private final ThemedReactContext themedReactContext;
|
|
30
|
+
private final VdoEventEmitter eventEmitter;
|
|
31
|
+
private VdoPlayerUIFragment vdoPlayerUIFragment;
|
|
32
|
+
private VdoPlayerControlView vdoPlayerControlView;
|
|
33
|
+
|
|
34
|
+
private VdoPlayer vdoPlayer;
|
|
35
|
+
|
|
36
|
+
// from props
|
|
37
|
+
private boolean playWhenReady = true;
|
|
38
|
+
private float pendingPlaybackSpeed = 0;
|
|
39
|
+
|
|
40
|
+
private VdoInitParams vdoParams;
|
|
41
|
+
private AppCompatActivity activity;
|
|
42
|
+
|
|
43
|
+
public ReactVdoPlayerUIView(ThemedReactContext context) {
|
|
44
|
+
super(context);
|
|
45
|
+
themedReactContext = context;
|
|
46
|
+
activity = (AppCompatActivity) themedReactContext.getCurrentActivity();
|
|
47
|
+
|
|
48
|
+
context.addLifecycleEventListener(this);
|
|
49
|
+
activity.addOnConfigurationChangedListener(this);
|
|
50
|
+
|
|
51
|
+
eventEmitter = new VdoEventEmitter(context);
|
|
52
|
+
|
|
53
|
+
LayoutInflater.from(context).inflate(R.layout.activity_vdo_player_ui, this);
|
|
54
|
+
|
|
55
|
+
vdoPlayerUIFragment = (VdoPlayerUIFragment) activity.getSupportFragmentManager().findFragmentById(R.id.online_vdo_player_ui_fragment);
|
|
56
|
+
initializePlayer();
|
|
57
|
+
|
|
58
|
+
int orientation = getResources().getConfiguration().orientation;
|
|
59
|
+
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
60
|
+
eventEmitter.isInitialPortrait();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private void initializePlayer() {
|
|
66
|
+
if (vdoPlayerUIFragment != null) {
|
|
67
|
+
// initialize the playerFragment; a VdoPlayer instance will be received
|
|
68
|
+
// in onInitializationSuccess() callback
|
|
69
|
+
vdoPlayerUIFragment.initialize(initializationListener);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Clean up all resources, references to this instance which may prevent it from being GC'ed.
|
|
76
|
+
*/
|
|
77
|
+
public void cleanUp() {
|
|
78
|
+
themedReactContext.removeLifecycleEventListener(this);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public void getPlaybackProperties() {
|
|
82
|
+
if (vdoPlayer != null) {
|
|
83
|
+
Object tp = vdoPlayer.getPlaybackProperty("totalPlayed");
|
|
84
|
+
long totalPlayed = (tp instanceof Long) ? (long)tp : 0L;
|
|
85
|
+
Object tc = vdoPlayer.getPlaybackProperty("totalCovered");
|
|
86
|
+
long totalCovered = (tc instanceof Long) ? (long)tc : 0L;
|
|
87
|
+
eventEmitter.playbackProperties(totalPlayed, totalCovered);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public void setPlayWhenReady(boolean playWhenReady) {
|
|
92
|
+
this.playWhenReady = playWhenReady;
|
|
93
|
+
if (vdoPlayer != null) {
|
|
94
|
+
vdoPlayer.setPlayWhenReady(playWhenReady);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public void setPlaybackSpeed(float playbackSpeed) {
|
|
99
|
+
this.pendingPlaybackSpeed = playbackSpeed;
|
|
100
|
+
if (vdoPlayer != null) {
|
|
101
|
+
vdoPlayer.setPlaybackSpeed(playbackSpeed);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public void seekTo(int targetMs) {
|
|
106
|
+
if (vdoPlayer != null) {
|
|
107
|
+
vdoPlayer.seekTo(targetMs);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public void setKeyDownEvent(KeyEvent event) {
|
|
112
|
+
if (! vdoPlayerControlView.controllerVisible()) {
|
|
113
|
+
vdoPlayerControlView.onKeyDown(event.getKeyCode(), event);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public void setPictureInPictureSupport() {
|
|
118
|
+
if (vdoPlayerUIFragment != null) {
|
|
119
|
+
vdoPlayerUIFragment.setPictureInPictureSupport(true);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Override
|
|
124
|
+
public void setId(int id) {
|
|
125
|
+
super.setId(id);
|
|
126
|
+
eventEmitter.setViewId(id);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@Override
|
|
130
|
+
protected void onAttachedToWindow() {
|
|
131
|
+
Log.d(TAG, "onAttachedToWindow");
|
|
132
|
+
super.onAttachedToWindow();
|
|
133
|
+
vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.player_control_view);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
protected void onDetachedFromWindow() {
|
|
138
|
+
Log.d(TAG, "onDetachedFromWindow");
|
|
139
|
+
FragmentManager fragmentManager = this.activity.getSupportFragmentManager();
|
|
140
|
+
if (fragmentManager != null && !fragmentManager.isDestroyed()) {
|
|
141
|
+
fragmentManager.beginTransaction().remove(vdoPlayerUIFragment).commitNow();
|
|
142
|
+
}
|
|
143
|
+
super.onDetachedFromWindow();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
// LifecycleEventListener impl
|
|
148
|
+
|
|
149
|
+
@Override
|
|
150
|
+
public void onHostResume() {
|
|
151
|
+
Log.d(TAG, "onHostResume");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Override
|
|
155
|
+
public void onHostPause() {
|
|
156
|
+
Log.d(TAG, "onHostPause");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@Override
|
|
160
|
+
public void onHostDestroy() {
|
|
161
|
+
Log.d(TAG, "onHostDestroy");
|
|
162
|
+
// this will probably never be called if the view is not on the first route into app;
|
|
163
|
+
// already unregistered as a lifecycle listener
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@Override
|
|
167
|
+
public void requestLayout() {
|
|
168
|
+
super.requestLayout();
|
|
169
|
+
post(measureAndLayout);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private final Runnable measureAndLayout = () -> {
|
|
173
|
+
measure(
|
|
174
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
175
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
176
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
public void setFullscreen(boolean setFullscreen) {
|
|
180
|
+
if (!setFullscreen) {
|
|
181
|
+
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
|
182
|
+
} else {
|
|
183
|
+
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// InitializationListener impl
|
|
188
|
+
|
|
189
|
+
PlayerHost.InitializationListener initializationListener = new PlayerHost.InitializationListener() {
|
|
190
|
+
@Override
|
|
191
|
+
public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
|
|
192
|
+
Log.d(TAG, "init success");
|
|
193
|
+
vdoPlayer = player;
|
|
194
|
+
vdoPlayer.addPlaybackEventListener(playbackListener);
|
|
195
|
+
|
|
196
|
+
eventEmitter.initSuccess(restored);
|
|
197
|
+
|
|
198
|
+
// load pending params
|
|
199
|
+
if (vdoParams != null) {
|
|
200
|
+
Log.d(TAG, "load pending params");
|
|
201
|
+
load(vdoParams);
|
|
202
|
+
vdoParams = null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@Override
|
|
207
|
+
public void onInitializationFailure(PlayerHost playerHost, ErrorDescription errorDescription) {
|
|
208
|
+
String msg = "onInitializationFailure: errorCode = " + errorDescription.errorCode + ": " + errorDescription.errorMsg;
|
|
209
|
+
Log.e(TAG, msg);
|
|
210
|
+
eventEmitter.initFailure(errorDescription);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
public void load(VdoInitParams params) {
|
|
215
|
+
if (vdoPlayer != null && params != null) {
|
|
216
|
+
vdoPlayer.load(params);
|
|
217
|
+
} else {
|
|
218
|
+
vdoParams = params;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.PlaybackEventListener() {
|
|
223
|
+
@Override
|
|
224
|
+
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
|
225
|
+
eventEmitter.playerStateChanged(playWhenReady, playbackState);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@Override
|
|
229
|
+
public void onTracksChanged(Track[] availableTracks, Track[] selectedTracks) {
|
|
230
|
+
Log.i(TAG, "onTracksChanged");
|
|
231
|
+
eventEmitter.tracksChanged(availableTracks, selectedTracks);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@Override
|
|
235
|
+
public void onBufferUpdate(long bufferTimeMs) {
|
|
236
|
+
eventEmitter.bufferUpdate(bufferTimeMs);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@Override
|
|
240
|
+
public void onSeekTo(long timeMs) {
|
|
241
|
+
Log.i(TAG, "onSeekTo: " + timeMs);
|
|
242
|
+
eventEmitter.seekTo(timeMs);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@Override
|
|
246
|
+
public void onProgress(long timeMs) {
|
|
247
|
+
eventEmitter.progress(timeMs);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@Override
|
|
251
|
+
public void onPlaybackSpeedChanged(float speed) {
|
|
252
|
+
Log.i(TAG, "onPlaybackSpeedChanged " + speed);
|
|
253
|
+
eventEmitter.speedChanged(speed);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@Override
|
|
257
|
+
public void onLoading(VdoInitParams vdoInitParams) {
|
|
258
|
+
Log.i(TAG, "onLoading");
|
|
259
|
+
eventEmitter.loading(vdoInitParams);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@Override
|
|
263
|
+
public void onLoadError(VdoInitParams vdoInitParams, ErrorDescription errorDescription) {
|
|
264
|
+
String err = "onLoadError code: " + errorDescription.errorCode + ": " + errorDescription.errorMsg;
|
|
265
|
+
Log.e(TAG, err);
|
|
266
|
+
eventEmitter.loadError(vdoInitParams, errorDescription);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@Override
|
|
270
|
+
public void onLoaded(VdoInitParams vdoInitParams) {
|
|
271
|
+
Log.i(TAG, "onLoaded");
|
|
272
|
+
vdoPlayer.setPlayWhenReady(playWhenReady);
|
|
273
|
+
if (pendingPlaybackSpeed > 0) {
|
|
274
|
+
vdoPlayer.setPlaybackSpeed(pendingPlaybackSpeed);
|
|
275
|
+
pendingPlaybackSpeed = 0;
|
|
276
|
+
}
|
|
277
|
+
eventEmitter.loaded(vdoInitParams, vdoPlayer.getCurrentMedia());
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@Override
|
|
281
|
+
public void onError(VdoInitParams vdoInitParams, ErrorDescription errorDescription) {
|
|
282
|
+
String err = "onError code " + errorDescription.errorCode + ": " + errorDescription.errorMsg;
|
|
283
|
+
Log.e(TAG, err);
|
|
284
|
+
eventEmitter.error(vdoInitParams, errorDescription);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@Override
|
|
288
|
+
public void onMediaEnded(VdoInitParams vdoInitParams) {
|
|
289
|
+
Log.i(TAG, "onMediaEnded");
|
|
290
|
+
eventEmitter.mediaEnded(vdoInitParams);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
@Override
|
|
295
|
+
public void accept(Configuration configuration) {
|
|
296
|
+
int newOrientation = configuration.orientation;
|
|
297
|
+
|
|
298
|
+
if (newOrientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
299
|
+
vdoPlayerControlView.setFullscreenState(false);
|
|
300
|
+
eventEmitter.exitFullscreen();
|
|
301
|
+
} else if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
302
|
+
vdoPlayerControlView.setFullscreenState(true);
|
|
303
|
+
eventEmitter.enterFullscreen();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
import android.view.KeyEvent;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
+
import com.facebook.react.common.MapBuilder;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
10
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
11
|
+
import com.vdocipher.aegis.player.VdoInitParams;
|
|
12
|
+
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
|
|
15
|
+
import javax.annotation.Nullable;
|
|
16
|
+
|
|
17
|
+
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
18
|
+
|
|
19
|
+
public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayerUIView> {
|
|
20
|
+
private static final String TAG = "RctVdoPlayerUIViewMngr";
|
|
21
|
+
|
|
22
|
+
private static final String REACT_CLASS = "RCTVdoPlayerUIView";
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public String getName() {
|
|
26
|
+
return REACT_CLASS;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public ReactVdoPlayerUIView createViewInstance(ThemedReactContext context) {
|
|
31
|
+
ReactVdoPlayerUIView playerView = new ReactVdoPlayerUIView(context);
|
|
32
|
+
Log.d(TAG, "created " + playerView.toString());
|
|
33
|
+
return playerView;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Nullable
|
|
37
|
+
@Override
|
|
38
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
39
|
+
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
40
|
+
for (String event : VdoEventEmitter.EVENTS) {
|
|
41
|
+
builder.put(event, MapBuilder.of("registrationName", event));
|
|
42
|
+
}
|
|
43
|
+
return builder.build();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
public void onDropViewInstance(ReactVdoPlayerUIView view) {
|
|
48
|
+
Log.d(TAG, "dropped " + view.toString());
|
|
49
|
+
view.cleanUp();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactProp(name = "embedInfo")
|
|
53
|
+
public void setEmbedInfo(ReactVdoPlayerUIView vdoPlayerView, @Nullable ReadableMap embedInfo) {
|
|
54
|
+
if (embedInfo != null) {
|
|
55
|
+
boolean offline = embedInfo.hasKey("offline") && embedInfo.getBoolean("offline");
|
|
56
|
+
final VdoInitParams initParams;
|
|
57
|
+
boolean enableAutoResume = embedInfo.hasKey("enableAutoResume") && embedInfo.getBoolean("enableAutoResume");
|
|
58
|
+
String preferredCaptionsLanguage = embedInfo.hasKey("preferredCaptionsLanguage") ?
|
|
59
|
+
embedInfo.getString("preferredCaptionsLanguage") : null;
|
|
60
|
+
String playerConfig = embedInfo.hasKey("playerConfig") ?
|
|
61
|
+
embedInfo.getString("playerConfig") : null;
|
|
62
|
+
String safetyNetApiKey = embedInfo.hasKey("safetyNetApiKey") ?
|
|
63
|
+
embedInfo.getString("safetyNetApiKey") : null;
|
|
64
|
+
boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
|
|
65
|
+
embedInfo.getBoolean("allowAdbDebugging");
|
|
66
|
+
boolean setPictureInPictureSupport = embedInfo.hasKey("setPictureInPictureSupport") && embedInfo.getBoolean("setPictureInPictureSupport");
|
|
67
|
+
|
|
68
|
+
VdoInitParams.Builder builder = new VdoInitParams.Builder();
|
|
69
|
+
|
|
70
|
+
if (enableAutoResume) {
|
|
71
|
+
builder.enableAutoResume();
|
|
72
|
+
}
|
|
73
|
+
if (safetyNetApiKey != null) {
|
|
74
|
+
builder.setSafetyNetApiKey(safetyNetApiKey);
|
|
75
|
+
}
|
|
76
|
+
if (playerConfig != null) {
|
|
77
|
+
builder.setPlayerConfig(playerConfig);
|
|
78
|
+
}
|
|
79
|
+
if (preferredCaptionsLanguage != null) {
|
|
80
|
+
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (offline) {
|
|
84
|
+
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
85
|
+
|
|
86
|
+
builder.setOfflinePlayback(mediaId)
|
|
87
|
+
.setAllowAdbDebugging(allowAdbDebugging);
|
|
88
|
+
|
|
89
|
+
} else {
|
|
90
|
+
String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
|
|
91
|
+
String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
|
|
92
|
+
boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
|
|
93
|
+
&& embedInfo.getBoolean("forceLowestBitrate");
|
|
94
|
+
boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
|
|
95
|
+
&& embedInfo.getBoolean("forceHighestSupportedBitrate");
|
|
96
|
+
int maxVideoBitrateKbps = embedInfo.hasKey("maxVideoBitrateKbps") ?
|
|
97
|
+
embedInfo.getInt("maxVideoBitrateKbps") : Integer.MAX_VALUE;
|
|
98
|
+
int bufferingGoalMs = embedInfo.hasKey("bufferingGoalMs") ?
|
|
99
|
+
embedInfo.getInt("bufferingGoalMs") : 0;
|
|
100
|
+
String[] overrides = getTechOverride(embedInfo);
|
|
101
|
+
|
|
102
|
+
builder.setOtp(otp)
|
|
103
|
+
.setPlaybackInfo(playbackInfo)
|
|
104
|
+
.setAllowAdbDebugging(allowAdbDebugging)
|
|
105
|
+
.setForceLowestBitrate(forceLowestBitrate)
|
|
106
|
+
.setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
|
|
107
|
+
.setMaxVideoBitrateKbps(maxVideoBitrateKbps);
|
|
108
|
+
|
|
109
|
+
if (bufferingGoalMs > 0) {
|
|
110
|
+
builder.setBufferingGoalMs(bufferingGoalMs);
|
|
111
|
+
}
|
|
112
|
+
if (overrides != null) {
|
|
113
|
+
builder.setTechOverride(overrides);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
initParams = builder.build();
|
|
118
|
+
|
|
119
|
+
if (setPictureInPictureSupport) {
|
|
120
|
+
vdoPlayerView.setPictureInPictureSupport();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
vdoPlayerView.load(initParams);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@ReactProp(name = "playWhenReady", defaultBoolean = true)
|
|
128
|
+
public void setPlayWhenReady(ReactVdoPlayerUIView vdoPlayerView, boolean playWhenReady) {
|
|
129
|
+
vdoPlayerView.setPlayWhenReady(playWhenReady);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@ReactProp(name = "playbackSpeed", defaultFloat = 1f)
|
|
133
|
+
public void setPlaybackSpeed(ReactVdoPlayerUIView vdoPlayerView, float playbackSpeed) {
|
|
134
|
+
vdoPlayerView.setPlaybackSpeed(playbackSpeed);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@ReactProp(name = "seek")
|
|
138
|
+
public void setSeek(ReactVdoPlayerUIView vdoPlayerView, final int targetMs) {
|
|
139
|
+
vdoPlayerView.seekTo(targetMs);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@ReactProp(name = "fullscreen", defaultBoolean = false)
|
|
143
|
+
public void setFullscreen(ReactVdoPlayerUIView vdoPlayerView, boolean fullscreen) {
|
|
144
|
+
vdoPlayerView.setFullscreen(fullscreen);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@ReactProp(name = "playbackProperties")
|
|
148
|
+
public void getPlaybackProperties(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
149
|
+
vdoPlayerView.getPlaybackProperties();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@ReactProp(name = "keyDownEvent")
|
|
153
|
+
public void setKeyDownEvent(ReactVdoPlayerUIView vdoPlayerView, ReadableMap eventMap) {
|
|
154
|
+
vdoPlayerView.setKeyDownEvent(new KeyEvent(eventMap.getInt("action"), eventMap.getInt("code")));
|
|
155
|
+
}
|
|
156
|
+
}
|