Skip to content

Commit

Permalink
SeekOverlay: Hide controls shadow in most cases during seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
vkay94 committed Nov 20, 2020
1 parent 9555a77 commit 95ad4ef
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 52 deletions.
109 changes: 58 additions & 51 deletions app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,70 +460,77 @@ private void setupPlayerSeekOverlay() {
final int fadeDurations = 450;

seekOverlay.showCircle(true)
.circleBackgroundColorInt(CircleClipTapView.COLOR_DARK_TRANSPARENT)
.circleBackgroundColorInt(CircleClipTapView.COLOR_DARK)
.seekSeconds(seekDurationInMillis / 1000)
.performListener(new PlayerSeekOverlay.PerformListener() {

final boolean keepShadow = true;
boolean keepShadow = false;

@Override
public void onPrepare() {
if (checkCorrectConditions()) {
gestureListener.endMultiDoubleTap();
return;
}
seekOverlay.arcSize(CircleClipTapView.Companion.calculateArcSize(getSurfaceView()));
}
@Override
public void onPrepare() {
if (checkCorrectConditions()) {
gestureListener.endMultiDoubleTap();
return;
}

@Override
public void onAnimationStart() {
animateView(seekOverlay, true, fadeDurations);
hideControls(fadeDurations, 0, keepShadow);
}
keepShadow = !getPlayer().getPlayWhenReady() && isControlsVisible();
seekOverlay
.arcSize(CircleClipTapView.Companion.calculateArcSize(getSurfaceView()))
.circleBackgroundColorInt(
keepShadow ? CircleClipTapView.COLOR_DARK_TRANSPARENT
: CircleClipTapView.COLOR_DARK
);
}

@Override
public void onAnimationEnd() {
animateView(seekOverlay, false, fadeDurations);
if (!getPlayer().getPlayWhenReady()) {
showControls(fadeDurations);
} else {
showHideShadow(false, fadeDurations, 0);
@Override
public void onAnimationStart() {
animateView(seekOverlay, true, fadeDurations);
hideControls(fadeDurations, 0, keepShadow);
}
}

@Override
public Boolean shouldFastForward(@NotNull final DisplayPortion portion) {
// Null indicates an invalid area or condition e.g. the middle portion
// or video start or end was reached during double tap seeking
if (checkCorrectConditions()) {
return null;
@Override
public void onAnimationEnd() {
animateView(seekOverlay, false, fadeDurations);
if (!getPlayer().getPlayWhenReady()) {
showControls(fadeDurations);
} else {
showHideShadow(false, fadeDurations, 0);
}
}
if (portion == DisplayPortion.LEFT) {
return false;
} else if (portion == DisplayPortion.RIGHT) {
return true;
} else /* portion == DisplayPortion.MIDDLE */ {
return null;

@Override
public Boolean shouldFastForward(@NotNull final DisplayPortion portion) {
// Null indicates an invalid area or condition e.g. the middle portion
// or video start or end was reached during double tap seeking
if (checkCorrectConditions()) {
return null;
}
if (portion == DisplayPortion.LEFT) {
return false;
} else if (portion == DisplayPortion.RIGHT) {
return true;
} else /* portion == DisplayPortion.MIDDLE */ {
return null;
}
}
}

@Override
public void seek(final boolean forward) {
gestureListener.keepInDoubleTapMode();
if (forward) {
onFastForward();
} else {
onFastRewind();
@Override
public void seek(final boolean forward) {
gestureListener.keepInDoubleTapMode();
if (forward) {
onFastForward();
} else {
onFastRewind();
}
}
}

private boolean checkCorrectConditions() {
return getPlayer().getCurrentPosition() == getPlayer().getDuration()
// Add puffer of a half second, so that direct rewinding is not possible
|| getPlayer().getCurrentPosition() <= 500L
|| getPlayer().getPlaybackState() == Player.STATE_ENDED
|| getPlayer().getPlaybackState() == Player.STATE_IDLE;
}
private boolean checkCorrectConditions() {
return getPlayer().getCurrentPosition() == getPlayer().getDuration()
// Add puffer of a half second, so that direct rewinding is not possible
|| getPlayer().getCurrentPosition() <= 500L
|| getPlayer().getPlaybackState() == Player.STATE_ENDED
|| getPlayer().getPlaybackState() == Player.STATE_IDLE;
}
});
gestureListener.doubleTapControls(seekOverlay);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.schabi.newpipe.player.event.DisplayPortion
class CircleClipTapView(context: Context?, attrs: AttributeSet) : View(context, attrs) {

companion object {
const val COLOR_DARK = 0x40000000
const val COLOR_DARK = 0x45000000
const val COLOR_DARK_TRANSPARENT = 0x30000000
const val COLOR_LIGHT_TRANSPARENT = 0x25EEEEEE

Expand Down

0 comments on commit 95ad4ef

Please sign in to comment.