Pass -1 not C.TIME_UNSET when duration is unknown

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179165479
This commit is contained in:
andrewlewis 2017-12-15 02:17:30 -08:00 committed by Oliver Woodman
parent 403f773f87
commit b97ce44182

View File

@ -151,6 +151,9 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
private static final String IMA_SDK_SETTINGS_PLAYER_TYPE = "google/exo.ext.ima"; private static final String IMA_SDK_SETTINGS_PLAYER_TYPE = "google/exo.ext.ima";
private static final String IMA_SDK_SETTINGS_PLAYER_VERSION = ExoPlayerLibraryInfo.VERSION; 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 * Threshold before the end of content at which IMA is notified that content is complete if the
* player buffers, in milliseconds. * player buffers, in milliseconds.
@ -533,6 +536,8 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
@Override @Override
public VideoProgressUpdate getContentProgress() { public VideoProgressUpdate getContentProgress() {
boolean hasContentDuration = contentDurationMs != C.TIME_UNSET;
long contentDurationMs = hasContentDuration ? this.contentDurationMs : IMA_DURATION_UNSET;
if (player == null) { if (player == null) {
return lastContentProgress; return lastContentProgress;
} else if (pendingContentPositionMs != C.TIME_UNSET) { } else if (pendingContentPositionMs != C.TIME_UNSET) {
@ -542,7 +547,7 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
long elapsedSinceEndMs = SystemClock.elapsedRealtime() - fakeContentProgressElapsedRealtimeMs; long elapsedSinceEndMs = SystemClock.elapsedRealtime() - fakeContentProgressElapsedRealtimeMs;
long fakePositionMs = fakeContentProgressOffsetMs + elapsedSinceEndMs; long fakePositionMs = fakeContentProgressOffsetMs + elapsedSinceEndMs;
return new VideoProgressUpdate(fakePositionMs, contentDurationMs); return new VideoProgressUpdate(fakePositionMs, contentDurationMs);
} else if (playingAd || contentDurationMs == C.TIME_UNSET) { } else if (playingAd || !hasContentDuration) {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY; return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
} else { } else {
return new VideoProgressUpdate(player.getCurrentPosition(), contentDurationMs); return new VideoProgressUpdate(player.getCurrentPosition(), contentDurationMs);