diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 9a19edf804..d0aa4d58af 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -44,7 +44,7 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.DecoderInitia import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException; import com.google.android.exoplayer2.offline.DownloadRequest; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; -import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.ui.StyledPlayerControlView; @@ -261,7 +261,7 @@ public class PlayerActivity extends AppCompatActivity intent.getBooleanExtra(IntentUtil.PREFER_EXTENSION_DECODERS_EXTRA, false); RenderersFactory renderersFactory = DemoUtil.buildRenderersFactory(/* context= */ this, preferExtensionDecoders); - MediaSourceFactory mediaSourceFactory = + MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(dataSourceFactory) .setAdsLoaderProvider(this::getAdsLoader) .setAdViewProvider(playerView); diff --git a/docs/ad-insertion.md b/docs/ad-insertion.md index 090d0e49d9..142de570a4 100644 --- a/docs/ad-insertion.md +++ b/docs/ad-insertion.md @@ -49,7 +49,7 @@ build and inject a `DefaultMediaSourceFactory` configured with an `AdsLoader.Provider` and an `AdViewProvider` when creating the player: ~~~ -MediaSourceFactory mediaSourceFactory = +MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(context) .setAdsLoaderProvider(adsLoaderProvider) .setAdViewProvider(playerView); diff --git a/docs/customization.md b/docs/customization.md index 6be6d39e77..5ac250ce72 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -14,10 +14,10 @@ Components common to all `ExoPlayer` implementations are: * `MediaSource` instances that define media to be played, load the media, and from which the loaded media can be read. `MediaSource` instances are created - from `MediaItem`s by a `MediaSourceFactory` inside the player. They can also + from `MediaItem`s by a `MediaSource.Factory` inside the player. They can also be passed directly to the player using the [media source based playlist API]. -* A `MediaSourceFactory` that converts `MediaItem`s to `MediaSource`s. The - `MediaSourceFactory` is injected when the player is created. +* A `MediaSource.Factory` that converts `MediaItem`s to `MediaSource`s. The + `MediaSource.Factory` is injected when the player is created. * `Renderer`s that render individual components of the media. `Renderer`s are injected when the player is created. * A `TrackSelector` that selects tracks provided by the `MediaSource` to be @@ -245,9 +245,9 @@ required. Some use cases for custom implementations are: appropriate if you wish to obtain media samples to feed to renderers in a custom way, or if you wish to implement custom `MediaSource` compositing behavior. -* `MediaSourceFactory` – Implementing a custom `MediaSourceFactory` allows - an application to customize the way in which `MediaSource`s are created from - `MediaItem`s. +* `MediaSource.Factory` – Implementing a custom `MediaSource.Factory` + allows an application to customize the way in which `MediaSource`s are created + from `MediaItem`s. * `DataSource` – ExoPlayer’s upstream package already contains a number of `DataSource` implementations for different use cases. You may want to implement you own `DataSource` class to load data in another way, such as over diff --git a/docs/drm.md b/docs/drm.md index 4b64640989..0ab2118e99 100644 --- a/docs/drm.md +++ b/docs/drm.md @@ -85,7 +85,7 @@ building the media item. If an app wants to customise the `DrmSessionManager` used for playback, they can implement a `DrmSessionManagerProvider` and pass this to the -`MediaSourceFactory` which is [used when building the player]. The provider can +`MediaSource.Factory` which is [used when building the player]. The provider can choose whether to instantiate a new manager instance each time or not. To always use the same instance: @@ -93,7 +93,7 @@ use the same instance: DrmSessionManager customDrmSessionManager = new CustomDrmSessionManager(/* ... */); // Pass a drm session manager provider to the media source factory. -MediaSourceFactory mediaSourceFactory = +MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(dataSourceFactory) .setDrmSessionManagerProvider(mediaItem -> customDrmSessionManager); ~~~ diff --git a/docs/media-items.md b/docs/media-items.md index f1c342c2a5..f57b3b9392 100644 --- a/docs/media-items.md +++ b/docs/media-items.md @@ -4,7 +4,7 @@ title: Media items The [playlist API][] is based on `MediaItem`s, which can be conveniently built using `MediaItem.Builder`. Inside the player, media items are converted into -playable `MediaSource`s by a `MediaSourceFactory`. Without +playable `MediaSource`s by a `MediaSource.Factory`. Without [custom configuration]({{ site.baseurl }}/media-sources.html#customizing-media-source-creation), this conversion is carried out by a `DefaultMediaSourceFactory`, which is capable of building complex media sources corresponding to the properties of the diff --git a/docs/media-sources.md b/docs/media-sources.md index 7cfde4af3b..15435baf74 100644 --- a/docs/media-sources.md +++ b/docs/media-sources.md @@ -6,7 +6,7 @@ redirect_from: In ExoPlayer every piece of media is represented by a `MediaItem`. However internally, the player needs `MediaSource` instances to play the content. The -player creates these from media items using a `MediaSourceFactory`. +player creates these from media items using a `MediaSource.Factory`. By default the player uses a `DefaultMediaSourceFactory`, which can create instances of the following content `MediaSource` implementations: @@ -27,13 +27,13 @@ customization. ## Customizing media source creation ## -When building the player, a `MediaSourceFactory` can be injected. For example, if -an app wants to insert ads and use a `CacheDataSource.Factory` to support +When building the player, a `MediaSource.Factory` can be injected. For example, +if an app wants to insert ads and use a `CacheDataSource.Factory` to support caching, an instance of `DefaultMediaSourceFactory` can be configured to match these requirements and injected during player construction: ~~~ -MediaSourceFactory mediaSourceFactory = +MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(cacheDataSourceFactory) .setAdsLoaderProvider(adsLoaderProvider) .setAdViewProvider(playerView); @@ -47,7 +47,7 @@ The [`DefaultMediaSourceFactory` JavaDoc]({{ site.baseurl }}/doc/reference/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.html) describes the available options in more detail. -It's also possible to inject a custom `MediaSourceFactory` implementation, for +It's also possible to inject a custom `MediaSource.Factory` implementation, for example to support creation of a custom media source type. The factory's `createMediaSource(MediaItem)` will be called to create a media source for each media item that is @@ -57,7 +57,7 @@ media item that is The [`ExoPlayer`] interface defines additional playlist methods that accept media sources rather than media items. This makes it possible to bypass the -player's internal `MediaSourceFactory` and pass media source instances to the +player's internal `MediaSource.Factory` and pass media source instances to the player directly: ~~~ diff --git a/docs/shrinking.md b/docs/shrinking.md index 7c97c9ea29..f8eb4ffbf6 100644 --- a/docs/shrinking.md +++ b/docs/shrinking.md @@ -106,9 +106,9 @@ ExoPlayer player = ## Custom `MediaSource` instantiation ## -If your app is using a custom `MediaSourceFactory` and you want +If your app is using a custom `MediaSource.Factory` and you want `DefaultMediaSourceFactory` to be removed by code stripping, you should pass -your `MediaSourceFactory` directly to the `ExoPlayer.Builder` constructor. +your `MediaSource.Factory` directly to the `ExoPlayer.Builder` constructor. ~~~ ExoPlayer player = @@ -117,13 +117,13 @@ ExoPlayer player = {: .language-java} If your app is using `MediaSource`s directly instead of `MediaItem`s you should -pass `MediaSourceFactory.UNSUPPORTED` to the `ExoPlayer.Builder` constructor, to -ensure `DefaultMediaSourceFactory` and `DefaultExtractorsFactory` can be +pass `MediaSource.Factory.UNSUPPORTED` to the `ExoPlayer.Builder` constructor, +to ensure `DefaultMediaSourceFactory` and `DefaultExtractorsFactory` can be stripped by code shrinking. ~~~ ExoPlayer player = - new ExoPlayer.Builder(context, MediaSourceFactory.UNSUPPORTED).build(); + new ExoPlayer.Builder(context, MediaSource.Factory.UNSUPPORTED).build(); ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory( dataSourceFactory, customExtractorsFactory) diff --git a/docs/transforming-media.md b/docs/transforming-media.md index db0e893839..a3c112f77a 100644 --- a/docs/transforming-media.md +++ b/docs/transforming-media.md @@ -41,7 +41,7 @@ transformer.startTransformation(inputMediaItem, outputPath); ~~~ {: .language-java} -Other parameters, such as the `MediaSourceFactory`, can be passed to the +Other parameters, such as the `MediaSource.Factory`, can be passed to the builder. `startTransformation` receives a `MediaItem` describing the input, and a path or 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 fa1ac96881..f9564154ca 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 @@ -46,7 +46,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Timeline; -import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsMediaSource; import com.google.android.exoplayer2.ui.AdViewProvider; @@ -222,7 +222,7 @@ public final class ImaAdsLoader implements AdsLoader { /** * Sets the MIME types to prioritize for linear ad media. If not specified, MIME types supported - * by the {@link MediaSourceFactory adMediaSourceFactory} used to construct the {@link + * by the {@link MediaSource.Factory adMediaSourceFactory} used to construct the {@link * AdsMediaSource} will be used. * * @param adMediaMimeTypes The MIME types to prioritize for linear ad media. May contain {@link diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java index e6ff11dfd9..53b196fbb9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java @@ -43,7 +43,6 @@ import com.google.android.exoplayer2.extractor.ExtractorsFactory; import com.google.android.exoplayer2.metadata.MetadataRenderer; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.MediaSourceFactory; import com.google.android.exoplayer2.source.ShuffleOrder; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.TextRenderer; @@ -77,7 +76,7 @@ import java.util.List; * * - *

