Commit 1c4653f7 by andrewlewis Committed by Oliver Woodman

Improve progress update logs

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

PiperOrigin-RevId: 339226534
parent aee7e608
...@@ -1119,6 +1119,10 @@ public final class ImaAdsLoader ...@@ -1119,6 +1119,10 @@ public final class ImaAdsLoader
private void updateAdProgress() { private void updateAdProgress() {
VideoProgressUpdate videoProgressUpdate = getAdVideoProgressUpdate(); VideoProgressUpdate videoProgressUpdate = getAdVideoProgressUpdate();
if (configuration.debugModeEnabled) {
Log.d(TAG, "Ad progress: " + ImaUtil.getStringForVideoProgressUpdate(videoProgressUpdate));
}
AdMediaInfo adMediaInfo = checkNotNull(imaAdMediaInfo); AdMediaInfo adMediaInfo = checkNotNull(imaAdMediaInfo);
for (int i = 0; i < adCallbacks.size(); i++) { for (int i = 0; i < adCallbacks.size(); i++) {
adCallbacks.get(i).onAdProgress(adMediaInfo, videoProgressUpdate); adCallbacks.get(i).onAdProgress(adMediaInfo, videoProgressUpdate);
...@@ -1730,15 +1734,9 @@ public final class ImaAdsLoader ...@@ -1730,15 +1734,9 @@ public final class ImaAdsLoader
public VideoProgressUpdate getContentProgress() { public VideoProgressUpdate getContentProgress() {
VideoProgressUpdate videoProgressUpdate = getContentVideoProgressUpdate(); VideoProgressUpdate videoProgressUpdate = getContentVideoProgressUpdate();
if (configuration.debugModeEnabled) { if (configuration.debugModeEnabled) {
if (VideoProgressUpdate.VIDEO_TIME_NOT_READY.equals(videoProgressUpdate)) {
Log.d(TAG, "Content progress: not ready");
} else {
Log.d( Log.d(
TAG, TAG,
Util.formatInvariant( "Content progress: " + ImaUtil.getStringForVideoProgressUpdate(videoProgressUpdate));
"Content progress: %.1f of %.1f s",
videoProgressUpdate.getCurrentTime(), videoProgressUpdate.getDuration()));
}
} }
if (waitingForPreloadElapsedRealtimeMs != C.TIME_UNSET) { if (waitingForPreloadElapsedRealtimeMs != C.TIME_UNSET) {
......
...@@ -33,6 +33,7 @@ import com.google.ads.interactivemedia.v3.api.FriendlyObstructionPurpose; ...@@ -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.ImaSdkSettings;
import com.google.ads.interactivemedia.v3.api.UiElement; 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.VideoAdPlayer;
import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.source.ads.AdPlaybackState; import com.google.android.exoplayer2.source.ads.AdPlaybackState;
import com.google.android.exoplayer2.source.ads.AdsLoader.OverlayInfo; import com.google.android.exoplayer2.source.ads.AdsLoader.OverlayInfo;
...@@ -202,5 +203,16 @@ import java.util.Set; ...@@ -202,5 +203,16 @@ import java.util.Set;
|| adError.getErrorCode() == AdError.AdErrorCode.UNKNOWN_ERROR; || 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() {} private ImaUtil() {}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment