Search in sources :

Example 1 with DatabaseProvider

use of com.google.android.exoplayer2.database.DatabaseProvider in project ExoPlayer by google.

the class ProgressiveDownloaderTest method createDownloadCache.

@Before
public void createDownloadCache() throws Exception {
    testDir = Util.createTempFile(ApplicationProvider.getApplicationContext(), "ProgressiveDownloaderTest");
    assertThat(testDir.delete()).isTrue();
    assertThat(testDir.mkdirs()).isTrue();
    DatabaseProvider databaseProvider = TestUtil.getInMemoryDatabaseProvider();
    downloadCache = new SimpleCache(testDir, new NoOpCacheEvictor(), databaseProvider);
}
Also used : DatabaseProvider(com.google.android.exoplayer2.database.DatabaseProvider) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) NoOpCacheEvictor(com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor) Before(org.junit.Before)

Example 2 with DatabaseProvider

use of com.google.android.exoplayer2.database.DatabaseProvider in project ExoPlayer by google.

the class DefaultDownloadIndexTest method setUp.

@Before
public void setUp() {
    databaseProvider = new StandaloneDatabaseProvider(ApplicationProvider.getApplicationContext());
    downloadIndex = new DefaultDownloadIndex(databaseProvider);
}
Also used : StandaloneDatabaseProvider(com.google.android.exoplayer2.database.StandaloneDatabaseProvider) Before(org.junit.Before)

Example 3 with DatabaseProvider

use of com.google.android.exoplayer2.database.DatabaseProvider in project Slide by ccrama.

the class Reddit method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mApplication = this;
    // LeakCanary.install(this);
    if (ProcessPhoenix.isPhoenixProcess(this)) {
        return;
    }
    final File dir;
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) && getExternalCacheDir() != null) {
        dir = new File(getExternalCacheDir() + File.separator + "video-cache");
    } else {
        dir = new File(getCacheDir() + File.separator + "video-cache");
    }
    LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(256 * 1024 * 1024);
    DatabaseProvider databaseProvider = new ExoDatabaseProvider(getAppContext());
    // 256MB
    videoCache = new SimpleCache(dir, evictor, databaseProvider);
    UpgradeUtil.upgrade(getApplicationContext());
    doMainStuff();
}
Also used : DatabaseProvider(com.google.android.exoplayer2.database.DatabaseProvider) ExoDatabaseProvider(com.google.android.exoplayer2.database.ExoDatabaseProvider) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) LeastRecentlyUsedCacheEvictor(com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor) ExoDatabaseProvider(com.google.android.exoplayer2.database.ExoDatabaseProvider) File(java.io.File)

Example 4 with DatabaseProvider

use of com.google.android.exoplayer2.database.DatabaseProvider in project react-native-track-player by react-native-kit.

the class LocalPlayback method initialize.

@Override
public void initialize() {
    if (cacheMaxSize > 0) {
        File cacheDir = new File(context.getCacheDir(), "TrackPlayer");
        DatabaseProvider db = new ExoDatabaseProvider(context);
        cache = new SimpleCache(cacheDir, new LeastRecentlyUsedCacheEvictor(cacheMaxSize), db);
    } else {
        cache = null;
    }
    super.initialize();
    resetQueue();
}
Also used : ExoDatabaseProvider(com.google.android.exoplayer2.database.ExoDatabaseProvider) DatabaseProvider(com.google.android.exoplayer2.database.DatabaseProvider) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) LeastRecentlyUsedCacheEvictor(com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor) ExoDatabaseProvider(com.google.android.exoplayer2.database.ExoDatabaseProvider) File(java.io.File)

Example 5 with DatabaseProvider

use of com.google.android.exoplayer2.database.DatabaseProvider in project ExoPlayer by google.

the class DefaultDownloadIndexTest method downloadIndex_upgradesFromVersion2.

@Test
public void downloadIndex_upgradesFromVersion2() throws IOException {
    Context context = ApplicationProvider.getApplicationContext();
    File databaseFile = context.getDatabasePath(StandaloneDatabaseProvider.DATABASE_NAME);
    try (FileOutputStream output = new FileOutputStream(databaseFile)) {
        output.write(TestUtil.getByteArray(context, "media/offline/exoplayer_internal_v2.db"));
    }
    Download dashDownload = createDownload(/* uri= */
    "http://www.test.com/manifest.mpd", /* mimeType= */
    MimeTypes.APPLICATION_MPD, ImmutableList.of(), /* customCacheKey= */
    null);
    Download hlsDownload = createDownload(/* uri= */
    "http://www.test.com/manifest.m3u8", /* mimeType= */
    MimeTypes.APPLICATION_M3U8, ImmutableList.of(), /* customCacheKey= */
    null);
    Download ssDownload = createDownload(/* uri= */
    "http://www.test.com/video.ism/manifest", /* mimeType= */
    MimeTypes.APPLICATION_SS, Arrays.asList(new StreamKey(0, 0), new StreamKey(1, 1)), /* customCacheKey= */
    null);
    Download progressiveDownload = createDownload(/* uri= */
    "http://www.test.com/video.mp4", /* mimeType= */
    MimeTypes.VIDEO_UNKNOWN, ImmutableList.of(), /* customCacheKey= */
    "customCacheKey");
    databaseProvider = new StandaloneDatabaseProvider(context);
    downloadIndex = new DefaultDownloadIndex(databaseProvider);
    assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.mpd"), dashDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.m3u8"), hlsDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/video.ism/manifest"), ssDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/video.mp4"), progressiveDownload);
}
Also used : Context(android.content.Context) FileOutputStream(java.io.FileOutputStream) StandaloneDatabaseProvider(com.google.android.exoplayer2.database.StandaloneDatabaseProvider) File(java.io.File) Test(org.junit.Test)

Aggregations

DatabaseProvider (com.google.android.exoplayer2.database.DatabaseProvider)3 SimpleCache (com.google.android.exoplayer2.upstream.cache.SimpleCache)3 File (java.io.File)3 Test (org.junit.Test)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 ExoDatabaseProvider (com.google.android.exoplayer2.database.ExoDatabaseProvider)2 StandaloneDatabaseProvider (com.google.android.exoplayer2.database.StandaloneDatabaseProvider)2 DownloadBuilder (com.google.android.exoplayer2.testutil.DownloadBuilder)2 LeastRecentlyUsedCacheEvictor (com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor)2 Before (org.junit.Before)2 Context (android.content.Context)1 SQLException (android.database.SQLException)1 WorkerThread (androidx.annotation.WorkerThread)1 DatabaseIOException (com.google.android.exoplayer2.database.DatabaseIOException)1 NoOpCacheEvictor (com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor)1 FileOutputStream (java.io.FileOutputStream)1