Improve progress update logs

Add logging for ad progress and switch from deprecated getters to new
millisecond getters.

PiperOrigin-RevId: 339226534
This commit is contained in:
andrewlewis 2020-10-27 12:01:10 +00:00 committed by Ian Baker
parent 8759874924
commit f1126ce514
2 changed files with 19 additions and 9 deletions

View file

@ -1119,6 +1119,10 @@ public final class ImaAdsLoader
private void updateAdProgress() {
VideoProgressUpdate videoProgressUpdate = getAdVideoProgressUpdate();
if (configuration.debugModeEnabled) {
Log.d(TAG, "Ad progress: " + ImaUtil.getStringForVideoProgressUpdate(videoProgressUpdate));
}
AdMediaInfo adMediaInfo = checkNotNull(imaAdMediaInfo);
for (int i = 0; i < adCallbacks.size(); i++) {
adCallbacks.get(i).onAdProgress(adMediaInfo, videoProgressUpdate);
@ -1730,15 +1734,9 @@ public final class ImaAdsLoader
public VideoProgressUpdate getContentProgress() {
VideoProgressUpdate videoProgressUpdate = getContentVideoProgressUpdate();
if (configuration.debugModeEnabled) {
if (VideoProgressUpdate.VIDEO_TIME_NOT_READY.equals(videoProgressUpdate)) {
Log.d(TAG, "Content progress: not ready");
} else {
Log.d(
TAG,
Util.formatInvariant(
"Content progress: %.1f of %.1f s",
videoProgressUpdate.getCurrentTime(), videoProgressUpdate.getDuration()));
}
Log.d(
TAG,
"Content progress: " + ImaUtil.getStringForVideoProgressUpdate(videoProgressUpdate));
}
if (waitingForPreloadElapsedRealtimeMs != C.TIME_UNSET) {

View file

@ -33,6 +33,7 @@ import com.google.ads.interactivemedia.v3.api.FriendlyObstructionPurpose;
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
import com.google.ads.interactivemedia.v3.api.UiElement;
import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer;
import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.source.ads.AdPlaybackState;
import com.google.android.exoplayer2.source.ads.AdsLoader.OverlayInfo;
@ -202,5 +203,16 @@ import java.util.Set;
|| adError.getErrorCode() == AdError.AdErrorCode.UNKNOWN_ERROR;
}
/** Returns a human-readable representation of a video progress update. */
public static String getStringForVideoProgressUpdate(VideoProgressUpdate videoProgressUpdate) {
if (VideoProgressUpdate.VIDEO_TIME_NOT_READY.equals(videoProgressUpdate)) {
return "not ready";
} else {
return Util.formatInvariant(
"%d ms of %d ms",
videoProgressUpdate.getCurrentTimeMs(), videoProgressUpdate.getDurationMs());
}
}
private ImaUtil() {}
}