Package com.google.android.exoplayer2.source.smoothstreaming.offline

## Class SsDownloader

- java.lang.Object
- - com.google.android.exoplayer2.offline.SegmentDownloader<SsManifest>
  - - com.google.android.exoplayer2.source.smoothstreaming.offline.SsDownloader

- All Implemented Interfaces:
    `Downloader`

      public final class SsDownloader
      extends SegmentDownloader<SsManifest>

  A downloader for SmoothStreaming streams.

  Example usage:

       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(
               new MediaItem.Builder()
                   .setUri(manifestUri)
                   .setStreamKeys(Collections.singletonList(new StreamKey(0, 0)))
                   .build(),
               cacheDataSourceFactory);
       // Perform the download.
       ssDownloader.download(progressListener);
       // Use the downloaded data for playback.
       SsMediaSource mediaSource =
           new SsMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.google.android.exoplayer2.offline.SegmentDownloader

      `SegmentDownloader.Segment`

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.offline.Downloader

      `Downloader.ProgressListener`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SsDownloader​(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory)` | Creates an instance.
    `SsDownloader​(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)` | Creates an instance.
    `SsDownloader​(MediaItem mediaItem, ParsingLoadable.Parser<SsManifest> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)` | Creates a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected List<SegmentDownloader.Segment>` | `getSegments​(DataSource dataSource, SsManifest manifest, boolean removing)` | Returns a list of all downloadable `SegmentDownloader.Segment`s for a given manifest.

    - ### Methods inherited from class com.google.android.exoplayer2.offline.SegmentDownloader

      `cancel, download, execute, getCompressibleDataSpec, getManifest, remove`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SsDownloader

          public SsDownloader​(MediaItem mediaItem,
                              CacheDataSource.Factory cacheDataSourceFactory)

      Creates an instance.
      Parameters:
        `mediaItem` - The `MediaItem` to be downloaded.
        `cacheDataSourceFactory` - A `CacheDataSource.Factory` for the cache into which the download will be written.

    - #### SsDownloader

          public SsDownloader​(MediaItem mediaItem,
                              CacheDataSource.Factory cacheDataSourceFactory,
                              Executor executor)

      Creates an instance.
      Parameters:
        `mediaItem` - The `MediaItem` to be downloaded.
        `cacheDataSourceFactory` - A `CacheDataSource.Factory` for the cache into which the download will be written.
        `executor` - An `Executor` used to make requests for the media being downloaded. Providing an `Executor` that uses multiple threads will speed up the download by allowing parts of it to be executed in parallel.

    - #### SsDownloader

          public SsDownloader​(MediaItem mediaItem,
                              ParsingLoadable.Parser<SsManifest> manifestParser,
                              CacheDataSource.Factory cacheDataSourceFactory,
                              Executor executor)

      Creates a new instance.
      Parameters:
        `mediaItem` - The `MediaItem` to be downloaded.
        `manifestParser` - A parser for SmoothStreaming manifests.
        `cacheDataSourceFactory` - A `CacheDataSource.Factory` for the cache into which the download will be written.
        `executor` - An `Executor` used to make requests for the media being downloaded. Providing an `Executor` that uses multiple threads will speed up the download by allowing parts of it to be executed in parallel.

  - ### Method Detail

    - #### getSegments

          protected List<SegmentDownloader.Segment> getSegments​(DataSource dataSource,
                                                                SsManifest manifest,
                                                                boolean removing)

      Description copied from class: `SegmentDownloader`
      Returns a list of all downloadable `SegmentDownloader.Segment`s for a given manifest. Any required data should be loaded using `SegmentDownloader.getManifest(com.google.android.exoplayer2.upstream.DataSource, com.google.android.exoplayer2.upstream.DataSpec, boolean)` or `SegmentDownloader.execute(com.google.android.exoplayer2.util.RunnableFutureTask<T, ?>, boolean)`.
      Specified by:
        `getSegments` in class `SegmentDownloader<SsManifest>`
      Parameters:
        `dataSource` - The `DataSource` through which to load any required data.
        `manifest` - The manifest containing the segments.
        `removing` - 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 `IOException` will be thrown in this case.
      Returns:
        The list of downloadable `SegmentDownloader.Segment`s.