com.google.android.exoplayer2.database.ExoDatabaseProvider Java Examples

The following examples show how to use com.google.android.exoplayer2.database.ExoDatabaseProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExoPlayerView.java    From AerialDream with GNU General Public License v3.0 6 votes vote down vote up
public void setUri(Uri uri) {
    if (uri == null) {
        return;
    }

    player.stop();
    prepared = false;

    DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory("Aerial Dream");
    DataSource.Factory dataSourceFactory = cacheSize > 0
            ? new CacheDataSourceFactory(new SimpleCache(getContext().getCacheDir(), new LeastRecentlyUsedCacheEvictor(cacheSize), new ExoDatabaseProvider(getContext())), httpDataSourceFactory, 0)
            : httpDataSourceFactory;

    mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
            .createMediaSource(uri);
    player.prepare(mediaSource);
}
 
Example #2
Source File: AppModule.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
@Provides
@Singleton
ExoCreator provideExoCreator() {
    SimpleCache cache = new SimpleCache(new File(mApplication.getCacheDir(), "/toro_cache"),
            new LeastRecentlyUsedCacheEvictor(200 * 1024 * 1024), new ExoDatabaseProvider(mApplication));
    Config config = new Config.Builder(mApplication).setMediaSourceBuilder(MediaSourceBuilder.LOOPING).setCache(cache)
            .build();
    return ToroExo.with(mApplication).getCreator(config);
}
 
Example #3
Source File: ExoMediaSourceHelper.java    From DKVideoPlayer with Apache License 2.0 4 votes vote down vote up
private Cache newCache() {
    return new SimpleCache(
            new File(mAppContext.getExternalCacheDir(), "exo-video-cache"),//缓存目录
            new LeastRecentlyUsedCacheEvictor(512 * 1024 * 1024),//缓存大小,默认512M,使用LRU算法实现
            new ExoDatabaseProvider(mAppContext));
}