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
This commit is contained in:
Kamil Moskała 2024-08-22 10:37:58 +02:00 committed by GitHub
parent b05201a9fa
commit 65faba312d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 5 deletions

View File

@ -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() { private void updateShutterViewVisibility() {
shutterView.setVisibility(this.hideShutterView ? View.INVISIBLE : View.VISIBLE); if (this.hideShutterView) {
hideShutterView();
} else {
showShutterView();
}
} }
@Override @Override
@ -194,7 +208,9 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
clearVideoView(); clearVideoView();
} }
this.player = player; this.player = player;
shutterView.setVisibility(this.hideShutterView ? View.INVISIBLE : View.VISIBLE);
updateShutterViewVisibility();
if (player != null) { if (player != null) {
setVideoView(); setVideoView();
player.addListener(componentListener); player.addListener(componentListener);
@ -281,7 +297,7 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
@Override @Override
public void onRenderedFirstFrame() { public void onRenderedFirstFrame() {
shutterView.setVisibility(INVISIBLE); hideShutterView();
} }
@Override @Override

View File

@ -276,9 +276,9 @@ class ReactExoplayerViewManager(private val config: ReactExoplayerConfig) : View
videoView.setSubtitleStyle(SubtitleStyle.parse(src)) 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) { fun setShutterColor(videoView: ReactExoplayerView, color: Int) {
videoView.setShutterColor(if (color == 0) Color.BLACK else color) videoView.setShutterColor(color)
} }
@ReactProp(name = PROP_BUFFER_CONFIG) @ReactProp(name = PROP_BUFFER_CONFIG)