diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index 265ffe585b..dbfdabaa28 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -15,6 +15,9 @@ */ package com.google.android.exoplayer2.ext.ima; +import static com.google.android.exoplayer2.ext.ima.ImaUtil.BITRATE_UNSET; +import static com.google.android.exoplayer2.ext.ima.ImaUtil.TIMEOUT_UNSET; +import static com.google.android.exoplayer2.ext.ima.ImaUtil.getImaLooper; import static com.google.android.exoplayer2.util.Assertions.checkArgument; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkState; @@ -461,9 +464,6 @@ public final class ImaAdsLoader /** The threshold below which ad cue points are treated as matching, in microseconds. */ private static final long THRESHOLD_AD_MATCH_US = 1000; - private static final int TIMEOUT_UNSET = -1; - private static final int BITRATE_UNSET = -1; - /** The state of ad playback. */ @Documented @Retention(RetentionPolicy.SOURCE) @@ -1661,12 +1661,6 @@ public final class ImaAdsLoader : timeline.getPeriod(/* periodIndex= */ 0, period).getPositionInWindowMs()); } - private static Looper getImaLooper() { - // IMA SDK callbacks occur on the main thread. This method can be used to check that the player - // is using the same looper, to ensure all interaction with this class is on the main thread. - return Looper.getMainLooper(); - } - private static boolean hasMidrollAdGroups(long[] adGroupTimesUs) { int count = adGroupTimesUs.length; if (count == 1) { diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java index 6d69547278..ae12819e84 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java @@ -16,6 +16,7 @@ package com.google.android.exoplayer2.ext.ima; import android.content.Context; +import android.os.Looper; import android.view.View; import android.view.ViewGroup; import androidx.annotation.Nullable; @@ -130,6 +131,9 @@ import java.util.Set; } } + public static final int TIMEOUT_UNSET = -1; + public static final int BITRATE_UNSET = -1; + /** * Returns the IMA {@link FriendlyObstructionPurpose} corresponding to the given {@link * OverlayInfo#purpose}. @@ -203,6 +207,13 @@ import java.util.Set; || adError.getErrorCode() == AdError.AdErrorCode.UNKNOWN_ERROR; } + /** Returns the looper on which all IMA SDK interaction must occur. */ + public static Looper getImaLooper() { + // IMA SDK callbacks occur on the main thread. This method can be used to check that the player + // is using the same looper, to ensure all interaction with this class is on the main thread. + return Looper.getMainLooper(); + } + /** Returns a human-readable representation of a video progress update. */ public static String getStringForVideoProgressUpdate(VideoProgressUpdate videoProgressUpdate) { if (VideoProgressUpdate.VIDEO_TIME_NOT_READY.equals(videoProgressUpdate)) {