Skip to content

Commit

Permalink
Makes controls initially hidden
Browse files Browse the repository at this point in the history
Also, there was a bug that controls are always shown at the beginning
even when controlview's hide() is called.

PiperOrigin-RevId: 323300617
  • Loading branch information
1nsun authored and ojw28 committed Jul 27, 2020
1 parent 9743e47 commit f99023e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
private final OnLayoutChangeListener onLayoutChangeListener;

private int uxState = UX_STATE_ALL_VISIBLE;
private boolean initiallyHidden;
private boolean isMinimalMode;
private boolean needToShowBars;
private boolean animationEnabled = true;
private boolean animationEnabled;

@Nullable private StyledPlayerControlView styledPlayerControlView;

Expand Down Expand Up @@ -86,9 +87,11 @@ public StyledPlayerControlViewLayoutManager() {
hideMainBarsRunnable = this::hideMainBars;
hideControllerRunnable = this::hideController;
onLayoutChangeListener = this::onLayoutChange;
animationEnabled = true;
}

public void show() {
initiallyHidden = false;
if (this.styledPlayerControlView == null) {
return;
}
Expand All @@ -102,6 +105,7 @@ public void show() {
}

public void hide() {
initiallyHidden = true;
if (styledPlayerControlView == null
|| uxState == UX_STATE_ANIMATING_HIDE
|| uxState == UX_STATE_NONE_VISIBLE) {
Expand Down Expand Up @@ -156,6 +160,8 @@ public void removeHideCallbacks() {
public void onViewAttached(StyledPlayerControlView v) {
styledPlayerControlView = v;

v.setVisibility(initiallyHidden ? View.GONE : View.VISIBLE);

v.addOnLayoutChangeListener(onLayoutChangeListener);

// Relating to Title Bar View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.ui;

import static com.google.android.exoplayer2.util.Assertions.checkNotNull;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
Expand Down Expand Up @@ -1320,9 +1322,10 @@ private boolean shouldShowControllerIndefinitely() {
}
int playbackState = player.getPlaybackState();
return controllerAutoShow
&& !player.getCurrentTimeline().isEmpty()
&& (playbackState == Player.STATE_IDLE
|| playbackState == Player.STATE_ENDED
|| !player.getPlayWhenReady());
|| !checkNotNull(player).getPlayWhenReady());
}

private void showController(boolean showIndefinitely) {
Expand Down Expand Up @@ -1613,7 +1616,7 @@ public void onTracksChanged(TrackGroupArray tracks, TrackSelectionArray selectio
// 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:
// https:/google/ExoPlayer/issues/5507.
Player player = Assertions.checkNotNull(StyledPlayerView.this.player);
Player player = checkNotNull(StyledPlayerView.this.player);
Timeline timeline = player.getCurrentTimeline();
if (timeline.isEmpty()) {
lastPeriodUidWithTracks = null;
Expand Down

0 comments on commit f99023e

Please sign in to comment.