mirror of
https://github.com/androidx/media.git
synced 2025-05-18 13:09:56 +08:00
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
This commit is contained in:
parent
9743e47f1f
commit
f99023e887
@ -54,9 +54,10 @@ import java.util.ArrayList;
|
||||
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;
|
||||
|
||||
@ -86,9 +87,11 @@ import java.util.ArrayList;
|
||||
hideMainBarsRunnable = this::hideMainBars;
|
||||
hideControllerRunnable = this::hideController;
|
||||
onLayoutChangeListener = this::onLayoutChange;
|
||||
animationEnabled = true;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
initiallyHidden = false;
|
||||
if (this.styledPlayerControlView == null) {
|
||||
return;
|
||||
}
|
||||
@ -102,6 +105,7 @@ import java.util.ArrayList;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
initiallyHidden = true;
|
||||
if (styledPlayerControlView == null
|
||||
|| uxState == UX_STATE_ANIMATING_HIDE
|
||||
|| uxState == UX_STATE_NONE_VISIBLE) {
|
||||
@ -156,6 +160,8 @@ import java.util.ArrayList;
|
||||
public void onViewAttached(StyledPlayerControlView v) {
|
||||
styledPlayerControlView = v;
|
||||
|
||||
v.setVisibility(initiallyHidden ? View.GONE : View.VISIBLE);
|
||||
|
||||
v.addOnLayoutChangeListener(onLayoutChangeListener);
|
||||
|
||||
// Relating to Title Bar View
|
||||
|
@ -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;
|
||||
@ -1320,9 +1322,10 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro
|
||||
}
|
||||
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) {
|
||||
@ -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
|
||||
// is necessary to avoid closing the shutter when such a transition occurs. See:
|
||||
// https://github.com/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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user