# HlsInterstitialsAdsLoader.AdsMediaSourceFactory

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

*** ** * ** ***


```
public final class HlsInterstitialsAdsLoader.AdsMediaSourceFactory implements MediaSource.Factory
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` to create a media source to play HLS streams with interstitials.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#AdsMediaSourceFactory(androidx.media3.exoplayer.hls.HlsInterstitialsAdsLoader,androidx.media3.common.AdViewProvider,android.content.Context)( https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader adsLoader, https://developer.android.com/reference/androidx/media3/common/AdViewProvider adViewProvider, https://developer.android.com/reference/android/content/Context.html context )` Creates an instance with a `https://developer.android.com/reference/androidx/media3/exoplayer/source/DefaultMediaSourceFactory`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#AdsMediaSourceFactory(androidx.media3.exoplayer.hls.HlsInterstitialsAdsLoader,androidx.media3.common.AdViewProvider,androidx.media3.exoplayer.source.MediaSource.Factory)( https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader adsLoader, https://developer.android.com/reference/androidx/media3/common/AdViewProvider adViewProvider, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory mediaSourceFactory )` Creates an instance with a custom `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory`. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#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`. |
| `int[]` | `@https://developer.android.com/reference/androidx/media3/common/C.ContentType https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#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/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#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/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#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://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.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/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

### AdsMediaSourceFactory

```
public AdsMediaSourceFactory(
    HlsInterstitialsAdsLoader adsLoader,
    AdViewProvider adViewProvider,
    Context context
)
```

Creates an instance with a `https://developer.android.com/reference/androidx/media3/exoplayer/source/DefaultMediaSourceFactory`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader adsLoader` | The `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader`. |
| `https://developer.android.com/reference/androidx/media3/common/AdViewProvider adViewProvider` | Provider of views for the ad UI. |
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |

### AdsMediaSourceFactory

```
public AdsMediaSourceFactory(
    HlsInterstitialsAdsLoader adsLoader,
    AdViewProvider adViewProvider,
    MediaSource.Factory mediaSourceFactory
)
```

Creates an instance with a custom `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader adsLoader` | The `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader`. |
| `https://developer.android.com/reference/androidx/media3/common/AdViewProvider adViewProvider` | Provider of views for the ad UI. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory mediaSourceFactory` | The `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` used to create content and ad media sources. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the provided `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory` doesn't support content type `https://developer.android.com/reference/androidx/media3/common/C#CONTENT_TYPE_HLS()`. |

## Public methods

### createMediaSource

```
public MediaSource 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/MediaSource` | The new `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`. |

### getSupportedTypes

```
@C.ContentType
public int[] getSupportedTypes()
```

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

### setDrmSessionManagerProvider

```
@CanIgnoreReturnValue
public HlsInterstitialsAdsLoader.AdsMediaSourceFactory 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/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory` | This factory, for convenience. |

### setLoadErrorHandlingPolicy

```
@CanIgnoreReturnValue
public HlsInterstitialsAdsLoader.AdsMediaSourceFactory 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/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory` | This factory, for convenience. |