# SingleSampleMediaSource.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/SingleSampleMediaSource.java+class:androidx.media3.exoplayer.source.SingleSampleMediaSource.Factory)

*** ** * ** ***


```
class SingleSampleMediaSource.Factory
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Deprecated in Java

Factory for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource`.

## Summary

| ### Public constructors |
|---|
| `[Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#Factory(androidx.media3.datasource.DataSource.Factory))(dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!)` **This function is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource!` | `[createMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem.SubtitleConfiguration,long))( subtitleConfiguration: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration!, durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html <T : https://developer.android.com/reference/java/util/concurrent/Executor.html?> [setDownloadExecutor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setDownloadExecutor(com.google.common.base.Supplier<T>,java.util.function.Consumer<T>))( downloadExecutor: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<T!>!, downloadExecutorReleaser: https://developer.android.com/reference/java/util/function/Consumer.html<T!>! )` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html [setLoadErrorHandlingPolicy](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setLoadErrorHandlingPolicy(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy))( loadErrorHandlingPolicy: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy? )` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html [setTag](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setTag(java.lang.Object))(tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html [setTrackId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setTrackId(java.lang.String))(trackId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setId(java.lang.String)` instead (on the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration` passed to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem.SubtitleConfiguration,long)`). <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html [setTreatLoadErrorsAsEndOfStream](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setTreatLoadErrorsAsEndOfStream(boolean))(treatLoadErrorsAsEndOfStream: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` **This function is deprecated.** Deprecated in Java |

## Public constructors

### Factory

```
[Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#Factory(androidx.media3.datasource.DataSource.Factory))(dataSourceFactory: DataSource.Factory!)
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Creates a factory for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource`s.

| Parameters |
|---|---|
| `dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!` | The factory from which the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` to read the media will be obtained. |

## Public functions

### createMediaSource

```
fun [createMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem.SubtitleConfiguration,long))(
    subtitleConfiguration: MediaItem.SubtitleConfiguration!,
    durationUs: Long
): SingleSampleMediaSource!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns a new `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource` using the current parameters.

| Parameters |
|---|---|
| `subtitleConfiguration: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration`. |
| `durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of the media stream in microseconds. |

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

### setDownloadExecutor

```
@CanIgnoreReturnValue
fun <T : Executor?> [setDownloadExecutor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setDownloadExecutor(com.google.common.base.Supplier<T>,java.util.function.Consumer<T>))(
    downloadExecutor: Supplier<T!>!,
    downloadExecutorReleaser: Consumer<T!>!
): SingleSampleMediaSource.Factory!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets a supplier for an `https://developer.android.com/reference/java/util/concurrent/Executor.html` that is used for loading the media.

| Parameters |
|---|---|
| `downloadExecutor: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<T!>!` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html` that provides an externally managed `https://developer.android.com/reference/java/util/concurrent/Executor.html` for downloading and extraction. |
| `downloadExecutorReleaser: https://developer.android.com/reference/java/util/function/Consumer.html<T!>!` | A callback triggered once a load task is finished and a supplied executor is no longer required. |

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

### setLoadErrorHandlingPolicy

```
@CanIgnoreReturnValue
fun [setLoadErrorHandlingPolicy](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setLoadErrorHandlingPolicy(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy))(
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy?
): SingleSampleMediaSource.Factory!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`. The default value is created by calling `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()`.

| Parameters |
|---|---|
| `loadErrorHandlingPolicy: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy?` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`. |

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

### setTag

```
@CanIgnoreReturnValue
fun [setTag](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setTag(java.lang.Object))(tag: Any?): SingleSampleMediaSource.Factory!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets a tag for the media source which will be published in the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` of the source as `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#tag()`.

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A tag for the media source. |

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

### setTrackId

```
@CanIgnoreReturnValue
fun [setTrackId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setTrackId(java.lang.String))(trackId: String?): SingleSampleMediaSource.Factory!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setId(java.lang.String)` instead (on the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration` passed to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#createMediaSource(androidx.media3.common.MediaItem.SubtitleConfiguration,long)`). `trackId` will only be used if `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration#id()` is `null`.

### setTreatLoadErrorsAsEndOfStream

```
@CanIgnoreReturnValue
fun [setTreatLoadErrorsAsEndOfStream](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SingleSampleMediaSource.Factory#setTreatLoadErrorsAsEndOfStream(boolean))(treatLoadErrorsAsEndOfStream: Boolean): SingleSampleMediaSource.Factory!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets whether load errors will be treated as end-of-stream signal (load errors will not be propagated). The default value is true.

| Parameters |
|---|---|
| `treatLoadErrorsAsEndOfStream: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | If true, load errors will not be propagated by sample streams, treating them as ended instead. If false, load errors will be propagated normally by `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#maybeThrowError()`. |

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