Class CacheManager
-
- All Implemented Interfaces:
public final class CacheManagerManages caching of video content for efficient playback with ExoPlayer (Media3). This class provides functionality to cache videos to disk and retrieve them when needed.
Thread-safe singleton
Avoids holding locks during I/O
Uses a consistent custom cache key per URL
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classCacheManager.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static CacheManager.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description CacheManager()
-
Method Summary
Modifier and Type Method Description final LonggetCacheSize()Total cache size in bytes. final CacheDataSource.FactorygetCacheDataSourceFactory()DataSource.Factory that supports cache read/write. final MediaSourcebuildMediaSource(String url, Boolean useCache)Create a MediaSource for a URL. final BooleanisFullyCached(String url)Is the content for url fully cached? final IntegergetCacheProgress(String url)% of content cached for url (0..100). final UnitclearCache()Clear all cached content (release outside lock, then delete files). final Unitrelease()Completely releases all resources associated with the cache manager. -
-
Method Detail
-
getCacheSize
final Long getCacheSize()
Total cache size in bytes.
-
getCacheDataSourceFactory
final CacheDataSource.Factory getCacheDataSourceFactory()
DataSource.Factory that supports cache read/write.
-
buildMediaSource
final MediaSource buildMediaSource(String url, Boolean useCache)
Create a MediaSource for a URL. If useCache=true, a custom cache key is set to the URL.
-
isFullyCached
final Boolean isFullyCached(String url)
Is the content for url fully cached?
-
getCacheProgress
final Integer getCacheProgress(String url)
% of content cached for url (0..100).
-
clearCache
final Unit clearCache()
Clear all cached content (release outside lock, then delete files).
-
-
-
-