Search in sources :

Example 6 with Downloader

use of androidx.media3.exoplayer.offline.Downloader in project media by androidx.

the class SsDownloaderTest method createWithDefaultDownloaderFactory.

@Test
public void createWithDefaultDownloaderFactory() throws Exception {
    CacheDataSource.Factory cacheDataSourceFactory = new CacheDataSource.Factory().setCache(Mockito.mock(Cache.class)).setUpstreamDataSourceFactory(DummyDataSource.FACTORY);
    DownloaderFactory factory = new DefaultDownloaderFactory(cacheDataSourceFactory, /* executor= */
    Runnable::run);
    Downloader downloader = factory.createDownloader(new DownloadRequest.Builder(/* id= */
    "id", Uri.parse("https://www.test.com/download")).setMimeType(MimeTypes.APPLICATION_SS).setStreamKeys(Collections.singletonList(new StreamKey(/* groupIndex= */
    0, /* trackIndex= */
    0))).build());
    assertThat(downloader).isInstanceOf(SsDownloader.class);
}
Also used : CacheDataSource(androidx.media3.datasource.cache.CacheDataSource) DefaultDownloaderFactory(androidx.media3.exoplayer.offline.DefaultDownloaderFactory) DefaultDownloaderFactory(androidx.media3.exoplayer.offline.DefaultDownloaderFactory) DownloaderFactory(androidx.media3.exoplayer.offline.DownloaderFactory) Downloader(androidx.media3.exoplayer.offline.Downloader) DefaultDownloaderFactory(androidx.media3.exoplayer.offline.DefaultDownloaderFactory) DownloaderFactory(androidx.media3.exoplayer.offline.DownloaderFactory) StreamKey(androidx.media3.common.StreamKey) Test(org.junit.Test)

Example 7 with Downloader

use of androidx.media3.exoplayer.offline.Downloader in project media by androidx.

the class DashDownloaderTest method createWithDefaultDownloaderFactory.

@Test
public void createWithDefaultDownloaderFactory() {
    CacheDataSource.Factory cacheDataSourceFactory = new CacheDataSource.Factory().setCache(Mockito.mock(Cache.class)).setUpstreamDataSourceFactory(DummyDataSource.FACTORY);
    DownloaderFactory factory = new DefaultDownloaderFactory(cacheDataSourceFactory, /* executor= */
    Runnable::run);
    Downloader downloader = factory.createDownloader(new DownloadRequest.Builder(/* id= */
    "id", Uri.parse("https://www.test.com/download")).setMimeType(MimeTypes.APPLICATION_MPD).setStreamKeys(Collections.singletonList(new StreamKey(/* groupIndex= */
    0, /* trackIndex= */
    0))).build());
    assertThat(downloader).isInstanceOf(DashDownloader.class);
}
Also used : CacheDataSource(androidx.media3.datasource.cache.CacheDataSource) DefaultDownloaderFactory(androidx.media3.exoplayer.offline.DefaultDownloaderFactory) DownloaderFactory(androidx.media3.exoplayer.offline.DownloaderFactory) DefaultDownloaderFactory(androidx.media3.exoplayer.offline.DefaultDownloaderFactory) Downloader(androidx.media3.exoplayer.offline.Downloader) DownloaderFactory(androidx.media3.exoplayer.offline.DownloaderFactory) DefaultDownloaderFactory(androidx.media3.exoplayer.offline.DefaultDownloaderFactory) StreamKey(androidx.media3.common.StreamKey) Test(org.junit.Test)

Example 8 with Downloader

use of androidx.media3.exoplayer.offline.Downloader in project media by androidx.

the class HlsDownloaderTest method downloadEncMediaPlaylist.

@Test
public void downloadEncMediaPlaylist() throws Exception {
    fakeDataSet = new FakeDataSet().setData(ENC_MEDIA_PLAYLIST_URI, ENC_MEDIA_PLAYLIST_DATA).setRandomData("enc.key", 8).setRandomData("enc2.key", 9).setRandomData("fileSequence0.ts", 10).setRandomData("fileSequence1.ts", 11).setRandomData("fileSequence2.ts", 12);
    HlsDownloader downloader = getHlsDownloader(ENC_MEDIA_PLAYLIST_URI, getKeys());
    downloader.download(progressListener);
    assertCachedData(cache, fakeDataSet);
}
Also used : FakeDataSet(androidx.media3.test.utils.FakeDataSet) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 CacheDataSource (androidx.media3.datasource.cache.CacheDataSource)5 StreamKey (androidx.media3.common.StreamKey)4 MediaItem (androidx.media3.common.MediaItem)3 DefaultDownloaderFactory (androidx.media3.exoplayer.offline.DefaultDownloaderFactory)3 Downloader (androidx.media3.exoplayer.offline.Downloader)3 DownloaderFactory (androidx.media3.exoplayer.offline.DownloaderFactory)3 FakeDataSet (androidx.media3.test.utils.FakeDataSet)3 Uri (android.net.Uri)2 DataSource (androidx.media3.datasource.DataSource)2 FakeDataSource (androidx.media3.test.utils.FakeDataSource)2 Nullable (androidx.annotation.Nullable)1 FailOnCloseDataSink (androidx.media3.test.utils.FailOnCloseDataSink)1 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1