mirror of
https://github.com/samsonjs/media.git
synced 2026-04-15 12:55:46 +00:00
Reset period position when resetState=True.
This is more in line with "forgetting all previous state" as documented for resetState=True. Also only apply the current position as initial seek position in this case. PiperOrigin-RevId: 236623630
This commit is contained in:
parent
7a1b8a9585
commit
28c7cb3716
2 changed files with 16 additions and 8 deletions
|
|
@ -661,6 +661,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
maskingPeriodIndex = getCurrentPeriodIndex();
|
||||
maskingWindowPositionMs = getCurrentPosition();
|
||||
}
|
||||
// Also reset period-based PlaybackInfo positions if resetting the state.
|
||||
resetPosition = resetPosition || resetState;
|
||||
MediaPeriodId mediaPeriodId =
|
||||
resetPosition
|
||||
? playbackInfo.getDummyFirstMediaPeriodId(shuffleModeEnabled, window)
|
||||
|
|
|
|||
|
|
@ -436,12 +436,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
private void prepareInternal(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
|
||||
pendingPrepareCount++;
|
||||
if (!resetPosition && pendingInitialSeekPosition == null && !playbackInfo.timeline.isEmpty()) {
|
||||
playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period);
|
||||
long windowPositionUs = playbackInfo.positionUs + period.getPositionInWindowUs();
|
||||
pendingInitialSeekPosition =
|
||||
new SeekPosition(Timeline.EMPTY, period.windowIndex, windowPositionUs);
|
||||
}
|
||||
resetInternal(
|
||||
/* resetRenderers= */ false, /* releaseMediaSource= */ true, resetPosition, resetState);
|
||||
loadControl.onPrepared();
|
||||
|
|
@ -864,11 +858,23 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
}
|
||||
}
|
||||
enabledRenderers = new Renderer[0];
|
||||
queue.clear(/* keepFrontPeriodUid= */ !resetPosition);
|
||||
setIsLoading(false);
|
||||
|
||||
if (resetPosition) {
|
||||
pendingInitialSeekPosition = null;
|
||||
} else if (resetState) {
|
||||
// When resetting the state, also reset the period-based PlaybackInfo position and convert
|
||||
// existing position to initial seek instead.
|
||||
resetPosition = true;
|
||||
if (pendingInitialSeekPosition == null && !playbackInfo.timeline.isEmpty()) {
|
||||
playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period);
|
||||
long windowPositionUs = playbackInfo.positionUs + period.getPositionInWindowUs();
|
||||
pendingInitialSeekPosition =
|
||||
new SeekPosition(Timeline.EMPTY, period.windowIndex, windowPositionUs);
|
||||
}
|
||||
}
|
||||
|
||||
queue.clear(/* keepFrontPeriodUid= */ !resetPosition);
|
||||
setIsLoading(false);
|
||||
if (resetState) {
|
||||
queue.setTimeline(Timeline.EMPTY);
|
||||
for (PendingMessageInfo pendingMessageInfo : pendingMessages) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue