From 96c42844fea4e7a1b364b6cfb94d16248246a3a8 Mon Sep 17 00:00:00 2001 From: vadim Date: Wed, 28 Nov 2018 14:56:58 +0200 Subject: [PATCH] ExoPlayer - Add possibility to hide shutterView --- README.md | 8 ++++++++ Video.js | 1 + .../java/com/brentvatne/exoplayer/ExoPlayerView.java | 10 ++++++++++ .../com/brentvatne/exoplayer/ReactExoplayerView.java | 5 +++++ .../exoplayer/ReactExoplayerViewManager.java | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/README.md b/README.md index a7c8430e..103cd470 100644 --- a/README.md +++ b/README.md @@ -693,6 +693,14 @@ useTextureView can only be set at same time you're setting the source. Platforms: Android ExoPlayer +#### hideShutterView +Controls ExoPlayer shutterView(black screen while loading) visibility + +* **false (default)** - Show shutterView +* **true** - Hide shutterView + +Platforms: Android ExoPlayer + #### volume Adjust the volume. * **1.0 (default)** - Play at full volume diff --git a/Video.js b/Video.js index 77b02f0a..60dd3f54 100644 --- a/Video.js +++ b/Video.js @@ -383,6 +383,7 @@ Video.propTypes = { fullscreenOrientation: PropTypes.oneOf(['all','landscape','portrait']), progressUpdateInterval: PropTypes.number, useTextureView: PropTypes.bool, + hideShutterView: PropTypes.bool, onLoadStart: PropTypes.func, onLoad: PropTypes.func, onBuffer: PropTypes.func, diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java index 85876709..35d56512 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java @@ -39,6 +39,7 @@ public final class ExoPlayerView extends FrameLayout { private ViewGroup.LayoutParams layoutParams; private boolean useTextureView = false; + private boolean hideShutterView = false; public ExoPlayerView(Context context) { this(context, null); @@ -106,6 +107,10 @@ public final class ExoPlayerView extends FrameLayout { } } + private void updateShutterViewVisibility() { + shutterView.setVisibility(this.hideShutterView ? View.INVISIBLE : View.VISIBLE); + } + /** * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous @@ -161,6 +166,11 @@ public final class ExoPlayerView extends FrameLayout { updateSurfaceView(); } + public void setHideShutterView(boolean hideShutterView) { + this.hideShutterView = hideShutterView; + updateShutterViewVisibility(); + } + private final Runnable measureAndLayout = new Runnable() { @Override public void run() { diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index dc49402d..033329b7 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -131,6 +131,7 @@ class ReactExoplayerView extends FrameLayout implements private float mProgressUpdateInterval = 250.0f; private boolean playInBackground = false; private boolean useTextureView = false; + private boolean hideShutterView = false; private Map requestHeaders; // \ End props @@ -954,6 +955,10 @@ class ReactExoplayerView extends FrameLayout implements exoPlayerView.setUseTextureView(useTextureView); } + public void setHideShutterView(boolean hideShutterView) { + exoPlayerView.setHideShutterView(hideShutterView); + } + public void setBufferConfig(int newMinBufferMs, int newMaxBufferMs, int newBufferForPlaybackMs, int newBufferForPlaybackAfterRebufferMs) { minBufferMs = newMinBufferMs; maxBufferMs = newMaxBufferMs; diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index 4d1ec286..fb72f434 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -51,6 +51,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager