vdocipher-rn-bridge 1.22.6 → 2.0.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/VdoPlayerSupportView.tsx +12 -70
- package/VdoPlayerUIView.tsx +29 -90
- package/VdoPlayerView.tsx +36 -73
- package/android/build.gradle +23 -4
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/vdocipher/rnbridge/PlayerViewRegistry.java +34 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +7 -11
- package/android/src/main/java/com/vdocipher/rnbridge/{ReactVdoPlayerUIViewManager.java → ReactVdoPlayerUIViewManagerImpl.java} +66 -80
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +8 -12
- package/android/src/main/java/com/vdocipher/rnbridge/{ReactVdoPlayerViewManager.java → ReactVdoPlayerViewManagerImpl.java} +61 -75
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModuleImpl.java +64 -0
- package/android/src/main/java/com/vdocipher/rnbridge/Utils.java +27 -0
- package/android/src/main/java/com/vdocipher/rnbridge/{VdoDownloadModule.java → VdoDownloadModuleImpl.java} +23 -50
- package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +51 -17
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerModuleImpl.java +28 -0
- package/android/src/main/java/com/vdocipher/rnbridge/{VdoPlayerSettingsModule.java → VdoPlayerSettingsModuleImpl.java} +3 -8
- package/android/src/main/java/com/vdocipher/rnbridge/{VdoPreCacheManagerModule.java → VdoPreCacheManagerModuleImpl.java} +3 -10
- package/android/src/main/java/com/vdocipher/rnbridge/{VdocipherRnBridgeModule.java → VdocipherRnBridgeModuleImpl.java} +5 -16
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgePackage.java +13 -27
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +195 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +174 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/TrackSelectionModule.java +61 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoDownloadModule.java +129 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPlayerModule.java +29 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPlayerSettingsModule.java +42 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPreCacheManagerModule.java +43 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +44 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +114 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +109 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/TrackSelectionModule.java +59 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoDownloadModule.java +132 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPlayerModule.java +29 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPlayerSettingsModule.java +40 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPreCacheManagerModule.java +40 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +40 -0
- package/downloads.ts +5 -5
- package/ios/AssetList.swift +27 -0
- package/ios/RCTVdoPlayerUIView.h +4 -4
- package/ios/RCTVdoPlayerUIView.swift +2 -1
- package/ios/RCTVdoPlayerUIViewComponentView.mm +127 -0
- package/ios/RCTVdoPlayerView.swift +1 -0
- package/ios/RCTVdoPlayerViewComponentView.mm +127 -0
- package/ios/VdoCipherRNView.h +16 -3
- package/ios/VdoCipherRNView.swift +45 -9
- package/ios/VdoDownload.swift +74 -76
- package/ios/VdoPlayerCommandDispatch.h +52 -0
- package/ios/VdoPreCacheManager.swift +1 -1
- package/ios/VdocipherRnBridgeViewManager.mm +234 -0
- package/ios/VdocipherRnBridgeViewManager.swift +4 -4
- package/package.json +46 -3
- package/react-native-vdocipher-rn-bridge.podspec +1 -1
- package/specs/NativeTrackSelection.ts +38 -0
- package/specs/NativeVdoDownload.ts +76 -0
- package/specs/NativeVdoEventEmitter.ts +12 -0
- package/specs/NativeVdoPlayer.ts +11 -0
- package/specs/NativeVdoPlayerSettings.ts +13 -0
- package/specs/NativeVdoPreCacheManager.ts +12 -0
- package/specs/NativeVdocipherRnBridge.ts +11 -0
- package/specs/RCTVdoPlayerUIViewNativeComponent.ts +93 -0
- package/specs/RCTVdoPlayerViewNativeComponent.ts +84 -0
- package/tsconfig.json +1 -1
- package/type.ts +84 -90
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModule.java +0 -126
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerModule.java +0 -54
- package/ios/VdocipherRnBridgeViewManager.m +0 -126
|
@@ -6,47 +6,40 @@ import android.view.KeyEvent;
|
|
|
6
6
|
import com.facebook.react.bridge.ReadableMap;
|
|
7
7
|
import com.facebook.react.common.MapBuilder;
|
|
8
8
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
-
import com.facebook.react.uimanager.ViewGroupManager;
|
|
10
|
-
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
11
9
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
12
10
|
import android.graphics.Color;
|
|
13
11
|
|
|
12
|
+
import org.json.JSONException;
|
|
13
|
+
|
|
14
14
|
import java.util.Map;
|
|
15
15
|
|
|
16
16
|
import javax.annotation.Nullable;
|
|
17
|
-
import java.util.concurrent.CopyOnWriteArraySet;
|
|
18
17
|
|
|
19
18
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
19
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
20
20
|
|
|
21
|
-
public class
|
|
21
|
+
public class ReactVdoPlayerUIViewManagerImpl {
|
|
22
22
|
private static final String TAG = "RctVdoPlayerUIViewMngr";
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
public static final String REACT_CLASS = "RCTVdoPlayerUIView";
|
|
25
|
+
public static final String NEW_ARCH_REACT_CLASS = "VdoPlayerUIView";
|
|
26
|
+
|
|
27
|
+
public static final String NAME = "RctVdoPlayerUIViewMngr";
|
|
25
28
|
|
|
26
|
-
private
|
|
27
|
-
private CopyOnWriteArraySet<Listener> listeners = new CopyOnWriteArraySet<>();
|
|
29
|
+
private final PlayerViewRegistry registry;
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return REACT_CLASS;
|
|
31
|
+
public ReactVdoPlayerUIViewManagerImpl(PlayerViewRegistry registry) {
|
|
32
|
+
this.registry = registry;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
@Override
|
|
35
35
|
public ReactVdoPlayerUIView createViewInstance(ThemedReactContext context) {
|
|
36
|
-
playerView = new ReactVdoPlayerUIView(context);
|
|
36
|
+
ReactVdoPlayerUIView playerView = new ReactVdoPlayerUIView(context);
|
|
37
37
|
Log.d(TAG, "created " + playerView.toString());
|
|
38
|
-
|
|
39
|
-
listener.onVideoPlayerViewInitialised(playerView);
|
|
40
|
-
}
|
|
38
|
+
registry.setPlayerUIView(playerView);
|
|
41
39
|
return playerView;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
public void addListener(Listener listener) {
|
|
45
|
-
listeners.add(listener);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
42
|
@Nullable
|
|
49
|
-
@Override
|
|
50
43
|
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
51
44
|
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
52
45
|
for (String event : VdoEventEmitter.EVENTS) {
|
|
@@ -55,13 +48,62 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
55
48
|
return builder.build();
|
|
56
49
|
}
|
|
57
50
|
|
|
58
|
-
@Override
|
|
59
51
|
public void onDropViewInstance(ReactVdoPlayerUIView view) {
|
|
60
52
|
Log.d(TAG, "dropped " + view.toString());
|
|
61
53
|
view.cleanUp();
|
|
54
|
+
registry.clearPlayerUIView(view);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public void receiveCommand(
|
|
58
|
+
ReactVdoPlayerUIView view,
|
|
59
|
+
String commandId,
|
|
60
|
+
@Nullable ReadableArray args
|
|
61
|
+
) {
|
|
62
|
+
switch (commandId) {
|
|
63
|
+
case "play":
|
|
64
|
+
view.setPlayWhenReady(true);
|
|
65
|
+
break;
|
|
66
|
+
case "pause":
|
|
67
|
+
view.setPlayWhenReady(false);
|
|
68
|
+
break;
|
|
69
|
+
case "seek":
|
|
70
|
+
int targetMs = args.getInt(0);
|
|
71
|
+
view.seekTo(targetMs);
|
|
72
|
+
break;
|
|
73
|
+
case "enterFullscreen":
|
|
74
|
+
view.setFullscreen(true);
|
|
75
|
+
break;
|
|
76
|
+
case "exitFullscreen":
|
|
77
|
+
view.setFullscreen(false);
|
|
78
|
+
break;
|
|
79
|
+
case "playbackSpeed":
|
|
80
|
+
float speed = (float) args.getDouble(0);
|
|
81
|
+
view.setPlaybackSpeed(speed);
|
|
82
|
+
break;
|
|
83
|
+
case "handleBackPress":
|
|
84
|
+
view.setBackpressCalled();
|
|
85
|
+
break;
|
|
86
|
+
case "keyDownEvent":
|
|
87
|
+
ReadableMap eventMap = args.getMap(0);
|
|
88
|
+
view.setKeyDownEvent(new KeyEvent(eventMap.getInt("action"), eventMap.getInt("code")));
|
|
89
|
+
break;
|
|
90
|
+
case "disableCaptions":
|
|
91
|
+
view.disableCaptions();
|
|
92
|
+
break;
|
|
93
|
+
case "enableAdaptiveVideo":
|
|
94
|
+
view.enableAdaptiveVideo();
|
|
95
|
+
break;
|
|
96
|
+
case "setVideoQuality":
|
|
97
|
+
case "setCaptionLanguage":
|
|
98
|
+
try {
|
|
99
|
+
view.setSelectedTrack(Utils.trackMapFromJson(args.getString(0)));
|
|
100
|
+
} catch (JSONException e) {
|
|
101
|
+
Log.e("VdoPlayer", "Invalid track payload", e);
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
62
105
|
}
|
|
63
106
|
|
|
64
|
-
@ReactProp(name = "embedInfo")
|
|
65
107
|
public void setEmbedInfo(ReactVdoPlayerUIView vdoPlayerView, @Nullable ReadableMap embedInfo) {
|
|
66
108
|
if (embedInfo != null) {
|
|
67
109
|
boolean offline = embedInfo.hasKey("offline") && embedInfo.getBoolean("offline");
|
|
@@ -154,72 +196,16 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
154
196
|
}
|
|
155
197
|
}
|
|
156
198
|
|
|
157
|
-
@ReactProp(name = "playWhenReady", defaultBoolean = true)
|
|
158
|
-
public void setPlayWhenReady(ReactVdoPlayerUIView vdoPlayerView, boolean playWhenReady) {
|
|
159
|
-
vdoPlayerView.setPlayWhenReady(playWhenReady);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
@ReactProp(name = "playbackSpeed", defaultFloat = 1f)
|
|
163
|
-
public void setPlaybackSpeed(ReactVdoPlayerUIView vdoPlayerView, float playbackSpeed) {
|
|
164
|
-
vdoPlayerView.setPlaybackSpeed(playbackSpeed);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@ReactProp(name = "seek")
|
|
168
|
-
public void setSeek(ReactVdoPlayerUIView vdoPlayerView, final int targetMs) {
|
|
169
|
-
vdoPlayerView.seekTo(targetMs);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@ReactProp(name = "fullscreen", defaultBoolean = false)
|
|
173
|
-
public void setFullscreen(ReactVdoPlayerUIView vdoPlayerView, boolean fullscreen) {
|
|
174
|
-
vdoPlayerView.setFullscreen(fullscreen);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@ReactProp(name = "playbackProperties")
|
|
178
|
-
public void getPlaybackProperties(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
179
|
-
vdoPlayerView.getPlaybackProperties();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
@ReactProp(name = "keyDownEvent")
|
|
183
|
-
public void setKeyDownEvent(ReactVdoPlayerUIView vdoPlayerView, ReadableMap eventMap) {
|
|
184
|
-
vdoPlayerView.setKeyDownEvent(new KeyEvent(eventMap.getInt("action"), eventMap.getInt("code")));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
@ReactProp(name = "resizeMode")
|
|
188
199
|
public void setResizeMode(ReactVdoPlayerUIView vdoPlayerView, String resizeMode) {
|
|
189
200
|
vdoPlayerView.setResizeMode(resizeMode);
|
|
190
201
|
}
|
|
191
202
|
|
|
192
|
-
@ReactProp(name = "aspectRatio")
|
|
193
203
|
public void setAspectRatio(ReactVdoPlayerUIView vdoPlayerView, float aspectRatio) {
|
|
194
204
|
vdoPlayerView.setAspectRatio(aspectRatio);
|
|
195
205
|
}
|
|
196
206
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
vdoPlayerView.setSelectedTrack(videoQuality);
|
|
207
|
+
public void setAutoPlay(ReactVdoPlayerUIView vdoPlayerView, boolean autoPlay) {
|
|
208
|
+
vdoPlayerView.setAutoPlay(autoPlay);
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
@ReactProp(name = "adaptiveVideo")
|
|
203
|
-
public void enableAdaptiveVideo(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
204
|
-
vdoPlayerView.enableAdaptiveVideo();
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
@ReactProp(name = "captionLanguage")
|
|
208
|
-
public void setCaptionLanguage(ReactVdoPlayerUIView vdoPlayerView, ReadableMap captionLanguage) {
|
|
209
|
-
vdoPlayerView.setSelectedTrack(captionLanguage);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
@ReactProp(name = "disableCaptions")
|
|
213
|
-
public void disableCaptions(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
214
|
-
vdoPlayerView.disableCaptions();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
@ReactProp(name = "backpressCalled")
|
|
218
|
-
public void setBackpressCalled(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
219
|
-
vdoPlayerView.setBackpressCalled();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
public interface Listener {
|
|
223
|
-
void onVideoPlayerViewInitialised(ReactVdoPlayerUIView vdoPlayerView);
|
|
224
|
-
}
|
|
225
211
|
}
|
|
@@ -236,16 +236,6 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
|
|
|
236
236
|
return true;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
public void getPlaybackProperties() {
|
|
240
|
-
if (vdoPlayer != null) {
|
|
241
|
-
Object tp = vdoPlayer.getPlaybackProperty("totalPlayed");
|
|
242
|
-
long totalPlayed = (tp instanceof Long) ? (long)tp : 0L;
|
|
243
|
-
Object tc = vdoPlayer.getPlaybackProperty("totalCovered");
|
|
244
|
-
long totalCovered = (tc instanceof Long) ? (long)tc : 0L;
|
|
245
|
-
eventEmitter.playbackProperties(totalPlayed, totalCovered);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
239
|
public void getPlaybackPropertiesV2(Callback callback) {
|
|
250
240
|
WritableMap playbackProperties = Arguments.createMap();
|
|
251
241
|
if (vdoPlayer != null) {
|
|
@@ -270,6 +260,12 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
|
|
|
270
260
|
}
|
|
271
261
|
}
|
|
272
262
|
|
|
263
|
+
public void setAutoPlay(boolean autoPlay) {
|
|
264
|
+
if (vdoPlayer == null) {
|
|
265
|
+
this.playWhenReady = autoPlay;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
273
269
|
public void setPlaybackSpeed(float playbackSpeed) {
|
|
274
270
|
this.pendingPlaybackSpeed = playbackSpeed;
|
|
275
271
|
if (vdoPlayer != null) {
|
|
@@ -486,7 +482,7 @@ public class ReactVdoPlayerView extends LinearLayout implements LifecycleEventLi
|
|
|
486
482
|
@Override
|
|
487
483
|
public void setId(int id) {
|
|
488
484
|
super.setId(id);
|
|
489
|
-
eventEmitter.
|
|
485
|
+
eventEmitter.setView(this);
|
|
490
486
|
}
|
|
491
487
|
|
|
492
488
|
@Override
|
|
@@ -626,7 +622,7 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
|
|
|
626
622
|
|
|
627
623
|
if (playing) {
|
|
628
624
|
//Request audio focus and notify other players to stop playback.
|
|
629
|
-
if ((audioFocusManager != null && audioFocusManager.requestAudioFocus())) {
|
|
625
|
+
if (!(audioFocusManager != null && audioFocusManager.requestAudioFocus())) {
|
|
630
626
|
Log.i(TAG, "Audio focus not granted");
|
|
631
627
|
}
|
|
632
628
|
} else if (playerState == VdoPlayer.STATE_ENDED && audioFocusManager != null) {
|
|
@@ -5,49 +5,40 @@ import android.util.Log;
|
|
|
5
5
|
import com.facebook.react.bridge.ReadableMap;
|
|
6
6
|
import com.facebook.react.common.MapBuilder;
|
|
7
7
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
8
|
-
import com.facebook.react.uimanager.ViewGroupManager;
|
|
9
|
-
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
8
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
11
|
-
import com.vdocipher.aegis.media.Track;
|
|
12
9
|
import android.graphics.Color;
|
|
13
10
|
|
|
11
|
+
import org.json.JSONException;
|
|
12
|
+
|
|
14
13
|
import java.util.Map;
|
|
15
14
|
|
|
16
15
|
import javax.annotation.Nullable;
|
|
17
|
-
import java.util.concurrent.CopyOnWriteArraySet;
|
|
18
16
|
|
|
19
17
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
20
|
-
import com.facebook.react.bridge.
|
|
18
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
21
19
|
|
|
22
|
-
public class
|
|
20
|
+
public class ReactVdoPlayerViewManagerImpl {
|
|
23
21
|
private static final String TAG = "ReactVdoPlayerViewMngr";
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
public static final String REACT_CLASS = "RCTVdoPlayerView";
|
|
24
|
+
public static final String NEW_ARCH_REACT_CLASS = "VdoPlayerView";
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
private CopyOnWriteArraySet<Listener> listeners = new CopyOnWriteArraySet<>();
|
|
26
|
+
public static final String NAME = "ReactVdoPlayerViewMngr";
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
private final PlayerViewRegistry registry;
|
|
29
|
+
|
|
30
|
+
public ReactVdoPlayerViewManagerImpl(PlayerViewRegistry registry) {
|
|
31
|
+
this.registry = registry;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
@Override
|
|
36
34
|
public ReactVdoPlayerView createViewInstance(ThemedReactContext context) {
|
|
37
|
-
playerView = new ReactVdoPlayerView(context);
|
|
35
|
+
ReactVdoPlayerView playerView = new ReactVdoPlayerView(context);
|
|
38
36
|
Log.d(TAG, "created " + playerView.toString());
|
|
39
|
-
|
|
40
|
-
listener.onVideoPlayerViewInitialised(playerView);
|
|
41
|
-
}
|
|
37
|
+
registry.setPlayerView(playerView);
|
|
42
38
|
return playerView;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
public void addListener(Listener listener) {
|
|
46
|
-
listeners.add(listener);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
41
|
@Nullable
|
|
50
|
-
@Override
|
|
51
42
|
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
52
43
|
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
53
44
|
for (String event : VdoEventEmitter.EVENTS) {
|
|
@@ -56,13 +47,55 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
56
47
|
return builder.build();
|
|
57
48
|
}
|
|
58
49
|
|
|
59
|
-
@Override
|
|
60
50
|
public void onDropViewInstance(ReactVdoPlayerView view) {
|
|
61
51
|
Log.d(TAG, "dropped " + view.toString());
|
|
62
52
|
view.cleanUp();
|
|
53
|
+
registry.clearPlayerView(view);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public void receiveCommand(
|
|
57
|
+
ReactVdoPlayerView view,
|
|
58
|
+
String commandId,
|
|
59
|
+
@Nullable ReadableArray args
|
|
60
|
+
) {
|
|
61
|
+
switch (commandId) {
|
|
62
|
+
case "play":
|
|
63
|
+
view.setPlayWhenReady(true);
|
|
64
|
+
break;
|
|
65
|
+
case "pause":
|
|
66
|
+
view.setPlayWhenReady(false);
|
|
67
|
+
break;
|
|
68
|
+
case "seek":
|
|
69
|
+
int targetMs = args.getInt(0);
|
|
70
|
+
view.seekTo(targetMs);
|
|
71
|
+
break;
|
|
72
|
+
case "enterFullscreen":
|
|
73
|
+
view.setFullscreen(true);
|
|
74
|
+
break;
|
|
75
|
+
case "exitFullscreen":
|
|
76
|
+
view.setFullscreen(false);
|
|
77
|
+
break;
|
|
78
|
+
case "playbackSpeed":
|
|
79
|
+
float speed = (float) args.getDouble(0);
|
|
80
|
+
view.setPlaybackSpeed(speed);
|
|
81
|
+
break;
|
|
82
|
+
case "disableCaptions":
|
|
83
|
+
view.disableCaptions();
|
|
84
|
+
break;
|
|
85
|
+
case "enableAdaptiveVideo":
|
|
86
|
+
view.enableAdaptiveVideo();
|
|
87
|
+
break;
|
|
88
|
+
case "setVideoQuality":
|
|
89
|
+
case "setCaptionLanguage":
|
|
90
|
+
try {
|
|
91
|
+
view.setSelectedTrack(Utils.trackMapFromJson(args.getString(0)));
|
|
92
|
+
} catch (JSONException e) {
|
|
93
|
+
Log.e("VdoPlayer", "Invalid track payload", e);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
63
97
|
}
|
|
64
98
|
|
|
65
|
-
@ReactProp(name = "embedInfo")
|
|
66
99
|
public void setEmbedInfo(ReactVdoPlayerView vdoPlayerView, @Nullable ReadableMap embedInfo) {
|
|
67
100
|
if (embedInfo != null) {
|
|
68
101
|
boolean offline = embedInfo.hasKey("offline") && embedInfo.getBoolean("offline");
|
|
@@ -146,63 +179,16 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
146
179
|
}
|
|
147
180
|
}
|
|
148
181
|
|
|
149
|
-
@ReactProp(name = "playWhenReady", defaultBoolean = true)
|
|
150
|
-
public void setPlayWhenReady(ReactVdoPlayerView vdoPlayerView, boolean playWhenReady) {
|
|
151
|
-
vdoPlayerView.setPlayWhenReady(playWhenReady);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
@ReactProp(name = "playbackSpeed", defaultFloat = 1f)
|
|
155
|
-
public void setPlaybackSpeed(ReactVdoPlayerView vdoPlayerView, float playbackSpeed) {
|
|
156
|
-
vdoPlayerView.setPlaybackSpeed(playbackSpeed);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@ReactProp(name = "seek")
|
|
160
|
-
public void setSeek(ReactVdoPlayerView vdoPlayerView, final int targetMs) {
|
|
161
|
-
vdoPlayerView.seekTo(targetMs);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
@ReactProp(name = "fullscreen", defaultBoolean = false)
|
|
165
|
-
public void setFullscreen(ReactVdoPlayerView vdoPlayerView, boolean fullscreen) {
|
|
166
|
-
vdoPlayerView.setFullscreen(fullscreen);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@ReactProp(name = "playbackProperties")
|
|
170
|
-
public void getPlaybackProperties(ReactVdoPlayerView vdoPlayerView, int ref) {
|
|
171
|
-
vdoPlayerView.getPlaybackProperties();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@ReactProp(name = "videoQuality")
|
|
175
|
-
public void setVideoQuality(ReactVdoPlayerView vdoPlayerView, ReadableMap videoQuality) {
|
|
176
|
-
vdoPlayerView.setSelectedTrack(videoQuality);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
@ReactProp(name = "adaptiveVideo")
|
|
180
|
-
public void enableAdaptiveVideo(ReactVdoPlayerView vdoPlayerView, int ref) {
|
|
181
|
-
vdoPlayerView.enableAdaptiveVideo();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
@ReactProp(name = "captionLanguage")
|
|
185
|
-
public void setCaptionLanguage(ReactVdoPlayerView vdoPlayerView, ReadableMap captionLanguage) {
|
|
186
|
-
vdoPlayerView.setSelectedTrack(captionLanguage);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
@ReactProp(name = "disableCaptions")
|
|
190
|
-
public void disableCaptions(ReactVdoPlayerView vdoPlayerView, int ref) {
|
|
191
|
-
vdoPlayerView.disableCaptions();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public interface Listener {
|
|
195
|
-
void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@ReactProp(name = "resizeMode")
|
|
199
182
|
public void setResizeMode(ReactVdoPlayerView vdoPlayerView, String resizeMode) {
|
|
200
183
|
vdoPlayerView.setResizeMode(resizeMode);
|
|
201
184
|
}
|
|
202
185
|
|
|
203
|
-
@ReactProp(name = "aspectRatio")
|
|
204
186
|
public void setAspectRatio(ReactVdoPlayerView vdoPlayerView, float aspectRatio) {
|
|
205
187
|
vdoPlayerView.setAspectRatio(aspectRatio);
|
|
206
188
|
}
|
|
207
189
|
|
|
190
|
+
public void setAutoPlay(ReactVdoPlayerView vdoPlayerView, boolean autoPlay) {
|
|
191
|
+
vdoPlayerView.setAutoPlay(autoPlay);
|
|
192
|
+
}
|
|
193
|
+
|
|
208
194
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.Callback;
|
|
5
|
+
|
|
6
|
+
public class TrackSelectionModuleImpl {
|
|
7
|
+
private static final String TAG = "TrackSelectionModuleImpl";
|
|
8
|
+
public static final String NAME = "TrackSelection";
|
|
9
|
+
|
|
10
|
+
private final PlayerViewRegistry registry;
|
|
11
|
+
|
|
12
|
+
public TrackSelectionModuleImpl(ReactApplicationContext reactContext, PlayerViewRegistry registry) {
|
|
13
|
+
this.registry = registry;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private ReactVdoPlayerView playerView() { return registry.getPlayerView(); }
|
|
17
|
+
private ReactVdoPlayerUIView playerUIView() { return registry.getPlayerUIView(); }
|
|
18
|
+
|
|
19
|
+
private boolean hasNoView() {
|
|
20
|
+
return playerView() == null && playerUIView() == null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public void isAdaptive(Callback callback) {
|
|
24
|
+
if (hasNoView()) return;
|
|
25
|
+
if (playerView() != null) playerView().isAdaptive(callback);
|
|
26
|
+
else playerUIView().isAdaptive(callback);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public void getVideoQualities(Callback callback) {
|
|
30
|
+
if (hasNoView()) return;
|
|
31
|
+
if (playerView() != null) playerView().getVideoQualities(callback);
|
|
32
|
+
else playerUIView().getVideoQualities(callback);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void getSelectedVideoQuality(Callback callback) {
|
|
36
|
+
if (hasNoView()) return;
|
|
37
|
+
if (playerView() != null) playerView().getSelectedVideoQuality(callback);
|
|
38
|
+
else playerUIView().getSelectedVideoQuality(callback);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public void getSelectedAudioQuality(Callback callback) {
|
|
42
|
+
if (hasNoView()) return;
|
|
43
|
+
if (playerView() != null) playerView().getSelectedAudioQuality(callback);
|
|
44
|
+
else playerUIView().getSelectedAudioQuality(callback);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public void getCaptionLanguages(Callback callback) {
|
|
48
|
+
if (hasNoView()) return;
|
|
49
|
+
if (playerView() != null) playerView().getCaptionLanguages(callback);
|
|
50
|
+
else playerUIView().getCaptionLanguages(callback);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public void getSelectedCaptionLanguage(Callback callback) {
|
|
54
|
+
if (hasNoView()) return;
|
|
55
|
+
if (playerView() != null) playerView().getSelectedCaptionLanguage(callback);
|
|
56
|
+
else playerUIView().getSelectedCaptionLanguage(callback);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public void getDuration(Callback callback) {
|
|
60
|
+
if (hasNoView()) return;
|
|
61
|
+
if (playerView() != null) playerView().getDuration(callback);
|
|
62
|
+
else playerUIView().getDuration(callback);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -19,6 +19,10 @@ import android.content.res.Configuration;
|
|
|
19
19
|
import androidx.appcompat.app.AppCompatActivity;
|
|
20
20
|
import com.vdocipher.aegis.player.VdoPlayerSetting.VdoPlaybackMode;
|
|
21
21
|
|
|
22
|
+
import org.json.JSONException;
|
|
23
|
+
import org.json.JSONObject;
|
|
24
|
+
|
|
25
|
+
import java.util.Iterator;
|
|
22
26
|
import java.util.List;
|
|
23
27
|
|
|
24
28
|
/**
|
|
@@ -190,6 +194,29 @@ public class Utils {
|
|
|
190
194
|
return trackMap;
|
|
191
195
|
}
|
|
192
196
|
|
|
197
|
+
// Commands carry the track/caption as a JSON string; rebuild the full map for setSelectedTrack.
|
|
198
|
+
public static WritableMap trackMapFromJson(String json) throws JSONException {
|
|
199
|
+
JSONObject obj = new JSONObject(json);
|
|
200
|
+
WritableMap map = Arguments.createMap();
|
|
201
|
+
Iterator<String> keys = obj.keys();
|
|
202
|
+
while (keys.hasNext()) {
|
|
203
|
+
String key = keys.next();
|
|
204
|
+
Object value = obj.get(key);
|
|
205
|
+
if (value instanceof Integer) {
|
|
206
|
+
map.putInt(key, (Integer) value);
|
|
207
|
+
} else if (value instanceof Number) {
|
|
208
|
+
map.putDouble(key, ((Number) value).doubleValue());
|
|
209
|
+
} else if (value instanceof Boolean) {
|
|
210
|
+
map.putBoolean(key, (Boolean) value);
|
|
211
|
+
} else if (value instanceof String) {
|
|
212
|
+
map.putString(key, (String) value);
|
|
213
|
+
} else {
|
|
214
|
+
map.putNull(key);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return map;
|
|
218
|
+
}
|
|
219
|
+
|
|
193
220
|
public static Track makeTrack(ReadableMap selectedTrackMap, Track[] availableTracks) {
|
|
194
221
|
int id = selectedTrackMap.getInt("id");
|
|
195
222
|
|