mirror of
https://github.com/androidx/media.git
synced 2025-05-15 03:29:53 +08:00
Prevent shutter closing for within-window seeks to unprepared periods
Issue: #5507 PiperOrigin-RevId: 315512207
This commit is contained in:
parent
80f4197e0f
commit
e5ec8e6b47
@ -1,5 +1,12 @@
|
|||||||
# Release notes #
|
# Release notes #
|
||||||
|
|
||||||
|
### 2.11.6 (not yet released) ###
|
||||||
|
|
||||||
|
* UI: Prevent `PlayerView` from temporarily hiding the video surface when
|
||||||
|
seeking to an unprepared period within the current window. For example when
|
||||||
|
seeking over an ad group, or to the next period in a multi-period DASH
|
||||||
|
stream ([#5507](https://github.com/google/ExoPlayer/issues/5507)).
|
||||||
|
|
||||||
### 2.11.5 (2020-06-05) ###
|
### 2.11.5 (2020-06-05) ###
|
||||||
|
|
||||||
* Improve the smoothness of video playback immediately after starting, seeking
|
* Improve the smoothness of video playback immediately after starting, seeking
|
||||||
|
@ -48,6 +48,8 @@ import com.google.android.exoplayer2.ExoPlaybackException;
|
|||||||
import com.google.android.exoplayer2.PlaybackPreparer;
|
import com.google.android.exoplayer2.PlaybackPreparer;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Player.DiscontinuityReason;
|
import com.google.android.exoplayer2.Player.DiscontinuityReason;
|
||||||
|
import com.google.android.exoplayer2.Timeline;
|
||||||
|
import com.google.android.exoplayer2.Timeline.Period;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
import com.google.android.exoplayer2.metadata.flac.PictureFrame;
|
import com.google.android.exoplayer2.metadata.flac.PictureFrame;
|
||||||
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
||||||
@ -1506,6 +1508,13 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
|
|||||||
SingleTapListener,
|
SingleTapListener,
|
||||||
PlayerControlView.VisibilityListener {
|
PlayerControlView.VisibilityListener {
|
||||||
|
|
||||||
|
private final Period period;
|
||||||
|
private @Nullable Object lastPeriodUidWithTracks;
|
||||||
|
|
||||||
|
public ComponentListener() {
|
||||||
|
period = new Period();
|
||||||
|
}
|
||||||
|
|
||||||
// TextOutput implementation
|
// TextOutput implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1554,6 +1563,29 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTracksChanged(TrackGroupArray tracks, TrackSelectionArray selections) {
|
public void onTracksChanged(TrackGroupArray tracks, TrackSelectionArray selections) {
|
||||||
|
// 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(PlayerView.this.player);
|
||||||
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
|
if (timeline.isEmpty()) {
|
||||||
|
lastPeriodUidWithTracks = null;
|
||||||
|
} else if (!player.getCurrentTrackGroups().isEmpty()) {
|
||||||
|
lastPeriodUidWithTracks =
|
||||||
|
timeline.getPeriod(player.getCurrentPeriodIndex(), period, /* setIds= */ true).uid;
|
||||||
|
} else if (lastPeriodUidWithTracks != null) {
|
||||||
|
int lastPeriodIndexWithTracks = timeline.getIndexOfPeriod(lastPeriodUidWithTracks);
|
||||||
|
if (lastPeriodIndexWithTracks != C.INDEX_UNSET) {
|
||||||
|
int lastWindowIndexWithTracks =
|
||||||
|
timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex;
|
||||||
|
if (player.getCurrentWindowIndex() == lastWindowIndexWithTracks) {
|
||||||
|
// We're in the same window. Suppress the update.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastPeriodUidWithTracks = null;
|
||||||
|
}
|
||||||
|
|
||||||
updateForCurrentTrackSelections(/* isNewPlayer= */ false);
|
updateForCurrentTrackSelections(/* isNewPlayer= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user