From 199b9d1689e1a389ba713f23d489a864fef97b95 Mon Sep 17 00:00:00 2001 From: olly Date: Thu, 8 Apr 2021 14:04:23 +0100 Subject: [PATCH] Convergence: Continue decoupling UI from Core Move AdsLoader inner classes that are also required by the UI module into common. PiperOrigin-RevId: 367414679 --- .../exoplayer2/ext/ima/ImaPlaybackTest.java | 17 +--- .../exoplayer2/ext/ima/AdTagLoader.java | 6 +- .../exoplayer2/ext/ima/ImaAdsLoader.java | 1 + .../android/exoplayer2/ext/ima/ImaUtil.java | 14 +-- .../exoplayer2/ext/ima/ImaAdsLoaderTest.java | 25 ++--- .../android/exoplayer2/ui/AdOverlayInfo.java | 74 ++++++++++++++ .../android/exoplayer2/ui/AdViewProvider.java | 48 +++++++++ .../android/exoplayer2/ui/package-info.java | 0 .../source/DefaultMediaSourceFactory.java | 2 +- .../exoplayer2/source/ads/AdsLoader.java | 97 +------------------ .../exoplayer2/source/ads/AdsMediaSource.java | 5 +- .../source/DefaultMediaSourceFactoryTest.java | 3 +- .../source/ads/AdsMediaSourceTest.java | 2 +- .../android/exoplayer2/ui/PlayerView.java | 14 ++- .../exoplayer2/ui/StyledPlayerView.java | 14 ++- 15 files changed, 162 insertions(+), 160 deletions(-) create mode 100644 library/common/src/main/java/com/google/android/exoplayer2/ui/AdOverlayInfo.java create mode 100644 library/common/src/main/java/com/google/android/exoplayer2/ui/AdViewProvider.java rename library/{ui => common}/src/main/java/com/google/android/exoplayer2/ui/package-info.java (100%) diff --git a/extensions/ima/src/androidTest/java/com/google/android/exoplayer2/ext/ima/ImaPlaybackTest.java b/extensions/ima/src/androidTest/java/com/google/android/exoplayer2/ext/ima/ImaPlaybackTest.java index 839c832951..aaa3cdc696 100644 --- a/extensions/ima/src/androidTest/java/com/google/android/exoplayer2/ext/ima/ImaPlaybackTest.java +++ b/extensions/ima/src/androidTest/java/com/google/android/exoplayer2/ext/ima/ImaPlaybackTest.java @@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat; import android.content.Context; import android.net.Uri; import android.view.Surface; -import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.Nullable; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -38,8 +37,6 @@ import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.ads.AdsLoader; -import com.google.android.exoplayer2.source.ads.AdsLoader.AdViewProvider; import com.google.android.exoplayer2.source.ads.AdsMediaSource; import com.google.android.exoplayer2.testutil.ActionSchedule; import com.google.android.exoplayer2.testutil.ExoHostedTest; @@ -51,7 +48,6 @@ import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; -import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -251,18 +247,7 @@ public final class ImaPlaybackTest { /* adsId= */ adTagDataSpec.uri, new DefaultMediaSourceFactory(dataSourceFactory), Assertions.checkNotNull(imaAdsLoader), - new AdViewProvider() { - - @Override - public ViewGroup getAdViewGroup() { - return overlayFrameLayout; - } - - @Override - public ImmutableList getAdOverlayInfos() { - return ImmutableList.of(); - } - }); + () -> overlayFrameLayout); } @Override diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java index c7722a6012..048321de3d 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java @@ -55,12 +55,12 @@ import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.source.ads.AdPlaybackState; -import com.google.android.exoplayer2.source.ads.AdsLoader.AdViewProvider; import com.google.android.exoplayer2.source.ads.AdsLoader.EventListener; -import com.google.android.exoplayer2.source.ads.AdsLoader.OverlayInfo; import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionUtil; +import com.google.android.exoplayer2.ui.AdOverlayInfo; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Util; @@ -318,7 +318,7 @@ import java.util.Map; new AdPlaybackState(adsId, getAdGroupTimesUsForCuePoints(adsManager.getAdCuePoints())); updateAdPlaybackState(); } - for (OverlayInfo overlayInfo : adViewProvider.getAdOverlayInfos()) { + for (AdOverlayInfo overlayInfo : adViewProvider.getAdOverlayInfos()) { adDisplayContainer.registerFriendlyObstruction( imaFactory.createFriendlyObstruction( overlayInfo.view, 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 b6e822cc34..f015042927 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 @@ -48,6 +48,7 @@ import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.source.MediaSourceFactory; import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsMediaSource; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; 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 0324e93713..377a9c4db8 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 @@ -36,7 +36,7 @@ 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.AdsLoader.OverlayInfo; +import com.google.android.exoplayer2.ui.AdOverlayInfo; import com.google.android.exoplayer2.upstream.DataSchemeDataSource; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.util.Util; @@ -138,18 +138,18 @@ import java.util.Set; /** * Returns the IMA {@link FriendlyObstructionPurpose} corresponding to the given {@link - * OverlayInfo#purpose}. + * AdOverlayInfo#purpose}. */ public static FriendlyObstructionPurpose getFriendlyObstructionPurpose( - @OverlayInfo.Purpose int purpose) { + @AdOverlayInfo.Purpose int purpose) { switch (purpose) { - case OverlayInfo.PURPOSE_CONTROLS: + case AdOverlayInfo.PURPOSE_CONTROLS: return FriendlyObstructionPurpose.VIDEO_CONTROLS; - case OverlayInfo.PURPOSE_CLOSE_AD: + case AdOverlayInfo.PURPOSE_CLOSE_AD: return FriendlyObstructionPurpose.CLOSE_AD; - case OverlayInfo.PURPOSE_NOT_VISIBLE: + case AdOverlayInfo.PURPOSE_NOT_VISIBLE: return FriendlyObstructionPurpose.NOT_VISIBLE; - case OverlayInfo.PURPOSE_OTHER: + case AdOverlayInfo.PURPOSE_OTHER: default: return FriendlyObstructionPurpose.OTHER; } diff --git a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java index 5e9ba805d2..6b62b38e4d 100644 --- a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java +++ b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java @@ -68,6 +68,8 @@ import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException; import com.google.android.exoplayer2.testutil.FakeMediaSource; import com.google.android.exoplayer2.testutil.FakeTimeline; import com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition; +import com.google.android.exoplayer2.ui.AdOverlayInfo; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; @@ -129,8 +131,8 @@ public final class ImaAdsLoaderTest { private TimelineWindowDefinition[] timelineWindowDefinitions; private AdsMediaSource adsMediaSource; private ViewGroup adViewGroup; - private AdsLoader.AdViewProvider adViewProvider; - private AdsLoader.AdViewProvider audioAdsAdViewProvider; + private AdViewProvider adViewProvider; + private AdViewProvider audioAdsAdViewProvider; private AdEvent.AdEventListener adEventListener; private ContentProgressProvider contentProgressProvider; private VideoAdPlayer videoAdPlayer; @@ -145,30 +147,19 @@ public final class ImaAdsLoaderTest { adViewGroup = new FrameLayout(getApplicationContext()); View adOverlayView = new View(getApplicationContext()); adViewProvider = - new AdsLoader.AdViewProvider() { + new AdViewProvider() { @Override public ViewGroup getAdViewGroup() { return adViewGroup; } @Override - public ImmutableList getAdOverlayInfos() { + public ImmutableList getAdOverlayInfos() { return ImmutableList.of( - new AdsLoader.OverlayInfo(adOverlayView, AdsLoader.OverlayInfo.PURPOSE_CLOSE_AD)); - } - }; - audioAdsAdViewProvider = - new AdsLoader.AdViewProvider() { - @Override - public ViewGroup getAdViewGroup() { - return null; - } - - @Override - public ImmutableList getAdOverlayInfos() { - return ImmutableList.of(); + new AdOverlayInfo(adOverlayView, AdOverlayInfo.PURPOSE_CLOSE_AD)); } }; + audioAdsAdViewProvider = () -> null; imaAdsLoader = new ImaAdsLoader.Builder(getApplicationContext()) .setImaFactory(mockImaFactory) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ui/AdOverlayInfo.java b/library/common/src/main/java/com/google/android/exoplayer2/ui/AdOverlayInfo.java new file mode 100644 index 0000000000..b3eee8970a --- /dev/null +++ b/library/common/src/main/java/com/google/android/exoplayer2/ui/AdOverlayInfo.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.ui; + +import android.view.View; +import androidx.annotation.IntDef; +import androidx.annotation.Nullable; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** Provides information about an overlay view shown on top of an ad view group. */ +public final class AdOverlayInfo { + + /** + * The purpose of the overlay. One of {@link #PURPOSE_CONTROLS}, {@link #PURPOSE_CLOSE_AD}, {@link + * #PURPOSE_OTHER} or {@link #PURPOSE_NOT_VISIBLE}. + */ + @Documented + @Retention(RetentionPolicy.SOURCE) + @IntDef({PURPOSE_CONTROLS, PURPOSE_CLOSE_AD, PURPOSE_OTHER, PURPOSE_NOT_VISIBLE}) + public @interface Purpose {} + /** Purpose for playback controls overlaying the player. */ + public static final int PURPOSE_CONTROLS = 0; + /** Purpose for ad close buttons overlaying the player. */ + public static final int PURPOSE_CLOSE_AD = 1; + /** Purpose for other overlays. */ + public static final int PURPOSE_OTHER = 2; + /** Purpose for overlays that are not visible. */ + public static final int PURPOSE_NOT_VISIBLE = 3; + + /** The overlay view. */ + public final View view; + /** The purpose of the overlay view. */ + @Purpose public final int purpose; + /** An optional, detailed reason that the overlay view is needed. */ + @Nullable public final String reasonDetail; + + /** + * Creates a new overlay info. + * + * @param view The view that is overlaying the player. + * @param purpose The purpose of the view. + */ + public AdOverlayInfo(View view, @Purpose int purpose) { + this(view, purpose, /* detailedReason= */ null); + } + + /** + * Creates a new overlay info. + * + * @param view The view that is overlaying the player. + * @param purpose The purpose of the view. + * @param detailedReason An optional, detailed reason that the view is on top of the player. + */ + public AdOverlayInfo(View view, @Purpose int purpose, @Nullable String detailedReason) { + this.view = view; + this.purpose = purpose; + this.reasonDetail = detailedReason; + } +} diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ui/AdViewProvider.java b/library/common/src/main/java/com/google/android/exoplayer2/ui/AdViewProvider.java new file mode 100644 index 0000000000..dd6fa84184 --- /dev/null +++ b/library/common/src/main/java/com/google/android/exoplayer2/ui/AdViewProvider.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.ui; + +import android.view.ViewGroup; +import androidx.annotation.Nullable; +import com.google.common.collect.ImmutableList; +import java.util.List; + +/** Provides information about views for the ad playback UI. */ +public interface AdViewProvider { + + /** + * Returns the {@link ViewGroup} on top of the player that will show any ad UI, or {@code null} if + * playing audio-only ads. Any views on top of the returned view group must be described by {@link + * AdOverlayInfo AdOverlayInfos} returned by {@link #getAdOverlayInfos()}, for accurate + * viewability measurement. + */ + @Nullable + ViewGroup getAdViewGroup(); + + /** + * Returns a list of {@link AdOverlayInfo} instances describing views that are on top of the ad + * view group, but that are essential for controlling playback and should be excluded from ad + * viewability measurements. + * + *

Each view must be either a fully transparent overlay (for capturing touch events), or a + * small piece of transient UI that is essential to the user experience of playback (such as a + * button to pause/resume playback or a transient full-screen or cast button). For more + * information see the documentation for your ads loader. + */ + default List getAdOverlayInfos() { + return ImmutableList.of(); + } +} diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/package-info.java b/library/common/src/main/java/com/google/android/exoplayer2/ui/package-info.java similarity index 100% rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/package-info.java rename to library/common/src/main/java/com/google/android/exoplayer2/ui/package-info.java diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java index 31aad16b02..60ecafada9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java @@ -29,8 +29,8 @@ import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; import com.google.android.exoplayer2.extractor.ExtractorsFactory; import com.google.android.exoplayer2.offline.StreamKey; import com.google.android.exoplayer2.source.ads.AdsLoader; -import com.google.android.exoplayer2.source.ads.AdsLoader.AdViewProvider; import com.google.android.exoplayer2.source.ads.AdsMediaSource; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsLoader.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsLoader.java index 86a2cb6ca5..906139cf76 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsLoader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsLoader.java @@ -15,20 +15,13 @@ */ package com.google.android.exoplayer2.source.ads; -import android.view.View; -import android.view.ViewGroup; -import androidx.annotation.IntDef; import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.DataSpec; -import com.google.common.collect.ImmutableList; import java.io.IOException; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.List; /** * Interface for loaders of ads, which can be used with {@link AdsMediaSource}. @@ -78,94 +71,6 @@ public interface AdsLoader { default void onAdTapped() {} } - /** Provides information about views for the ad playback UI. */ - interface AdViewProvider { - - /** - * Returns the {@link ViewGroup} on top of the player that will show any ad UI, or {@code null} - * if playing audio-only ads. Any views on top of the returned view group must be described by - * {@link OverlayInfo OverlayInfos} returned by {@link #getAdOverlayInfos()}, for accurate - * viewability measurement. - */ - @Nullable - ViewGroup getAdViewGroup(); - - /** @deprecated Use {@link #getAdOverlayInfos()} instead. */ - @Deprecated - default View[] getAdOverlayViews() { - return new View[0]; - } - - /** - * Returns a list of {@link OverlayInfo} instances describing views that are on top of the ad - * view group, but that are essential for controlling playback and should be excluded from ad - * viewability measurements by the {@link AdsLoader} (if it supports this). - * - *

Each view must be either a fully transparent overlay (for capturing touch events), or a - * small piece of transient UI that is essential to the user experience of playback (such as a - * button to pause/resume playback or a transient full-screen or cast button). For more - * information see the documentation for your ads loader. - */ - @SuppressWarnings("deprecation") - default List getAdOverlayInfos() { - ImmutableList.Builder listBuilder = new ImmutableList.Builder<>(); - // Call through to deprecated version. - for (View view : getAdOverlayViews()) { - listBuilder.add(new OverlayInfo(view, OverlayInfo.PURPOSE_CONTROLS)); - } - return listBuilder.build(); - } - } - - /** Provides information about an overlay view shown on top of an ad view group. */ - final class OverlayInfo { - - @Documented - @Retention(RetentionPolicy.SOURCE) - @IntDef({PURPOSE_CONTROLS, PURPOSE_CLOSE_AD, PURPOSE_OTHER, PURPOSE_NOT_VISIBLE}) - public @interface Purpose {} - /** Purpose for playback controls overlaying the player. */ - public static final int PURPOSE_CONTROLS = 0; - /** Purpose for ad close buttons overlaying the player. */ - public static final int PURPOSE_CLOSE_AD = 1; - /** Purpose for other overlays. */ - public static final int PURPOSE_OTHER = 2; - /** Purpose for overlays that are not visible. */ - public static final int PURPOSE_NOT_VISIBLE = 3; - - /** The overlay view. */ - public final View view; - /** The purpose of the overlay view. */ - @Purpose public final int purpose; - /** An optional, detailed reason that the overlay view is needed. */ - @Nullable public final String reasonDetail; - - /** - * Creates a new overlay info. - * - * @param view The view that is overlaying the player. - * @param purpose The purpose of the view. - */ - public OverlayInfo(View view, @Purpose int purpose) { - this(view, purpose, /* detailedReason= */ null); - } - - /** - * Creates a new overlay info. - * - * @param view The view that is overlaying the player. - * @param purpose The purpose of the view. - * @param detailedReason An optional, detailed reason that the view is on top of the player. See - * the documentation for the {@link AdsLoader} implementation for more information on this - * string's formatting. - */ - public OverlayInfo(View view, @Purpose int purpose, @Nullable String detailedReason) { - this.view = view; - this.purpose = purpose; - this.reasonDetail = detailedReason; - } - } - // Methods called by the application. /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java index f17ad2d8f5..f9a3daca86 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java @@ -36,6 +36,7 @@ import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSourceEventListener; import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.TransferListener; @@ -128,7 +129,7 @@ public final class AdsMediaSource extends CompositeMediaSource { private final MediaSource contentMediaSource; private final MediaSourceFactory adMediaSourceFactory; private final AdsLoader adsLoader; - private final AdsLoader.AdViewProvider adViewProvider; + private final AdViewProvider adViewProvider; private final DataSpec adTagDataSpec; private final Object adsId; private final Handler mainHandler; @@ -160,7 +161,7 @@ public final class AdsMediaSource extends CompositeMediaSource { Object adsId, MediaSourceFactory adMediaSourceFactory, AdsLoader adsLoader, - AdsLoader.AdViewProvider adViewProvider) { + AdViewProvider adViewProvider) { this.contentMediaSource = contentMediaSource; this.adMediaSourceFactory = adMediaSourceFactory; this.adsLoader = adsLoader; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactoryTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactoryTest.java index 67f06e4f85..72a7c8c638 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactoryTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactoryTest.java @@ -26,6 +26,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsMediaSource; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.util.MimeTypes; import java.util.Arrays; import java.util.Collections; @@ -205,7 +206,7 @@ public final class DefaultMediaSourceFactoryTest { DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()) .setAdsLoaderProvider(ignoredAdsConfiguration -> mock(AdsLoader.class)) - .setAdViewProvider(mock(AdsLoader.AdViewProvider.class)); + .setAdViewProvider(mock(AdViewProvider.class)); MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdsMediaSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdsMediaSourceTest.java index b5748aaa42..1580a39f17 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdsMediaSourceTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdsMediaSourceTest.java @@ -34,9 +34,9 @@ import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource.MediaSourceCaller; import com.google.android.exoplayer2.source.MediaSourceFactory; import com.google.android.exoplayer2.source.SinglePeriodTimeline; -import com.google.android.exoplayer2.source.ads.AdsLoader.AdViewProvider; import com.google.android.exoplayer2.source.ads.AdsLoader.EventListener; import com.google.android.exoplayer2.testutil.FakeMediaSource; +import com.google.android.exoplayer2.ui.AdViewProvider; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.DataSpec; import org.junit.Before; diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index 8823ea0cec..90f6a31d3e 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -54,7 +54,6 @@ import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.flac.PictureFrame; import com.google.android.exoplayer2.metadata.id3.ApicFrame; import com.google.android.exoplayer2.source.TrackGroupArray; -import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; @@ -264,7 +263,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; * PlayerView. This will cause the specified layout to be inflated instead of {@code * exo_player_view.xml} for only the instance on which the attribute is set. */ -public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider { +public class PlayerView extends FrameLayout implements AdViewProvider { // LINT.IfChange /** @@ -1233,18 +1232,17 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider } @Override - public List getAdOverlayInfos() { - List overlayViews = new ArrayList<>(); + public List getAdOverlayInfos() { + List overlayViews = new ArrayList<>(); if (overlayFrameLayout != null) { overlayViews.add( - new AdsLoader.OverlayInfo( + new AdOverlayInfo( overlayFrameLayout, - AdsLoader.OverlayInfo.PURPOSE_NOT_VISIBLE, + AdOverlayInfo.PURPOSE_NOT_VISIBLE, /* detailedReason= */ "Transparent overlay does not impact viewability")); } if (controller != null) { - overlayViews.add( - new AdsLoader.OverlayInfo(controller, AdsLoader.OverlayInfo.PURPOSE_CONTROLS)); + overlayViews.add(new AdOverlayInfo(controller, AdOverlayInfo.PURPOSE_CONTROLS)); } return ImmutableList.copyOf(overlayViews); } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index fcf18e0937..7e87b662f1 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -56,7 +56,6 @@ import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.flac.PictureFrame; import com.google.android.exoplayer2.metadata.id3.ApicFrame; import com.google.android.exoplayer2.source.TrackGroupArray; -import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; @@ -266,7 +265,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; * attribute on a StyledPlayerView. This will cause the specified layout to be inflated instead of * {@code exo_styled_player_view.xml} for only the instance on which the attribute is set. */ -public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewProvider { +public class StyledPlayerView extends FrameLayout implements AdViewProvider { // LINT.IfChange /** @@ -1251,18 +1250,17 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro } @Override - public List getAdOverlayInfos() { - List overlayViews = new ArrayList<>(); + public List getAdOverlayInfos() { + List overlayViews = new ArrayList<>(); if (overlayFrameLayout != null) { overlayViews.add( - new AdsLoader.OverlayInfo( + new AdOverlayInfo( overlayFrameLayout, - AdsLoader.OverlayInfo.PURPOSE_NOT_VISIBLE, + AdOverlayInfo.PURPOSE_NOT_VISIBLE, /* detailedReason= */ "Transparent overlay does not impact viewability")); } if (controller != null) { - overlayViews.add( - new AdsLoader.OverlayInfo(controller, AdsLoader.OverlayInfo.PURPOSE_CONTROLS)); + overlayViews.add(new AdOverlayInfo(controller, AdOverlayInfo.PURPOSE_CONTROLS)); } return ImmutableList.copyOf(overlayViews); }