From 79f03dfba314c455520033a229c7f36199bcc681 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 21 Jun 2021 23:31:22 +0100 Subject: [PATCH] Fix DefaultTimeBar glitches The glitches were introduced in: https://github.com/google/ExoPlayer/commit/6c31e34528 The problem is that Listener.onEvents is called in a later looper iteration than the listener methods that were previously used. This created a gap on the main thread between the UI component dispatching a seek operation to the player, and onEvents being called to update the progress bar's position. At the start of this gap the progress bar is rendering the new position, but its position member variable is still set to the old position. If the progress bar is re-drawn by another message on the main thread within the gap, it will briefly show the old position until onEvents is called. There are multiple possible fixes to this, and the best one is probably to modify ListenerSet to remove the gap. That's high risk though, so for now we fix the flicker by always updating the progress immediately after the seek is dispatched, in addition to when onEvents is called. Issue: #9049 PiperOrigin-RevId: 380678388 --- RELEASENOTES.md | 2 ++ .../google/android/exoplayer2/ui/PlayerControlView.java | 8 ++------ .../android/exoplayer2/ui/StyledPlayerControlView.java | 8 ++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 39fa946b80..9c7a68cec6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -35,6 +35,8 @@ * Fix focusability of `StyledPlayerView` and `StyledPlayerControlView` popup menus on API levels prior to 26 ([#9061](https://github.com/google/ExoPlayer/issues/9061)). + * Fix progress bar flickering immediately after the user seeks + ([#9049](https://github.com/google/ExoPlayer/pull/9049)). ### 2.14.1 (2021-06-11) diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java index 1499aa556a..e4a88c083e 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java @@ -1155,12 +1155,8 @@ public class PlayerControlView extends FrameLayout { } else { windowIndex = player.getCurrentWindowIndex(); } - boolean dispatched = seekTo(player, windowIndex, positionMs); - if (!dispatched) { - // The seek wasn't dispatched then the progress bar scrubber will be in the wrong position. - // Trigger a progress update to snap it back. - updateProgress(); - } + seekTo(player, windowIndex, positionMs); + updateProgress(); } private boolean seekTo(Player player, int windowIndex, long positionMs) { diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 886bfd9f21..86086dd90b 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -1534,12 +1534,8 @@ public class StyledPlayerControlView extends FrameLayout { } else { windowIndex = player.getCurrentWindowIndex(); } - boolean dispatched = seekTo(player, windowIndex, positionMs); - if (!dispatched) { - // The seek wasn't dispatched then the progress bar scrubber will be in the wrong position. - // Trigger a progress update to snap it back. - updateProgress(); - } + seekTo(player, windowIndex, positionMs); + updateProgress(); } private boolean seekTo(Player player, int windowIndex, long positionMs) {