use of androidx.media3.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);
}
use of androidx.media3.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();
}
use of androidx.media3.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();
}
use of androidx.media3.database.DatabaseProvider in project media by androidx.
the class CacheFileMetadataIndex method delete.
/**
* Deletes index data for the specified cache.
*
* <p>This method may be slow and shouldn't normally be called on the main thread.
*
* @param databaseProvider Provides the database in which the index is stored.
* @param uid The cache UID.
* @throws DatabaseIOException If an error occurs deleting the index data.
*/
@WorkerThread
public static void delete(DatabaseProvider databaseProvider, long uid) throws DatabaseIOException {
String hexUid = Long.toHexString(uid);
try {
String tableName = getTableName(hexUid);
SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
writableDatabase.beginTransactionNonExclusive();
try {
VersionTable.removeVersion(writableDatabase, VersionTable.FEATURE_CACHE_FILE_METADATA, hexUid);
dropTable(writableDatabase, tableName);
writableDatabase.setTransactionSuccessful();
} finally {
writableDatabase.endTransaction();
}
} catch (SQLException e) {
throw new DatabaseIOException(e);
}
}
use of androidx.media3.database.DatabaseProvider in project media by androidx.
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);
}
Aggregations