mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
8ef6a2e7bd
commit
17232f58a3
2 changed files with 15 additions and 6 deletions
|
|
@ -430,7 +430,9 @@ public final class ImaAdsLoader implements Player.EventListener, VideoAdPlayer,
|
||||||
} else if (!playingAd) {
|
} else if (!playingAd) {
|
||||||
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
|
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -349,8 +349,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||||
return maskingWindowPositionMs;
|
return maskingWindowPositionMs;
|
||||||
} else {
|
} else {
|
||||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
return playbackInfoPositionUsToWindowPositionMs(playbackInfo.positionUs);
|
||||||
return period.getPositionInWindowMs() + C.usToMs(playbackInfo.positionUs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,8 +359,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||||
return maskingWindowPositionMs;
|
return maskingWindowPositionMs;
|
||||||
} else {
|
} else {
|
||||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
return playbackInfoPositionUsToWindowPositionMs(playbackInfo.bufferedPositionUs);
|
||||||
return period.getPositionInWindowMs() + C.usToMs(playbackInfo.bufferedPositionUs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -388,7 +386,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayingAd() {
|
public boolean isPlayingAd() {
|
||||||
return pendingSeekAcks == 0 && playbackInfo.periodId.adGroupIndex != C.INDEX_UNSET;
|
return pendingSeekAcks == 0 && playbackInfo.periodId.isAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -542,4 +540,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