add useSecureView prop to prevent screen recording

This commit is contained in:
Gabriel 2022-02-14 21:17:22 -04:00
parent 2ab029995f
commit 2af360a7bb
5 changed files with 41 additions and 1 deletions

View File

@ -316,6 +316,7 @@ var styles = StyleSheet.create({
* [textTracks](#texttracks)
* [trackId](#trackId)
* [useTextureView](#usetextureview)
* [useSecureView](#useSecureView)
* [volume](#volume)
* [localSourceEncryptionKeyScheme](#localSourceEncryptionKeyScheme)
@ -911,6 +912,18 @@ useTextureView can only be set at same time you're setting the source.
Platforms: Android ExoPlayer
#### useSecureView
Force the output to a SurfaceView and enables the secure surface.
This will override useTextureView flag.
SurfaceView is is the only one that can be labeled as secure.
* **true** - Use security
* **false (default)** - Do not use security
Platforms: Android ExoPlayer
#### volume
Adjust the volume.
* **1.0 (default)** - Play at full volume

View File

@ -488,6 +488,7 @@ Video.propTypes = {
fullscreenOrientation: PropTypes.oneOf(['all', 'landscape', 'portrait']),
progressUpdateInterval: PropTypes.number,
useTextureView: PropTypes.bool,
useSecureView: PropTypes.bool,
hideShutterView: PropTypes.bool,
onLoadStart: PropTypes.func,
onLoad: PropTypes.func,

View File

@ -41,6 +41,7 @@ public final class ExoPlayerView extends FrameLayout {
private ViewGroup.LayoutParams layoutParams;
private boolean useTextureView = true;
private boolean useSecureView = false;
private boolean hideShutterView = false;
public ExoPlayerView(Context context) {
@ -103,7 +104,15 @@ public final class ExoPlayerView extends FrameLayout {
}
private void updateSurfaceView() {
View view = useTextureView ? new TextureView(context) : new SurfaceView(context);
View view;
if (!useTextureView || useSecureView) {
view = new SurfaceView(context);
if (useSecureView) {
((SurfaceView)view).setSecure(true);
}
} else {
view = new TextureView(context);
}
view.setLayoutParams(layoutParams);
surfaceView = view;
@ -178,6 +187,13 @@ public final class ExoPlayerView extends FrameLayout {
}
}
public void useSecureView(boolean useSecureView) {
if (useSecureView != this.useSecureView) {
this.useSecureView = useSecureView;
updateSurfaceView();
}
}
public void setHideShutterView(boolean hideShutterView) {
this.hideShutterView = hideShutterView;
updateShutterViewVisibility();

View File

@ -1696,6 +1696,10 @@ class ReactExoplayerView extends FrameLayout implements
exoPlayerView.setUseTextureView(finallyUseTextureView);
}
public void useSecureView(boolean useSecureView) {
exoPlayerView.useSecureView(useSecureView);
}
public void setHideShutterView(boolean hideShutterView) {
exoPlayerView.setHideShutterView(hideShutterView);
}

View File

@ -72,6 +72,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_DISABLE_DISCONNECT_ERROR = "disableDisconnectError";
private static final String PROP_FULLSCREEN = "fullscreen";
private static final String PROP_USE_TEXTURE_VIEW = "useTextureView";
private static final String PROP_SECURE_VIEW = "useSecureView";
private static final String PROP_SELECTED_VIDEO_TRACK = "selectedVideoTrack";
private static final String PROP_SELECTED_VIDEO_TRACK_TYPE = "type";
private static final String PROP_SELECTED_VIDEO_TRACK_VALUE = "value";
@ -331,6 +332,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
videoView.setUseTextureView(useTextureView);
}
@ReactProp(name = PROP_SECURE_VIEW, defaultBoolean = true)
public void useSecureView(final ReactExoplayerView videoView, final boolean useSecureView) {
videoView.useSecureView(useSecureView);
}
@ReactProp(name = PROP_HIDE_SHUTTER_VIEW, defaultBoolean = false)
public void setHideShutterView(final ReactExoplayerView videoView, final boolean hideShutterView) {
videoView.setHideShutterView(hideShutterView);