mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Use resolved position for masking when seeking to C.TIME_UNSET
Also fire onPositionDiscontinuity in this case ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174039483
This commit is contained in:
parent
37d33f58af
commit
72b6791660
1 changed files with 8 additions and 13 deletions
|
|
@ -251,31 +251,26 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
pendingSeekAcks++;
|
pendingSeekAcks++;
|
||||||
maskingWindowIndex = windowIndex;
|
maskingWindowIndex = windowIndex;
|
||||||
if (timeline.isEmpty()) {
|
if (timeline.isEmpty()) {
|
||||||
|
maskingWindowPositionMs = positionMs == C.TIME_UNSET ? 0 : positionMs;
|
||||||
maskingPeriodIndex = 0;
|
maskingPeriodIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
timeline.getWindow(windowIndex, window);
|
timeline.getWindow(windowIndex, window);
|
||||||
long resolvedPositionUs =
|
long windowPositionUs = positionMs == C.TIME_UNSET ? window.getDefaultPositionUs()
|
||||||
positionMs == C.TIME_UNSET ? window.getDefaultPositionUs() : C.msToUs(positionMs);
|
: C.msToUs(positionMs);
|
||||||
int periodIndex = window.firstPeriodIndex;
|
int periodIndex = window.firstPeriodIndex;
|
||||||
long periodPositionUs = window.getPositionInFirstPeriodUs() + resolvedPositionUs;
|
long periodPositionUs = window.getPositionInFirstPeriodUs() + windowPositionUs;
|
||||||
long periodDurationUs = timeline.getPeriod(periodIndex, period).getDurationUs();
|
long periodDurationUs = timeline.getPeriod(periodIndex, period).getDurationUs();
|
||||||
while (periodDurationUs != C.TIME_UNSET && periodPositionUs >= periodDurationUs
|
while (periodDurationUs != C.TIME_UNSET && periodPositionUs >= periodDurationUs
|
||||||
&& periodIndex < window.lastPeriodIndex) {
|
&& periodIndex < window.lastPeriodIndex) {
|
||||||
periodPositionUs -= periodDurationUs;
|
periodPositionUs -= periodDurationUs;
|
||||||
periodDurationUs = timeline.getPeriod(++periodIndex, period).getDurationUs();
|
periodDurationUs = timeline.getPeriod(++periodIndex, period).getDurationUs();
|
||||||
}
|
}
|
||||||
|
maskingWindowPositionMs = C.usToMs(windowPositionUs);
|
||||||
maskingPeriodIndex = periodIndex;
|
maskingPeriodIndex = periodIndex;
|
||||||
}
|
}
|
||||||
if (positionMs == C.TIME_UNSET) {
|
internalPlayer.seekTo(timeline, windowIndex, C.msToUs(positionMs));
|
||||||
// TODO: Work out when to call onPositionDiscontinuity on listeners for this case.
|
for (Player.EventListener listener : listeners) {
|
||||||
maskingWindowPositionMs = 0;
|
listener.onPositionDiscontinuity(DISCONTINUITY_REASON_SEEK);
|
||||||
internalPlayer.seekTo(timeline, windowIndex, C.TIME_UNSET);
|
|
||||||
} else {
|
|
||||||
maskingWindowPositionMs = positionMs;
|
|
||||||
internalPlayer.seekTo(timeline, windowIndex, C.msToUs(positionMs));
|
|
||||||
for (Player.EventListener listener : listeners) {
|
|
||||||
listener.onPositionDiscontinuity(DISCONTINUITY_REASON_SEEK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue