# 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)

*** ** * ** ***


```
class HlsInterstitialsAdsLoader.AdsMediaSourceFactory : MediaSource.Factory
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#AdsMediaSourceFactory(androidx.media3.exoplayer.hls.HlsInterstitialsAdsLoader,androidx.media3.common.AdViewProvider,android.content.Context)( adsLoader: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader!, adViewProvider: https://developer.android.com/reference/kotlin/androidx/media3/common/AdViewProvider!, context: https://developer.android.com/reference/android/content/Context.html! )` Creates an instance with a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/DefaultMediaSourceFactory`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#AdsMediaSourceFactory(androidx.media3.exoplayer.hls.HlsInterstitialsAdsLoader,androidx.media3.common.AdViewProvider,androidx.media3.exoplayer.source.MediaSource.Factory)( adsLoader: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader!, adViewProvider: https://developer.android.com/reference/kotlin/androidx/media3/common/AdViewProvider!, mediaSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory! )` Creates an instance with a custom `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#createMediaSource(androidx.media3.common.MediaItem)(mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!)` Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.ContentType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#getSupportedTypes()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.ContentType` supported by media sources created by this factory. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#setDrmSessionManagerProvider(androidx.media3.exoplayer.drm.DrmSessionManagerProvider)( drmSessionManagerProvider: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManagerProvider! )` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManagerProvider` used to obtain a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManager` for a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory#setLoadErrorHandlingPolicy(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy)( loadErrorHandlingPolicy: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy! )` Sets an optional `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`. |

### Inherited Constants

From [androidx.media3.exoplayer.source.MediaSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory) `const https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory!` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem)` and `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory#getSupportedTypes()`.

### Inherited functions

From [androidx.media3.exoplayer.source.MediaSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory) `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory!` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
@https://developer.android.com/reference/kotlin/androidx/media3/common/util/ExperimentalApi
[experimentalParseSubtitlesDuringExtraction](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory#experimentalParseSubtitlesDuringExtraction(boolean))(
parseSubtitlesDuringExtraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html
)`

**This function 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/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory!` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory#setCmcdConfigurationFactory(androidx.media3.exoplayer.upstream.CmcdConfiguration.Factory)(
cmcdConfigurationFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/CmcdConfiguration.Factory!
)`

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/CmcdConfiguration.Factory` used to obtain a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/CmcdConfiguration` for a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory!` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory#setDownloadExecutor(com.google.common.base.Supplier<androidx.media3.exoplayer.util.ReleasableExecutor>)(downloadExecutor: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/util/ReleasableExecutor!>!)`

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

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

## Public constructors

### AdsMediaSourceFactory

```
AdsMediaSourceFactory(
    adsLoader: HlsInterstitialsAdsLoader!,
    adViewProvider: AdViewProvider!,
    context: Context!
)
```

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

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

### AdsMediaSourceFactory

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

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

| Parameters |
|---|---|
| `adsLoader: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader`. |
| `adViewProvider: https://developer.android.com/reference/kotlin/androidx/media3/common/AdViewProvider!` | Provider of views for the ad UI. |
| `mediaSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory!` | The `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory` doesn't support content type `https://developer.android.com/reference/kotlin/androidx/media3/common/C#CONTENT_TYPE_HLS()`. |

## Public functions

### createMediaSource

```
fun createMediaSource(mediaItem: MediaItem!): MediaSource!
```

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

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

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

### getSupportedTypes

```
@C.ContentType
fun getSupportedTypes(): Array<Int>!
```

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

### setDrmSessionManagerProvider

```
@CanIgnoreReturnValue
fun setDrmSessionManagerProvider(
    drmSessionManagerProvider: DrmSessionManagerProvider!
): HlsInterstitialsAdsLoader.AdsMediaSourceFactory!
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory!` | This factory, for convenience. |

### setLoadErrorHandlingPolicy

```
@CanIgnoreReturnValue
fun setLoadErrorHandlingPolicy(
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy!
): HlsInterstitialsAdsLoader.AdsMediaSourceFactory!
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AdsMediaSourceFactory!` | This factory, for convenience. |