# PreloadMediaSource.Factory

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/preload/PreloadMediaSource.java+class:androidx.media3.exoplayer.source.preload.PreloadMediaSource.Factory)

*** ** * ** ***


```
public final class PreloadMediaSource.Factory implements MediaSource.Factory
```

<br />

*** ** * ** ***

Factory for `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#Factory(androidx.media3.exoplayer.source.MediaSource.Factory,androidx.media3.exoplayer.source.preload.PreloadMediaSource.PreloadControl,androidx.media3.exoplayer.trackselection.TrackSelector,androidx.media3.exoplayer.upstream.BandwidthMeter,androidx.media3.exoplayer.RendererCapabilities[],androidx.media3.exoplayer.LoadControl,android.os.Looper)( https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory mediaSourceFactory, https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.PreloadControl preloadControl, https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelector trackSelector, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter, RendererCapabilities[] rendererCapabilities, https://developer.android.com/reference/androidx/media3/exoplayer/LoadControl loadControl, https://developer.android.com/reference/android/os/Looper.html preloadLooper )` Creates a new factory for `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource`. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Creates a new `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` with the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#createMediaSource(androidx.media3.exoplayer.source.MediaSource)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource)` |
| `int[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#getSupportedTypes()()` Returns the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` supported by media sources created by this factory. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#setClock(androidx.media3.common.util.Clock)(https://developer.android.com/reference/androidx/media3/common/util/Clock clock)` Sets the `https://developer.android.com/reference/androidx/media3/common/util/Clock` that will be used by the `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#setCmcdConfigurationFactory(androidx.media3.exoplayer.upstream.CmcdConfiguration.Factory)( https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration.Factory cmcdConfigurationFactory )` Sets the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration.Factory` used to obtain a `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration` for a `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#setDrmSessionManagerProvider(androidx.media3.exoplayer.drm.DrmSessionManagerProvider)( https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManagerProvider drmSessionManagerProvider )` Sets the `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManagerProvider` used to obtain a `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager` for a `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory#setLoadErrorHandlingPolicy(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy)( https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy loadErrorHandlingPolicy )` Sets an optional `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`. |

### Inherited Constants

From [androidx.media3.exoplayer.source.MediaSource.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory) `static final https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory#UNSUPPORTED()`

An instance that throws `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` from `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem)` and `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory#getSupportedTypes()`.

### Inherited methods

From [androidx.media3.exoplayer.source.MediaSource.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory) `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
@https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi
[experimentalParseSubtitlesDuringExtraction](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory#experimentalParseSubtitlesDuringExtraction(boolean))(
boolean parseSubtitlesDuringExtraction
)`

**This method is deprecated.**

This method (and all support for 'legacy' subtitle decoding during rendering) will be removed in a future release.

<br />

`https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory#setDownloadExecutor(com.google.common.base.Supplier<androidx.media3.exoplayer.util.ReleasableExecutor>)(https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor> downloadExecutor)`

Sets a supplier for an `https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor` that is used for loading the media.
`https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory#setSubtitleParserFactory(androidx.media3.extractor.text.SubtitleParser.Factory)(https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory subtitleParserFactory)`

Sets the `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory` to be used for parsing subtitles during extraction.

## Public constructors

### Factory

```
public Factory(
    MediaSource.Factory mediaSourceFactory,
    PreloadMediaSource.PreloadControl preloadControl,
    TrackSelector trackSelector,
    BandwidthMeter bandwidthMeter,
    RendererCapabilities[] rendererCapabilities,
    LoadControl loadControl,
    Looper preloadLooper
)
```

Creates a new factory for `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory mediaSourceFactory` | The underlying `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.PreloadControl preloadControl` | The `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.PreloadControl` that will control the progress of preloading the created `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource` instances. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelector trackSelector` | The `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelector`. The instance passed should be `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelector#init(androidx.media3.exoplayer.trackselection.TrackSelector.InvalidationListener,androidx.media3.exoplayer.upstream.BandwidthMeter)`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter`. It should be the same bandwidth meter of the `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` that is injected by `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer.Builder#setBandwidthMeter(androidx.media3.exoplayer.upstream.BandwidthMeter)`. |
| `RendererCapabilities[] rendererCapabilities` | The array of `https://developer.android.com/reference/androidx/media3/exoplayer/RendererCapabilities`. It should be derived from the same `https://developer.android.com/reference/androidx/media3/exoplayer/RenderersFactory` of the `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` that is injected by `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer.Builder#setRenderersFactory(androidx.media3.exoplayer.RenderersFactory)`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/LoadControl loadControl` | The `https://developer.android.com/reference/androidx/media3/exoplayer/LoadControl`. It should be the same instance of the `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` that is injected by `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer.Builder#setLoadControl(androidx.media3.exoplayer.LoadControl)`. |
| `https://developer.android.com/reference/android/os/Looper.html preloadLooper` | The `https://developer.android.com/reference/android/os/Looper.html` that will be used for preloading. It should be the same looper with `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer.Builder#setPlaybackLooper(android.os.Looper)` that will play the created `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource` instances. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `bandwidthMeter` is `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter#NO_OP()`. |

## Public methods

### createMediaSource

```
public PreloadMediaSource createMediaSource(MediaItem mediaItem)
```

Creates a new `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` with the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item to play. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource` | The new `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`. |

### createMediaSource

```
public PreloadMediaSource createMediaSource(MediaSource mediaSource)
```

### getSupportedTypes

```
public int[] getSupportedTypes()
```

Returns the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` supported by media sources created by this factory.

### setClock

```
@CanIgnoreReturnValue
public PreloadMediaSource.Factory setClock(Clock clock)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/util/Clock` that will be used by the `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource`. Should only be set for testing purposes.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | This factory, for convenience. |

### setCmcdConfigurationFactory

```
@CanIgnoreReturnValue
public PreloadMediaSource.Factory setCmcdConfigurationFactory(
    CmcdConfiguration.Factory cmcdConfigurationFactory
)
```

Sets the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration.Factory` used to obtain a `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration` for a `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | This factory, for convenience. |

### setDrmSessionManagerProvider

```
@CanIgnoreReturnValue
public PreloadMediaSource.Factory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)
```

Sets the `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManagerProvider` used to obtain a `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager` for a `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | This factory, for convenience. |

### setLoadErrorHandlingPolicy

```
@CanIgnoreReturnValue
public PreloadMediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)
```

Sets an optional `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource.Factory` | This factory, for convenience. |