mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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:
parent
8759874924
commit
f1126ce514
2 changed files with 19 additions and 9 deletions
|
|
@ -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
|
||||||
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(
|
||||||
Log.d(TAG, "Content progress: not ready");
|
TAG,
|
||||||
} else {
|
"Content progress: " + ImaUtil.getStringForVideoProgressUpdate(videoProgressUpdate));
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
Util.formatInvariant(
|
|
||||||
"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;
|
||||||
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;
|
||||||
|| 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() {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue