Fix resuming postrolls
Postrolls would be skipped because the period duration wasn't know at the moment of resuming playback after backgrounding, so the position wouldn't be resolved to resume the postroll ad. We have the period duration stored in the AdPlaybackState, so we can use that directly. Issue: #7518 PiperOrigin-RevId: 317830418
This commit is contained in:
parent
836babd5d6
commit
093f9931b4
@ -270,7 +270,9 @@ public final class AdPlaybackState {
|
||||
public final AdGroup[] adGroups;
|
||||
/** The position offset in the first unplayed ad at which to begin playback, in microseconds. */
|
||||
public final long adResumePositionUs;
|
||||
/** The content duration in microseconds, if known. {@link C#TIME_UNSET} otherwise. */
|
||||
/**
|
||||
* The duration of the content period in microseconds, if known. {@link C#TIME_UNSET} otherwise.
|
||||
*/
|
||||
public final long contentDurationUs;
|
||||
|
||||
/**
|
||||
|
@ -44,23 +44,16 @@ public final class SinglePeriodAdTimeline extends ForwardingTimeline {
|
||||
@Override
|
||||
public Period getPeriod(int periodIndex, Period period, boolean setIds) {
|
||||
timeline.getPeriod(periodIndex, period, setIds);
|
||||
long durationUs =
|
||||
period.durationUs == C.TIME_UNSET ? adPlaybackState.contentDurationUs : period.durationUs;
|
||||
period.set(
|
||||
period.id,
|
||||
period.uid,
|
||||
period.windowIndex,
|
||||
period.durationUs,
|
||||
durationUs,
|
||||
period.getPositionInWindowUs(),
|
||||
adPlaybackState);
|
||||
return period;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindow(int windowIndex, Window window, long defaultPositionProjectionUs) {
|
||||
window = super.getWindow(windowIndex, window, defaultPositionProjectionUs);
|
||||
if (window.durationUs == C.TIME_UNSET) {
|
||||
window.durationUs = adPlaybackState.contentDurationUs;
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user