Move DefaultMediaSourceFactory.AdsLoaderProvider to AdsLoader.Provider
Keep the old interface deprecated so any app code implementing it by name (rather than with a lambda) will continue to work. PiperOrigin-RevId: 416816566
This commit is contained in:
parent
a24ffbd21b
commit
2fad15a815
@ -99,23 +99,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
@UnstableApi
|
@UnstableApi
|
||||||
public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
|
|
||||||
/**
|
/** @deprecated Use {@link AdsLoader.Provider} instead. */
|
||||||
* Provides {@link AdsLoader} instances for media items that have {@link
|
@Deprecated
|
||||||
* MediaItem.LocalConfiguration#adsConfiguration ad tag URIs}.
|
public interface AdsLoaderProvider extends AdsLoader.Provider {}
|
||||||
*/
|
|
||||||
public interface AdsLoaderProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an {@link AdsLoader} for the given {@link
|
|
||||||
* MediaItem.LocalConfiguration#adsConfiguration ads configuration}, or {@code null} if no ads
|
|
||||||
* loader is available for the given ads configuration.
|
|
||||||
*
|
|
||||||
* <p>This method is called each time a {@link MediaSource} is created from a {@link MediaItem}
|
|
||||||
* that defines an {@link MediaItem.LocalConfiguration#adsConfiguration ads configuration}.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
AdsLoader getAdsLoader(MediaItem.AdsConfiguration adsConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String TAG = "DMediaSourceFactory";
|
private static final String TAG = "DMediaSourceFactory";
|
||||||
|
|
||||||
@ -123,7 +109,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
private final DelegateFactoryLoader delegateFactoryLoader;
|
private final DelegateFactoryLoader delegateFactoryLoader;
|
||||||
|
|
||||||
@Nullable private final MediaSourceFactory serverSideDaiMediaSourceFactory;
|
@Nullable private final MediaSourceFactory serverSideDaiMediaSourceFactory;
|
||||||
@Nullable private AdsLoaderProvider adsLoaderProvider;
|
@Nullable private AdsLoader.Provider adsLoaderProvider;
|
||||||
@Nullable private AdViewProvider adViewProvider;
|
@Nullable private AdViewProvider adViewProvider;
|
||||||
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private long liveTargetOffsetMs;
|
private long liveTargetOffsetMs;
|
||||||
@ -213,14 +199,14 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link AdsLoaderProvider} that provides {@link AdsLoader} instances for media items
|
* Sets the {@link AdsLoader.Provider} that provides {@link AdsLoader} instances for media items
|
||||||
* that have {@link MediaItem.LocalConfiguration#adsConfiguration ads configurations}.
|
* that have {@link MediaItem.LocalConfiguration#adsConfiguration ads configurations}.
|
||||||
*
|
*
|
||||||
* @param adsLoaderProvider A provider for {@link AdsLoader} instances.
|
* @param adsLoaderProvider A provider for {@link AdsLoader} instances.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
*/
|
*/
|
||||||
public DefaultMediaSourceFactory setAdsLoaderProvider(
|
public DefaultMediaSourceFactory setAdsLoaderProvider(
|
||||||
@Nullable AdsLoaderProvider adsLoaderProvider) {
|
@Nullable AdsLoader.Provider adsLoaderProvider) {
|
||||||
this.adsLoaderProvider = adsLoaderProvider;
|
this.adsLoaderProvider = adsLoaderProvider;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -459,7 +445,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
if (adsConfiguration == null) {
|
if (adsConfiguration == null) {
|
||||||
return mediaSource;
|
return mediaSource;
|
||||||
}
|
}
|
||||||
@Nullable AdsLoaderProvider adsLoaderProvider = this.adsLoaderProvider;
|
@Nullable AdsLoader.Provider adsLoaderProvider = this.adsLoaderProvider;
|
||||||
@Nullable AdViewProvider adViewProvider = this.adViewProvider;
|
@Nullable AdViewProvider adViewProvider = this.adViewProvider;
|
||||||
if (adsLoaderProvider == null || adViewProvider == null) {
|
if (adsLoaderProvider == null || adViewProvider == null) {
|
||||||
Log.w(
|
Log.w(
|
||||||
|
@ -19,9 +19,11 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.media3.common.AdPlaybackState;
|
import androidx.media3.common.AdPlaybackState;
|
||||||
import androidx.media3.common.AdViewProvider;
|
import androidx.media3.common.AdViewProvider;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.Player;
|
import androidx.media3.common.Player;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.datasource.DataSpec;
|
import androidx.media3.datasource.DataSpec;
|
||||||
|
import androidx.media3.exoplayer.source.MediaSource;
|
||||||
import androidx.media3.exoplayer.source.ads.AdsMediaSource.AdLoadException;
|
import androidx.media3.exoplayer.source.ads.AdsMediaSource.AdLoadException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -48,6 +50,24 @@ import java.io.IOException;
|
|||||||
@UnstableApi
|
@UnstableApi
|
||||||
public interface AdsLoader {
|
public interface AdsLoader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides {@link AdsLoader} instances for media items that have {@link
|
||||||
|
* MediaItem.LocalConfiguration#adsConfiguration ad tag URIs}.
|
||||||
|
*/
|
||||||
|
interface Provider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an {@link AdsLoader} for the given {@link
|
||||||
|
* MediaItem.LocalConfiguration#adsConfiguration ads configuration}, or {@code null} if no ads
|
||||||
|
* loader is available for the given ads configuration.
|
||||||
|
*
|
||||||
|
* <p>This method is called each time a {@link MediaSource} is created from a {@link MediaItem}
|
||||||
|
* that defines an {@link MediaItem.LocalConfiguration#adsConfiguration ads configuration}.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
AdsLoader getAdsLoader(MediaItem.AdsConfiguration adsConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
/** Listener for ads loader events. All methods are called on the main thread. */
|
/** Listener for ads loader events. All methods are called on the main thread. */
|
||||||
interface EventListener {
|
interface EventListener {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user