Commit f99023e8 by insun Committed by Oliver Woodman

Makes controls initially hidden

Also, there was a bug that controls are always shown at the beginning
even when controlview's hide() is called.

PiperOrigin-RevId: 323300617
parent 9743e47f
...@@ -54,9 +54,10 @@ import java.util.ArrayList; ...@@ -54,9 +54,10 @@ import java.util.ArrayList;
private final OnLayoutChangeListener onLayoutChangeListener; private final OnLayoutChangeListener onLayoutChangeListener;
private int uxState = UX_STATE_ALL_VISIBLE; private int uxState = UX_STATE_ALL_VISIBLE;
private boolean initiallyHidden;
private boolean isMinimalMode; private boolean isMinimalMode;
private boolean needToShowBars; private boolean needToShowBars;
private boolean animationEnabled = true; private boolean animationEnabled;
@Nullable private StyledPlayerControlView styledPlayerControlView; @Nullable private StyledPlayerControlView styledPlayerControlView;
...@@ -86,9 +87,11 @@ import java.util.ArrayList; ...@@ -86,9 +87,11 @@ import java.util.ArrayList;
hideMainBarsRunnable = this::hideMainBars; hideMainBarsRunnable = this::hideMainBars;
hideControllerRunnable = this::hideController; hideControllerRunnable = this::hideController;
onLayoutChangeListener = this::onLayoutChange; onLayoutChangeListener = this::onLayoutChange;
animationEnabled = true;
} }
public void show() { public void show() {
initiallyHidden = false;
if (this.styledPlayerControlView == null) { if (this.styledPlayerControlView == null) {
return; return;
} }
...@@ -102,6 +105,7 @@ import java.util.ArrayList; ...@@ -102,6 +105,7 @@ import java.util.ArrayList;
} }
public void hide() { public void hide() {
initiallyHidden = true;
if (styledPlayerControlView == null if (styledPlayerControlView == null
|| uxState == UX_STATE_ANIMATING_HIDE || uxState == UX_STATE_ANIMATING_HIDE
|| uxState == UX_STATE_NONE_VISIBLE) { || uxState == UX_STATE_NONE_VISIBLE) {
...@@ -156,6 +160,8 @@ import java.util.ArrayList; ...@@ -156,6 +160,8 @@ import java.util.ArrayList;
public void onViewAttached(StyledPlayerControlView v) { public void onViewAttached(StyledPlayerControlView v) {
styledPlayerControlView = v; styledPlayerControlView = v;
v.setVisibility(initiallyHidden ? View.GONE : View.VISIBLE);
v.addOnLayoutChangeListener(onLayoutChangeListener); v.addOnLayoutChangeListener(onLayoutChangeListener);
// Relating to Title Bar View // Relating to Title Bar View
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.ui; package com.google.android.exoplayer2.ui;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
...@@ -1320,9 +1322,10 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro ...@@ -1320,9 +1322,10 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro
} }
int playbackState = player.getPlaybackState(); int playbackState = player.getPlaybackState();
return controllerAutoShow return controllerAutoShow
&& !player.getCurrentTimeline().isEmpty()
&& (playbackState == Player.STATE_IDLE && (playbackState == Player.STATE_IDLE
|| playbackState == Player.STATE_ENDED || playbackState == Player.STATE_ENDED
|| !player.getPlayWhenReady()); || !checkNotNull(player).getPlayWhenReady());
} }
private void showController(boolean showIndefinitely) { private void showController(boolean showIndefinitely) {
...@@ -1613,7 +1616,7 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro ...@@ -1613,7 +1616,7 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro
// Suppress the update if transitioning to an unprepared period within the same window. This // Suppress the update if transitioning to an unprepared period within the same window. This
// is necessary to avoid closing the shutter when such a transition occurs. See: // is necessary to avoid closing the shutter when such a transition occurs. See:
// https://github.com/google/ExoPlayer/issues/5507. // https://github.com/google/ExoPlayer/issues/5507.
Player player = Assertions.checkNotNull(StyledPlayerView.this.player); Player player = checkNotNull(StyledPlayerView.this.player);
Timeline timeline = player.getCurrentTimeline(); Timeline timeline = player.getCurrentTimeline();
if (timeline.isEmpty()) { if (timeline.isEmpty()) {
lastPeriodUidWithTracks = null; lastPeriodUidWithTracks = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment