# SsDownloader

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

*** ** * ** ***


```
@UnstableApi
class SsDownloader : SegmentDownloader<SsManifest!>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.media3.exoplayer.offline.SegmentDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader)\<[SsManifest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/manifest/SsManifest)!\> ||
|   | ↳ | [androidx.media3.exoplayer.smoothstreaming.offline.SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader) |

*** ** * ** ***

A downloader for SmoothStreaming streams.

Example usage:

```kotlin
SimpleCache cache = new SimpleCache(downloadFolder, new NoOpCacheEvictor(), databaseProvider);
CacheDataSource.Factory cacheDataSourceFactory =
    new CacheDataSource.Factory()
        .setCache(cache)
        .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory());
// Create a downloader for the first track of the first stream element.
SsDownloader ssDownloader =
    new SsDownloader.Factory(cacheDataSourceFactory)
          .create(new MediaItem.Builder()
              .setUri(manifestUri)
              .setStreamKeys(ImmutableList.of(new StreamKey(0, 0)))
              .build());
// Perform the download.
ssDownloader.download(progressListener);
// Use the downloaded data for playback.
SsMediaSource mediaSource =
    new SsMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory : https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/manifest/SsManifest!>` A factory for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader`. |

| ### Public constructors |
|---|
| `[SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader#SsDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory))( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, cacheDataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory! )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `[SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader#SsDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,java.util.concurrent.Executor))( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, cacheDataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory!, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html! )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |

| ### Protected functions |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader.Segment!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader#getSegments(androidx.media3.datasource.DataSource,androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest,boolean)( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, manifest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/manifest/SsManifest!, removing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns a list of all downloadable `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader.Segment`s for a given manifest. |

### Inherited Constants

From [androidx.media3.exoplayer.offline.SegmentDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#DEFAULT_MAX_MERGED_SEGMENT_START_TIME_DIFF_MS() = 20000`

### Inherited functions

From [androidx.media3.exoplayer.offline.SegmentDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#cancel()()`

Permanently cancels the downloading by this downloader.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener)(progressListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader.ProgressListener?)`

Downloads the content.
`T!` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#execute(com.google.common.base.Supplier<androidx.media3.common.util.RunnableFutureTask<T,?>>,boolean)(
runnable: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/kotlin/androidx/media3/common/util/RunnableFutureTask<T!, *>!>!,
removing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html
)`

Executes the provided `https://developer.android.com/reference/kotlin/androidx/media3/common/util/RunnableFutureTask`.
`java-static https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#getCompressibleDataSpec(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` `M!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#getManifest(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,boolean)(dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!, removing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Loads and parses a manifest.
`M!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#getManifest(androidx.media3.datasource.DataSource,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<M>,androidx.media3.datasource.DataSpec,boolean)(
dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!,
manifestParser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<M!>!,
dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!,
removing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html
)`

Loads and parses a manifest with a different parser than the base parser that parsed the initial manifest.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#remove()()`

Removes the content.

### Inherited properties

From [androidx.media3.exoplayer.offline.SegmentDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#durationUs()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#startPositionUs()`

## Public constructors

### SsDownloader

```
[SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader#SsDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory))(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!
)
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory#create(androidx.media3.common.MediaItem)` instead.

### SsDownloader

```
[SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader#SsDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,java.util.concurrent.Executor))(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!,
    executor: Executor!
)
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory#create(androidx.media3.common.MediaItem)` instead.

## Protected functions

### getSegments

```
protected fun getSegments(
    dataSource: DataSource!,
    manifest: SsManifest!,
    removing: Boolean
): (Mutable)List<SegmentDownloader.Segment!>!
```

Returns a list of all downloadable `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader.Segment`s for a given manifest. Any required data should be loaded using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#getManifest(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,boolean)` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader#execute(com.google.common.base.Supplier<androidx.media3.common.util.RunnableFutureTask<T,?>>,boolean)`.

| Parameters |
|---|---|
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` through which to load any required data. |
| `manifest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/manifest/SsManifest!` | The manifest containing the segments. |
| `removing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the segments are being obtained as part of a removal. If true then a partial segment list is returned in the case that a load error prevents all segments from being listed. If false then an `https://developer.android.com/reference/java/io/IOException.html` will be thrown in this case. |

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader.Segment!>!` | The list of downloadable `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader.Segment`s. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | Thrown if `allowPartialIndex` is false and an execution error occurs, or if the media is not in a form that allows for its segments to be listed. |