mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
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
df10fdf773
commit
67c99e1d11
2 changed files with 6 additions and 11 deletions
|
|
@ -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…
Reference in a new issue