mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Fix position reporting during ads when period has non-zero window offset.
Reporting incorrect positions for ad playbacks was causing IMA to think the ad wasn't playing, when in fact it was. Issue: #3180 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=167702032
This commit is contained in:
parent
d187d294e5
commit
8719d41e34
2 changed files with 15 additions and 6 deletions
|
|
@ -430,7 +430,9 @@ public final class ImaAdsLoader implements Player.EventListener, VideoAdPlayer,
|
|||
} else if (!playingAd) {
|
||||
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
|
||||
} else {
|
||||
return new VideoProgressUpdate(player.getCurrentPosition(), player.getDuration());
|
||||
long adDuration = player.getDuration();
|
||||
return adDuration == C.TIME_UNSET ? VideoProgressUpdate.VIDEO_TIME_NOT_READY
|
||||
: new VideoProgressUpdate(player.getCurrentPosition(), adDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -319,8 +319,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||
return maskingWindowPositionMs;
|
||||
} else {
|
||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
||||
return period.getPositionInWindowMs() + C.usToMs(playbackInfo.positionUs);
|
||||
return playbackInfoPositionUsToWindowPositionMs(playbackInfo.positionUs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -330,8 +329,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||
return maskingWindowPositionMs;
|
||||
} else {
|
||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
||||
return period.getPositionInWindowMs() + C.usToMs(playbackInfo.bufferedPositionUs);
|
||||
return playbackInfoPositionUsToWindowPositionMs(playbackInfo.bufferedPositionUs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +356,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
|
||||
@Override
|
||||
public boolean isPlayingAd() {
|
||||
return pendingSeekAcks == 0 && playbackInfo.periodId.adGroupIndex != C.INDEX_UNSET;
|
||||
return pendingSeekAcks == 0 && playbackInfo.periodId.isAd();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -512,4 +510,13 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
}
|
||||
}
|
||||
|
||||
private long playbackInfoPositionUsToWindowPositionMs(long positionUs) {
|
||||
long positionMs = C.usToMs(positionUs);
|
||||
if (!playbackInfo.periodId.isAd()) {
|
||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
||||
positionMs += period.getPositionInWindowMs();
|
||||
}
|
||||
return positionMs;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue