Skip to content

Commit

Permalink
fix(android): hide surfaceView for loading time when shutter is hidden (
Browse files Browse the repository at this point in the history
#4060)

* fix(android): hide surfaceView for loading time when shutter is hidden

* fix: hide/show surface view without casting
  • Loading branch information
moskalakamil authored Aug 22, 2024
1 parent b05201a commit 65faba3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 19 additions & 3 deletions android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,22 @@ public void updateSurfaceView(@ViewType.ViewType int viewType) {
}
}

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
Expand Down Expand Up @@ -194,7 +208,9 @@ public void setPlayer(ExoPlayer player) {
clearVideoView();
}
this.player = player;
shutterView.setVisibility(this.hideShutterView ? View.INVISIBLE : View.VISIBLE);

updateShutterViewVisibility();

if (player != null) {
setVideoView();
player.addListener(componentListener);
Expand Down Expand Up @@ -281,7 +297,7 @@ public void onVideoSizeChanged(VideoSize videoSize) {

@Override
public void onRenderedFirstFrame() {
shutterView.setVisibility(INVISIBLE);
hideShutterView();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 65faba3

Please sign in to comment.