From 65faba312d23de981972d2b6ffecefbc87ecac61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Moska=C5=82a?= <91079590+moskalakamil@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:37:58 +0200 Subject: [PATCH] fix(android): hide surfaceView for loading time when shutter is hidden (#4060) * fix(android): hide surfaceView for loading time when shutter is hidden * fix: hide/show surface view without casting --- .../brentvatne/exoplayer/ExoPlayerView.java | 22 ++++++++++++++++--- .../exoplayer/ReactExoplayerViewManager.kt | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java index a57b91f9..dd18dbfd 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java @@ -161,8 +161,22 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider { } } + private void hideShutterView() { + shutterView.setVisibility(INVISIBLE); + surfaceView.setAlpha(1); + } + + private void showShutterView() { + shutterView.setVisibility(VISIBLE); + surfaceView.setAlpha(0); + } + private void updateShutterViewVisibility() { - shutterView.setVisibility(this.hideShutterView ? View.INVISIBLE : View.VISIBLE); + if (this.hideShutterView) { + hideShutterView(); + } else { + showShutterView(); + } } @Override @@ -194,7 +208,9 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider { clearVideoView(); } this.player = player; - shutterView.setVisibility(this.hideShutterView ? View.INVISIBLE : View.VISIBLE); + + updateShutterViewVisibility(); + if (player != null) { setVideoView(); player.addListener(componentListener); @@ -281,7 +297,7 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider { @Override public void onRenderedFirstFrame() { - shutterView.setVisibility(INVISIBLE); + hideShutterView(); } @Override diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.kt b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.kt index 8299c345..195875be 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.kt +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.kt @@ -276,9 +276,9 @@ class ReactExoplayerViewManager(private val config: ReactExoplayerConfig) : View videoView.setSubtitleStyle(SubtitleStyle.parse(src)) } - @ReactProp(name = PROP_SHUTTER_COLOR, defaultInt = 0) + @ReactProp(name = PROP_SHUTTER_COLOR, defaultInt = Color.BLACK) fun setShutterColor(videoView: ReactExoplayerView, color: Int) { - videoView.setShutterColor(if (color == 0) Color.BLACK else color) + videoView.setShutterColor(color) } @ReactProp(name = PROP_BUFFER_CONFIG)