If specifying a {@link MediaSourceFactory} using {@link - * Transformer.Builder#setMediaSourceFactory(MediaSourceFactory)}, make sure that {@link + *

If specifying a {@link MediaSource.Factory} using {@link + * Transformer.Builder#setMediaSourceFactory(MediaSource.Factory)}, make sure that {@link * Mp4Extractor#FLAG_READ_SEF_DATA} is set on the {@link Mp4Extractor} used. Otherwise, the slow * motion metadata will be ignored and the input won't be flattened. * diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java index 636a137d52..fc4a96957b 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java @@ -51,7 +51,6 @@ import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor; import com.google.android.exoplayer2.metadata.MetadataOutput; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.MediaSourceFactory; import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.util.Clock; @@ -93,7 +92,7 @@ public final class Transformer { private @MonotonicNonNull Context context; // Optional fields. - private @MonotonicNonNull MediaSourceFactory mediaSourceFactory; + private MediaSource.@MonotonicNonNull Factory mediaSourceFactory; private Muxer.Factory muxerFactory; private boolean removeAudio; private boolean removeVideo; @@ -171,14 +170,14 @@ public final class Transformer { } /** - * Sets the {@link MediaSourceFactory} to be used to retrieve the inputs to transform. The + * Sets the {@link MediaSource.Factory} to be used to retrieve the inputs to transform. The * default value is a {@link DefaultMediaSourceFactory} built with the context provided in * {@link #Builder(Context) the constructor}. * - * @param mediaSourceFactory A {@link MediaSourceFactory}. + * @param mediaSourceFactory A {@link MediaSource.Factory}. * @return This builder. */ - public Builder setMediaSourceFactory(MediaSourceFactory mediaSourceFactory) { + public Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { this.mediaSourceFactory = mediaSourceFactory; return this; } @@ -471,7 +470,7 @@ public final class Transformer { public static final int PROGRESS_STATE_NO_TRANSFORMATION = 4; private final Context context; - private final MediaSourceFactory mediaSourceFactory; + private final MediaSource.Factory mediaSourceFactory; private final Muxer.Factory muxerFactory; private final boolean removeAudio; private final boolean removeVideo; @@ -490,7 +489,7 @@ public final class Transformer { private Transformer( Context context, - MediaSourceFactory mediaSourceFactory, + MediaSource.Factory mediaSourceFactory, Muxer.Factory muxerFactory, boolean removeAudio, boolean removeVideo, diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java index 53a0f7eeba..42b2da9fd1 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java @@ -27,6 +27,8 @@ import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; import com.google.android.exoplayer2.util.Util; /** Fake {@link MediaSourceFactory} that creates a {@link FakeMediaSource}. */ +// Implement and return deprecated type for backwards compatibility. +@SuppressWarnings("deprecation") public final class FakeMediaSourceFactory implements MediaSourceFactory { /** The window UID used by media sources that are created by the factory. */ diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java index 9a668f0186..b607c52723 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java @@ -27,7 +27,7 @@ import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.analytics.AnalyticsCollector; -import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; @@ -46,7 +46,7 @@ public class TestExoPlayerBuilder { private BandwidthMeter bandwidthMeter; @Nullable private Renderer[] renderers; @Nullable private RenderersFactory renderersFactory; - @Nullable private MediaSourceFactory mediaSourceFactory; + @Nullable private MediaSource.Factory mediaSourceFactory; private boolean useLazyPreparation; private @MonotonicNonNull Looper looper; private long seekBackIncrementMs; @@ -222,21 +222,21 @@ public class TestExoPlayerBuilder { } /** - * Returns the {@link MediaSourceFactory} that will be used by the player, or null if no {@link - * MediaSourceFactory} has been set yet and no default is available. + * Returns the {@link MediaSource.Factory} that will be used by the player, or null if no {@link + * MediaSource.Factory} has been set yet and no default is available. */ @Nullable - public MediaSourceFactory getMediaSourceFactory() { + public MediaSource.Factory getMediaSourceFactory() { return mediaSourceFactory; } /** - * Sets the {@link MediaSourceFactory} to be used by the player. + * Sets the {@link MediaSource.Factory} to be used by the player. * - * @param mediaSourceFactory The {@link MediaSourceFactory} to be used by the player. + * @param mediaSourceFactory The {@link MediaSource.Factory} to be used by the player. * @return This builder. */ - public TestExoPlayerBuilder setMediaSourceFactory(MediaSourceFactory mediaSourceFactory) { + public TestExoPlayerBuilder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { this.mediaSourceFactory = mediaSourceFactory; return this; }