vdocipher-rn-bridge 2.0.1 → 2.1.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/VdoCastButton.tsx +22 -0
- package/VdoCastMiniController.tsx +21 -0
- package/VdoPlayerView.tsx +64 -0
- package/android/build.gradle +5 -3
- package/android/src/main/java/com/vdocipher/rnbridge/AudioFocusManager.java +7 -2
- package/android/src/main/java/com/vdocipher/rnbridge/PlayerViewRegistry.java +21 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoCastButtonManagerImpl.java +40 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoCastMiniControllerManagerImpl.java +12 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +85 -59
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManagerImpl.java +18 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +450 -103
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManagerImpl.java +30 -1
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModuleImpl.java +13 -28
- package/android/src/main/java/com/vdocipher/rnbridge/Utils.java +36 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdoCastButtonView.java +59 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdoCastMiniControllerView.java +83 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdoDownloadModuleImpl.java +15 -3
- package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +15 -2
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerModuleImpl.java +8 -10
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerSettingsModuleImpl.java +5 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgeModuleImpl.java +12 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgePackage.java +3 -1
- package/android/src/main/res/layout/vdo_cast_mini_controller.xml +9 -0
- package/android/src/main/res/values/vdo_cast_arrays.xml +9 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoCastButtonManager.java +44 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoCastMiniControllerManager.java +37 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +12 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +30 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPlayerModule.java +5 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPlayerSettingsModule.java +5 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoCastButtonManager.java +27 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoCastMiniControllerManager.java +19 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +4 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +13 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPlayerModule.java +5 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPlayerSettingsModule.java +5 -0
- package/downloads.ts +4 -1
- package/index.ts +4 -0
- package/ios/RCTVdoPlayerUIView.swift +38 -11
- package/ios/RCTVdoPlayerUIViewComponentView.mm +1 -0
- package/ios/RCTVdoPlayerView.swift +5 -2
- package/ios/RCTVdoPlayerViewComponentView.mm +1 -0
- package/ios/VdoCipherRNView.h +1 -0
- package/ios/VdoCipherRNView.swift +142 -19
- package/ios/VdoEventEmitter.swift +2 -0
- package/ios/VdoPlaybackProperties.h +1 -0
- package/ios/VdoPlaybackProperties.swift +5 -0
- package/ios/VdoPlayerCommandDispatch.h +4 -0
- package/ios/VdoPlayerSettings.swift +5 -0
- package/ios/VdocipherRnBridgeViewManager.mm +12 -0
- package/ios/VdocipherRnBridgeViewManager.swift +5 -1
- package/package.json +3 -1
- package/specs/NativeVdoPlayer.ts +1 -0
- package/specs/NativeVdoPlayerSettings.ts +2 -0
- package/specs/RCTVdoCastButtonNativeComponent.ts +11 -0
- package/specs/RCTVdoCastMiniControllerNativeComponent.ts +9 -0
- package/specs/RCTVdoPlayerUIViewNativeComponent.ts +13 -0
- package/specs/RCTVdoPlayerViewNativeComponent.ts +19 -0
- package/type.ts +51 -1
|
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
6
6
|
import com.facebook.react.common.MapBuilder;
|
|
7
7
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
8
8
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
9
|
+
import com.vdocipher.aegis.player.VdoMediaMetadata;
|
|
9
10
|
import android.graphics.Color;
|
|
10
11
|
|
|
11
12
|
import org.json.JSONException;
|
|
@@ -15,6 +16,7 @@ import java.util.Map;
|
|
|
15
16
|
import javax.annotation.Nullable;
|
|
16
17
|
|
|
17
18
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
19
|
+
import static com.vdocipher.rnbridge.Utils.getVdoMediaMetadata;
|
|
18
20
|
import com.facebook.react.bridge.ReadableArray;
|
|
19
21
|
|
|
20
22
|
public class ReactVdoPlayerViewManagerImpl {
|
|
@@ -93,9 +95,25 @@ public class ReactVdoPlayerViewManagerImpl {
|
|
|
93
95
|
Log.e("VdoPlayer", "Invalid track payload", e);
|
|
94
96
|
}
|
|
95
97
|
break;
|
|
98
|
+
case "stopCasting":
|
|
99
|
+
view.stopCasting();
|
|
100
|
+
break;
|
|
101
|
+
case "openCastControls":
|
|
102
|
+
view.openCastControls();
|
|
103
|
+
break;
|
|
104
|
+
case "mute":
|
|
105
|
+
view.setMuted(true);
|
|
106
|
+
break;
|
|
107
|
+
case "unmute":
|
|
108
|
+
view.setMuted(false);
|
|
109
|
+
break;
|
|
96
110
|
}
|
|
97
111
|
}
|
|
98
112
|
|
|
113
|
+
public void setChromecastEnabled(ReactVdoPlayerView vdoPlayerView, boolean enabled) {
|
|
114
|
+
vdoPlayerView.setChromecastEnabled(enabled);
|
|
115
|
+
}
|
|
116
|
+
|
|
99
117
|
public void setEmbedInfo(ReactVdoPlayerView vdoPlayerView, @Nullable ReadableMap embedInfo) {
|
|
100
118
|
if (embedInfo != null) {
|
|
101
119
|
boolean offline = embedInfo.hasKey("offline") && embedInfo.getBoolean("offline");
|
|
@@ -132,6 +150,16 @@ public class ReactVdoPlayerViewManagerImpl {
|
|
|
132
150
|
int markerColorInt = Color.parseColor(clipMarkerColor);
|
|
133
151
|
builder.setClips(clipStartInMs, clipEndInMs, clipped, markerColorInt);
|
|
134
152
|
|
|
153
|
+
VdoMediaMetadata vdoMediaMetadata = getVdoMediaMetadata(embedInfo);
|
|
154
|
+
if (vdoMediaMetadata != null) {
|
|
155
|
+
builder.setVdoMediaMetadata(vdoMediaMetadata);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
builder.setStartMuted(embedInfo.hasKey("startMuted") && !embedInfo.isNull("startMuted")
|
|
159
|
+
&& embedInfo.getBoolean("startMuted"));
|
|
160
|
+
builder.setDisableAnalytics(embedInfo.hasKey("disableAnalytics") && !embedInfo.isNull("disableAnalytics")
|
|
161
|
+
&& embedInfo.getBoolean("disableAnalytics"));
|
|
162
|
+
|
|
135
163
|
if (offline) {
|
|
136
164
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
137
165
|
|
|
@@ -174,7 +202,8 @@ public class ReactVdoPlayerViewManagerImpl {
|
|
|
174
202
|
}
|
|
175
203
|
|
|
176
204
|
initParams = builder.build();
|
|
177
|
-
|
|
205
|
+
|
|
206
|
+
vdoPlayerView.setOfflinePlayback(offline);
|
|
178
207
|
vdoPlayerView.load(initParams);
|
|
179
208
|
}
|
|
180
209
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.vdocipher.rnbridge;
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments;
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
5
|
import com.facebook.react.bridge.Callback;
|
|
5
6
|
|
|
@@ -13,52 +14,36 @@ public class TrackSelectionModuleImpl {
|
|
|
13
14
|
this.registry = registry;
|
|
14
15
|
}
|
|
15
16
|
|
|
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
17
|
public void isAdaptive(Callback callback) {
|
|
24
|
-
|
|
25
|
-
if (playerView() != null) playerView().isAdaptive(callback);
|
|
26
|
-
else playerUIView().isAdaptive(callback);
|
|
18
|
+
registry.withView(callback, () -> false, v -> v.isAdaptive(callback), v -> v.isAdaptive(callback));
|
|
27
19
|
}
|
|
28
20
|
|
|
29
21
|
public void getVideoQualities(Callback callback) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else playerUIView().getVideoQualities(callback);
|
|
22
|
+
registry.withView(callback, Arguments::createArray,
|
|
23
|
+
v -> v.getVideoQualities(callback), v -> v.getVideoQualities(callback));
|
|
33
24
|
}
|
|
34
25
|
|
|
35
26
|
public void getSelectedVideoQuality(Callback callback) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else playerUIView().getSelectedVideoQuality(callback);
|
|
27
|
+
registry.withView(callback, Arguments::createMap,
|
|
28
|
+
v -> v.getSelectedVideoQuality(callback), v -> v.getSelectedVideoQuality(callback));
|
|
39
29
|
}
|
|
40
30
|
|
|
41
31
|
public void getSelectedAudioQuality(Callback callback) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else playerUIView().getSelectedAudioQuality(callback);
|
|
32
|
+
registry.withView(callback, Arguments::createMap,
|
|
33
|
+
v -> v.getSelectedAudioQuality(callback), v -> v.getSelectedAudioQuality(callback));
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
public void getCaptionLanguages(Callback callback) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
else playerUIView().getCaptionLanguages(callback);
|
|
37
|
+
registry.withView(callback, Arguments::createArray,
|
|
38
|
+
v -> v.getCaptionLanguages(callback), v -> v.getCaptionLanguages(callback));
|
|
51
39
|
}
|
|
52
40
|
|
|
53
41
|
public void getSelectedCaptionLanguage(Callback callback) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
else playerUIView().getSelectedCaptionLanguage(callback);
|
|
42
|
+
registry.withView(callback, Arguments::createMap,
|
|
43
|
+
v -> v.getSelectedCaptionLanguage(callback), v -> v.getSelectedCaptionLanguage(callback));
|
|
57
44
|
}
|
|
58
45
|
|
|
59
46
|
public void getDuration(Callback callback) {
|
|
60
|
-
|
|
61
|
-
if (playerView() != null) playerView().getDuration(callback);
|
|
62
|
-
else playerUIView().getDuration(callback);
|
|
47
|
+
registry.withView(callback, () -> 0, v -> v.getDuration(callback), v -> v.getDuration(callback));
|
|
63
48
|
}
|
|
64
49
|
}
|
|
@@ -13,9 +13,11 @@ import com.vdocipher.aegis.offline.DownloadStatus;
|
|
|
13
13
|
import com.vdocipher.aegis.offline.VdoDownloadManager;
|
|
14
14
|
import com.vdocipher.aegis.player.VdoPlayer;
|
|
15
15
|
import com.vdocipher.aegis.player.PlayerHost;
|
|
16
|
+
import com.vdocipher.aegis.player.VdoMediaMetadata;
|
|
16
17
|
import android.app.UiModeManager;
|
|
17
18
|
import android.content.Context;
|
|
18
19
|
import android.content.res.Configuration;
|
|
20
|
+
import android.net.Uri;
|
|
19
21
|
import androidx.appcompat.app.AppCompatActivity;
|
|
20
22
|
import com.vdocipher.aegis.player.VdoPlayerSetting.VdoPlaybackMode;
|
|
21
23
|
|
|
@@ -428,6 +430,40 @@ public class Utils {
|
|
|
428
430
|
}
|
|
429
431
|
}
|
|
430
432
|
|
|
433
|
+
public static VdoMediaMetadata getVdoMediaMetadata(ReadableMap embedInfo) {
|
|
434
|
+
ReadableMap metadataMap = embedInfo.hasKey("mediaMetadata") ? embedInfo.getMap("mediaMetadata") : null;
|
|
435
|
+
if (metadataMap == null) {
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
String title = getNonEmptyString(metadataMap, "title");
|
|
439
|
+
String description = getNonEmptyString(metadataMap, "description");
|
|
440
|
+
String posterUrl = getNonEmptyString(metadataMap, "posterUrl");
|
|
441
|
+
if (title == null && description == null && posterUrl == null) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// aegis ignores server metadata once this is set, so unset fields stay blank
|
|
446
|
+
VdoMediaMetadata vdoMediaMetadata = new VdoMediaMetadata();
|
|
447
|
+
if (title != null) {
|
|
448
|
+
vdoMediaMetadata.setTitle(title);
|
|
449
|
+
}
|
|
450
|
+
if (description != null) {
|
|
451
|
+
vdoMediaMetadata.setDescription(description);
|
|
452
|
+
}
|
|
453
|
+
if (posterUrl != null) {
|
|
454
|
+
vdoMediaMetadata.setPoster(Uri.parse(posterUrl));
|
|
455
|
+
}
|
|
456
|
+
return vdoMediaMetadata;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
public static String getNonEmptyString(ReadableMap map, String key) {
|
|
460
|
+
if (!map.hasKey(key) || map.isNull(key)) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
String value = map.getString(key);
|
|
464
|
+
return value == null || value.isEmpty() ? null : value;
|
|
465
|
+
}
|
|
466
|
+
|
|
431
467
|
public static boolean isRunningOnTv(AppCompatActivity activity) {
|
|
432
468
|
UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
|
|
433
469
|
return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import android.app.UiModeManager;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.res.Configuration;
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import androidx.mediarouter.app.MediaRouteButton;
|
|
9
|
+
|
|
10
|
+
import com.google.android.gms.cast.framework.CastButtonFactory;
|
|
11
|
+
import com.google.android.gms.cast.framework.CastContext;
|
|
12
|
+
import com.google.android.gms.common.ConnectionResult;
|
|
13
|
+
import com.google.android.gms.common.GoogleApiAvailability;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cast button set up only when Google Play services are available and not on a TV; MediaRouteButton
|
|
17
|
+
* then manages its own visibility (shown only when a cast device is on the network).
|
|
18
|
+
*/
|
|
19
|
+
public class VdoCastButtonView extends MediaRouteButton {
|
|
20
|
+
private static final String TAG = "VdoCastButton";
|
|
21
|
+
|
|
22
|
+
public VdoCastButtonView(Context context) {
|
|
23
|
+
super(context);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Override
|
|
27
|
+
public void onAttachedToWindow() {
|
|
28
|
+
super.onAttachedToWindow();
|
|
29
|
+
if (isCastAvailable()) {
|
|
30
|
+
try {
|
|
31
|
+
CastContext.getSharedInstance(getContext());
|
|
32
|
+
CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), this);
|
|
33
|
+
} catch (Exception e) {
|
|
34
|
+
Log.e(TAG, Log.getStackTraceString(e));
|
|
35
|
+
setVisibility(GONE);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
setVisibility(GONE);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private boolean isCastAvailable() {
|
|
43
|
+
if (isRunningOnTv()) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
return GoogleApiAvailability.getInstance()
|
|
48
|
+
.isGooglePlayServicesAvailable(getContext()) == ConnectionResult.SUCCESS;
|
|
49
|
+
} catch (Exception e) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private boolean isRunningOnTv() {
|
|
55
|
+
UiModeManager uiModeManager = (UiModeManager) getContext().getSystemService(Context.UI_MODE_SERVICE);
|
|
56
|
+
return uiModeManager != null
|
|
57
|
+
&& uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import android.widget.FrameLayout;
|
|
6
|
+
|
|
7
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
8
|
+
import androidx.fragment.app.Fragment;
|
|
9
|
+
import androidx.fragment.app.FragmentManager;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
12
|
+
|
|
13
|
+
public class VdoCastMiniControllerView extends FrameLayout {
|
|
14
|
+
private static final String TAG = "VdoCastMiniController";
|
|
15
|
+
|
|
16
|
+
private final ThemedReactContext reactContext;
|
|
17
|
+
private boolean inflated = false;
|
|
18
|
+
|
|
19
|
+
public VdoCastMiniControllerView(ThemedReactContext context) {
|
|
20
|
+
super(context);
|
|
21
|
+
this.reactContext = context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
protected void onAttachedToWindow() {
|
|
26
|
+
super.onAttachedToWindow();
|
|
27
|
+
inflateMiniController();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
protected void onDetachedFromWindow() {
|
|
32
|
+
removeMiniController();
|
|
33
|
+
super.onDetachedFromWindow();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private void inflateMiniController() {
|
|
37
|
+
if (inflated) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
Activity activity = reactContext.getCurrentActivity();
|
|
41
|
+
if (!(activity instanceof AppCompatActivity)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
// Inflate via the activity inflater so the fragment's onInflate receives castControlButtons.
|
|
46
|
+
activity.getLayoutInflater().inflate(R.layout.vdo_cast_mini_controller, this, true);
|
|
47
|
+
inflated = true;
|
|
48
|
+
} catch (Exception e) {
|
|
49
|
+
Log.e(TAG, Log.getStackTraceString(e));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private void removeMiniController() {
|
|
54
|
+
Activity activity = reactContext.getCurrentActivity();
|
|
55
|
+
if (activity instanceof AppCompatActivity) {
|
|
56
|
+
FragmentManager fm = ((AppCompatActivity) activity).getSupportFragmentManager();
|
|
57
|
+
Fragment fragment = fm.findFragmentById(R.id.vdo_cast_mini_controller_fragment);
|
|
58
|
+
if (fragment != null && !fm.isDestroyed()) {
|
|
59
|
+
try {
|
|
60
|
+
fm.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
|
|
61
|
+
} catch (Exception e) {
|
|
62
|
+
Log.e(TAG, Log.getStackTraceString(e));
|
|
63
|
+
fm.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
removeAllViews();
|
|
68
|
+
inflated = false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public void requestLayout() {
|
|
73
|
+
super.requestLayout();
|
|
74
|
+
post(measureAndLayout);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private final Runnable measureAndLayout = () -> {
|
|
78
|
+
measure(
|
|
79
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
80
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
81
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -54,9 +54,9 @@ public class VdoDownloadModuleImpl implements VdoDownloadManager.EventListener {
|
|
|
54
54
|
|
|
55
55
|
public VdoDownloadModuleImpl(ReactApplicationContext reactContext) {
|
|
56
56
|
downloadOptionsStore = new HashMap<>();
|
|
57
|
-
VdoDownloadManager.getInstance(reactContext).addEventListener(this);
|
|
58
57
|
mainHandler = new Handler(Looper.getMainLooper());
|
|
59
58
|
reactApplicationContext = reactContext;
|
|
59
|
+
VdoDownloadManager.getInstance(reactContext).addEventListener(this);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
public void getDownloadOptions(ReadableMap optionParams,
|
|
@@ -336,7 +336,19 @@ public class VdoDownloadModuleImpl implements VdoDownloadManager.EventListener {
|
|
|
336
336
|
DownloadSelections downloadSelections = new DownloadSelections(downloadOptions, selectedIndices);
|
|
337
337
|
|
|
338
338
|
// Build a DownloadRequest
|
|
339
|
-
DownloadRequest
|
|
339
|
+
DownloadRequest.Builder requestBuilder = new DownloadRequest.Builder(downloadSelections);
|
|
340
|
+
String notificationTitle = Utils.getNonEmptyString(requestOptions, "notificationTitle");
|
|
341
|
+
if (notificationTitle != null) {
|
|
342
|
+
requestBuilder.setNotificationTitle(notificationTitle);
|
|
343
|
+
}
|
|
344
|
+
String notificationDescription = Utils.getNonEmptyString(requestOptions, "notificationDescription");
|
|
345
|
+
if (notificationDescription != null) {
|
|
346
|
+
requestBuilder.setNotificationDescription(notificationDescription);
|
|
347
|
+
}
|
|
348
|
+
requestBuilder.setDisableAnalytics(requestOptions.hasKey("disableAnalytics")
|
|
349
|
+
&& !requestOptions.isNull("disableAnalytics")
|
|
350
|
+
&& requestOptions.getBoolean("disableAnalytics"));
|
|
351
|
+
DownloadRequest request = requestBuilder.build();
|
|
340
352
|
|
|
341
353
|
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext, downloadLocation);
|
|
342
354
|
|
|
@@ -361,7 +373,7 @@ public class VdoDownloadModuleImpl implements VdoDownloadManager.EventListener {
|
|
|
361
373
|
String mediaId,
|
|
362
374
|
@Nullable DownloadStatus downloadStatus) {
|
|
363
375
|
|
|
364
|
-
if(!reactContext.hasActiveCatalystInstance()) {
|
|
376
|
+
if(reactContext == null || !reactContext.hasActiveCatalystInstance()) {
|
|
365
377
|
return;
|
|
366
378
|
}
|
|
367
379
|
|
|
@@ -37,6 +37,7 @@ class VdoEventEmitter {
|
|
|
37
37
|
private static final String EVENT_ENTER_FULLSCREEN = "onVdoEnterFullscreen";
|
|
38
38
|
private static final String EVENT_EXIT_FULLSCREEN = "onVdoExitFullscreen";
|
|
39
39
|
private static final String EVENT_PICTURE_IN_PICTURE_MODE_CHANGED ="onVdoPictureInPictureModeChanged";
|
|
40
|
+
private static final String EVENT_CAST_STATE_CHANGED = "onVdoCastStateChanged";
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
static final String[] EVENTS = {
|
|
@@ -48,7 +49,8 @@ class VdoEventEmitter {
|
|
|
48
49
|
EVENT_MEDIA_ENDED,
|
|
49
50
|
EVENT_ERROR,
|
|
50
51
|
EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
|
|
51
|
-
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED
|
|
52
|
+
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED,
|
|
53
|
+
EVENT_CAST_STATE_CHANGED
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
@Retention(RetentionPolicy.SOURCE)
|
|
@@ -60,7 +62,8 @@ class VdoEventEmitter {
|
|
|
60
62
|
EVENT_MEDIA_ENDED,
|
|
61
63
|
EVENT_ERROR,
|
|
62
64
|
EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
|
|
63
|
-
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED
|
|
65
|
+
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED,
|
|
66
|
+
EVENT_CAST_STATE_CHANGED})
|
|
64
67
|
@interface VdoEvent {}
|
|
65
68
|
|
|
66
69
|
private static final String EVENT_PROP_RESTORED = "restored";
|
|
@@ -80,6 +83,9 @@ class VdoEventEmitter {
|
|
|
80
83
|
|
|
81
84
|
private static final String EVENT_PROP_ERROR_DESCRIPTION = "errorDescription";
|
|
82
85
|
|
|
86
|
+
private static final String EVENT_PROP_CAST_STATE = "state";
|
|
87
|
+
private static final String EVENT_PROP_DEVICE_NAME = "deviceName";
|
|
88
|
+
|
|
83
89
|
private final ReactContext reactContext;
|
|
84
90
|
private View view;
|
|
85
91
|
|
|
@@ -191,6 +197,13 @@ class VdoEventEmitter {
|
|
|
191
197
|
receiveEvent(EVENT_PICTURE_IN_PICTURE_MODE_CHANGED, event);
|
|
192
198
|
}
|
|
193
199
|
|
|
200
|
+
void castStateChanged(String state, String deviceName) {
|
|
201
|
+
WritableMap event = Arguments.createMap();
|
|
202
|
+
event.putString(EVENT_PROP_CAST_STATE, state);
|
|
203
|
+
event.putString(EVENT_PROP_DEVICE_NAME, deviceName);
|
|
204
|
+
receiveEvent(EVENT_CAST_STATE_CHANGED, event);
|
|
205
|
+
}
|
|
206
|
+
|
|
194
207
|
private void receiveEvent(@VdoEvent String type, WritableMap event) {
|
|
195
208
|
View v = this.view;
|
|
196
209
|
if (v == null) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.vdocipher.rnbridge;
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments;
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
5
|
import com.facebook.react.bridge.Callback;
|
|
5
6
|
|
|
@@ -14,15 +15,12 @@ public class VdoPlayerModuleImpl {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
public void getPlaybackPropertiesV2(Callback callback) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} else {
|
|
25
|
-
playerUIView.getPlaybackPropertiesV2(callback);
|
|
26
|
-
}
|
|
18
|
+
registry.withView(callback, Arguments::createMap,
|
|
19
|
+
v -> v.getPlaybackPropertiesV2(callback), v -> v.getPlaybackPropertiesV2(callback));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public void isMuted(Callback callback) {
|
|
23
|
+
registry.withView(callback, () -> false,
|
|
24
|
+
v -> callback.invoke(v.isMuted()), v -> callback.invoke(v.isMuted()));
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -48,4 +48,9 @@ public class VdoPlayerSettingsModuleImpl {
|
|
|
48
48
|
sharedPreferences.edit().putString(VDO_PLAYBACK_MODE, playbackMode).apply();
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
// App-wide and in memory; Aegis applies it on the main thread.
|
|
52
|
+
public void setPictureInPictureActionsEnabled(boolean enabled) {
|
|
53
|
+
VdoPlayerSetting.setPictureInPictureActionsEnabled(enabled);
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
}
|
|
@@ -8,10 +8,12 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
8
8
|
import com.facebook.react.bridge.ReactMethod;
|
|
9
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
10
10
|
import com.vdocipher.aegis.player.VdoInitParams;
|
|
11
|
+
import com.vdocipher.aegis.player.VdoMediaMetadata;
|
|
11
12
|
|
|
12
13
|
import android.graphics.Color;
|
|
13
14
|
|
|
14
15
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
16
|
+
import static com.vdocipher.rnbridge.Utils.getVdoMediaMetadata;
|
|
15
17
|
import java.util.HashMap;
|
|
16
18
|
|
|
17
19
|
public class VdocipherRnBridgeModuleImpl {
|
|
@@ -64,6 +66,16 @@ public class VdocipherRnBridgeModuleImpl {
|
|
|
64
66
|
int markerColorInt = Color.parseColor(clipMarkerColor);
|
|
65
67
|
builder.setClips(clipStartInMs, clipEndInMs, clipped, markerColorInt);
|
|
66
68
|
|
|
69
|
+
VdoMediaMetadata vdoMediaMetadata = getVdoMediaMetadata(embedInfo);
|
|
70
|
+
if (vdoMediaMetadata != null) {
|
|
71
|
+
builder.setVdoMediaMetadata(vdoMediaMetadata);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
builder.setStartMuted(embedInfo.hasKey("startMuted") && !embedInfo.isNull("startMuted")
|
|
75
|
+
&& embedInfo.getBoolean("startMuted"));
|
|
76
|
+
builder.setDisableAnalytics(embedInfo.hasKey("disableAnalytics") && !embedInfo.isNull("disableAnalytics")
|
|
77
|
+
&& embedInfo.getBoolean("disableAnalytics"));
|
|
78
|
+
|
|
67
79
|
if (offline) {
|
|
68
80
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
69
81
|
|
|
@@ -33,6 +33,8 @@ public class VdocipherRnBridgePackage implements ReactPackage {
|
|
|
33
33
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
34
34
|
return Arrays.<ViewManager>asList(
|
|
35
35
|
new ReactVdoPlayerUIViewManager(reactContext, registry),
|
|
36
|
-
new ReactVdoPlayerViewManager(reactContext, registry)
|
|
36
|
+
new ReactVdoPlayerViewManager(reactContext, registry),
|
|
37
|
+
new ReactVdoCastButtonManager(),
|
|
38
|
+
new ReactVdoCastMiniControllerManager());
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
4
|
+
android:id="@+id/vdo_cast_mini_controller_fragment"
|
|
5
|
+
android:name="com.vdocipher.aegis.cast.CustomMiniControllerFragment"
|
|
6
|
+
android:layout_width="match_parent"
|
|
7
|
+
android:layout_height="wrap_content"
|
|
8
|
+
app:castShowImageThumbnail="true"
|
|
9
|
+
app:castControlButtons="@array/vdo_cast_mini_controller_buttons" />
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<!-- MiniControllerFragment requires exactly 3 buttons; use empty for unused slots. -->
|
|
4
|
+
<array name="vdo_cast_mini_controller_buttons">
|
|
5
|
+
<item>@id/cast_button_type_empty</item>
|
|
6
|
+
<item>@id/cast_button_type_play_pause_toggle</item>
|
|
7
|
+
<item>@id/cast_button_type_empty</item>
|
|
8
|
+
</array>
|
|
9
|
+
</resources>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
7
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
10
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
11
|
+
import com.facebook.react.viewmanagers.VdoCastButtonManagerInterface;
|
|
12
|
+
import com.facebook.react.viewmanagers.VdoCastButtonManagerDelegate;
|
|
13
|
+
|
|
14
|
+
@ReactModule(name = ReactVdoCastButtonManagerImpl.NEW_ARCH_REACT_CLASS)
|
|
15
|
+
public class ReactVdoCastButtonManager extends SimpleViewManager<VdoCastButtonView>
|
|
16
|
+
implements VdoCastButtonManagerInterface<VdoCastButtonView> {
|
|
17
|
+
|
|
18
|
+
private final ReactVdoCastButtonManagerImpl impl = new ReactVdoCastButtonManagerImpl();
|
|
19
|
+
private final ViewManagerDelegate<VdoCastButtonView> mDelegate = new VdoCastButtonManagerDelegate<>(this);
|
|
20
|
+
|
|
21
|
+
@Nullable
|
|
22
|
+
@Override
|
|
23
|
+
protected ViewManagerDelegate<VdoCastButtonView> getDelegate() {
|
|
24
|
+
return mDelegate;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@NonNull
|
|
28
|
+
@Override
|
|
29
|
+
public String getName() {
|
|
30
|
+
return ReactVdoCastButtonManagerImpl.NEW_ARCH_REACT_CLASS;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@NonNull
|
|
34
|
+
@Override
|
|
35
|
+
public VdoCastButtonView createViewInstance(ThemedReactContext context) {
|
|
36
|
+
return impl.createViewInstance(context);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
@ReactProp(name = "tint", customType = "Color")
|
|
41
|
+
public void setTint(VdoCastButtonView view, @Nullable Integer tint) {
|
|
42
|
+
impl.setTint(view, tint);
|
|
43
|
+
}
|
|
44
|
+
}
|
package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoCastMiniControllerManager.java
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
7
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
10
|
+
import com.facebook.react.viewmanagers.VdoCastMiniControllerManagerInterface;
|
|
11
|
+
import com.facebook.react.viewmanagers.VdoCastMiniControllerManagerDelegate;
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = ReactVdoCastMiniControllerManagerImpl.NEW_ARCH_REACT_CLASS)
|
|
14
|
+
public class ReactVdoCastMiniControllerManager extends SimpleViewManager<VdoCastMiniControllerView>
|
|
15
|
+
implements VdoCastMiniControllerManagerInterface<VdoCastMiniControllerView> {
|
|
16
|
+
|
|
17
|
+
private final ReactVdoCastMiniControllerManagerImpl impl = new ReactVdoCastMiniControllerManagerImpl();
|
|
18
|
+
private final ViewManagerDelegate<VdoCastMiniControllerView> mDelegate = new VdoCastMiniControllerManagerDelegate<>(this);
|
|
19
|
+
|
|
20
|
+
@Nullable
|
|
21
|
+
@Override
|
|
22
|
+
protected ViewManagerDelegate<VdoCastMiniControllerView> getDelegate() {
|
|
23
|
+
return mDelegate;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@NonNull
|
|
27
|
+
@Override
|
|
28
|
+
public String getName() {
|
|
29
|
+
return ReactVdoCastMiniControllerManagerImpl.NEW_ARCH_REACT_CLASS;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@NonNull
|
|
33
|
+
@Override
|
|
34
|
+
public VdoCastMiniControllerView createViewInstance(ThemedReactContext context) {
|
|
35
|
+
return impl.createViewInstance(context);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -48,6 +48,8 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
48
48
|
private static final int COMMAND_ENABLE_ADAPTIVE_VIDEO = 10;
|
|
49
49
|
private static final int COMMAND_SET_VIDEO_QUALITY = 11;
|
|
50
50
|
private static final int COMMAND_SET_CAPTION_LANGUAGE = 12;
|
|
51
|
+
private static final int COMMAND_MUTE = 13;
|
|
52
|
+
private static final int COMMAND_UNMUTE = 14;
|
|
51
53
|
|
|
52
54
|
private final ViewManagerDelegate<ReactVdoPlayerUIView> mDelegate;
|
|
53
55
|
|
|
@@ -100,6 +102,8 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
100
102
|
.put("enableAdaptiveVideo", COMMAND_ENABLE_ADAPTIVE_VIDEO)
|
|
101
103
|
.put("setVideoQuality", COMMAND_SET_VIDEO_QUALITY)
|
|
102
104
|
.put("setCaptionLanguage", COMMAND_SET_CAPTION_LANGUAGE)
|
|
105
|
+
.put("mute", COMMAND_MUTE)
|
|
106
|
+
.put("unmute", COMMAND_UNMUTE)
|
|
103
107
|
.build();
|
|
104
108
|
}
|
|
105
109
|
|
|
@@ -192,4 +196,12 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
192
196
|
reactVdoPlayerUIViewManagerImpl.receiveCommand(view, "setScreenBlurred", null);
|
|
193
197
|
}
|
|
194
198
|
|
|
199
|
+
public void mute(ReactVdoPlayerUIView view) {
|
|
200
|
+
reactVdoPlayerUIViewManagerImpl.receiveCommand(view, "mute", null);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public void unmute(ReactVdoPlayerUIView view) {
|
|
204
|
+
reactVdoPlayerUIViewManagerImpl.receiveCommand(view, "unmute", null);
|
|
205
|
+
}
|
|
206
|
+
|
|
195
207
|
}
|