Skip to content

Commit

Permalink
Pass -1 not C.TIME_UNSET when duration is unknown
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179165479
  • Loading branch information
andrewlewis authored and ojw28 committed Dec 15, 2017
1 parent 403f773 commit b97ce44
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ public ImaAdsLoader buildForAdsResponse(String adsResponse) {
private static final String IMA_SDK_SETTINGS_PLAYER_TYPE = "google/exo.ext.ima";
private static final String IMA_SDK_SETTINGS_PLAYER_VERSION = ExoPlayerLibraryInfo.VERSION;

/** The value used in {@link VideoProgressUpdate}s to indicate an unset duration. */
private static final long IMA_DURATION_UNSET = -1L;

/**
* Threshold before the end of content at which IMA is notified that content is complete if the
* player buffers, in milliseconds.
Expand Down Expand Up @@ -533,6 +536,8 @@ public void onAdError(AdErrorEvent adErrorEvent) {

@Override
public VideoProgressUpdate getContentProgress() {
boolean hasContentDuration = contentDurationMs != C.TIME_UNSET;
long contentDurationMs = hasContentDuration ? this.contentDurationMs : IMA_DURATION_UNSET;
if (player == null) {
return lastContentProgress;
} else if (pendingContentPositionMs != C.TIME_UNSET) {
Expand All @@ -542,7 +547,7 @@ public VideoProgressUpdate getContentProgress() {
long elapsedSinceEndMs = SystemClock.elapsedRealtime() - fakeContentProgressElapsedRealtimeMs;
long fakePositionMs = fakeContentProgressOffsetMs + elapsedSinceEndMs;
return new VideoProgressUpdate(fakePositionMs, contentDurationMs);
} else if (playingAd || contentDurationMs == C.TIME_UNSET) {
} else if (playingAd || !hasContentDuration) {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
} else {
return new VideoProgressUpdate(player.getCurrentPosition(), contentDurationMs);
Expand Down

0 comments on commit b97ce44

Please sign in to comment.