Java Code Examples for com.google.android.exoplayer2.upstream.FileDataSourceFactory

The following examples show how to use com.google.android.exoplayer2.upstream.FileDataSourceFactory. These examples are extracted from open source projects. 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 Project: ExoPlayer-Wrapper   Source File: ExoPlayerHelper.java    License: Apache License 2.0 6 votes vote down vote up
private void enableCache(int maxCacheSizeMb) {
    LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSizeMb * 1024 * 1024);
    File file = new File(mContext.getCacheDir(), "media");
    Log.d("ZAQ", "enableCache (" + maxCacheSizeMb + " MB), file: " + file.getAbsolutePath());
    SimpleCache simpleCache = new SimpleCache(file, evictor);
    mDataSourceFactory = new CacheDataSourceFactory(
            simpleCache,
            mDataSourceFactory,
            new FileDataSourceFactory(),
            new CacheDataSinkFactory(simpleCache, 2 * 1024 * 1024),
            CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR,
            new CacheDataSource.EventListener() {
                @Override
                public void onCacheIgnored(int reason) {
                    Log.d("ZAQ", "onCacheIgnored");
                }

                @Override
                public void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead) {
                    Log.d("ZAQ", "onCachedBytesRead , cacheSizeBytes: " + cacheSizeBytes + "   cachedBytesRead: " + cachedBytesRead);
                }
            });
}
 
Example 2
Source Project: mimi-reader   Source File: ExoPlayer2Helper.java    License: Apache License 2.0 6 votes vote down vote up
public ExoPlayer2Helper(Context context) {
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    dataSourceFactory = new FileDataSourceFactory(this);
    extractorsFactory = new DefaultExtractorsFactory();

    DefaultTrackSelector trackSelector = new DefaultTrackSelector(bandwidthMeter);
    DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(context);
    EventLogger eventLogger = new EventLogger(trackSelector);

    player = ExoPlayerFactory.newSimpleInstance(context, renderersFactory, trackSelector);
    player.addListener(this);
    player.addListener(eventLogger);
    player.setAudioDebugListener(eventLogger);
    player.setVideoDebugListener(eventLogger);
    player.setMetadataOutput(eventLogger);
    player.setVideoListener(this);
}
 
Example 3
/** @see CacheDataSource#CacheDataSource(Cache, DataSource, int) */
public CacheDataSourceFactory(
    Cache cache, DataSource.Factory upstreamFactory, @CacheDataSource.Flags int flags) {
  this(
      cache,
      upstreamFactory,
      new FileDataSourceFactory(),
      new CacheDataSinkFactory(cache, CacheDataSink.DEFAULT_FRAGMENT_SIZE),
      flags,
      /* eventListener= */ null);
}
 
Example 4
/** @see CacheDataSource#CacheDataSource(Cache, DataSource, int) */
public CacheDataSourceFactory(
    Cache cache, DataSource.Factory upstreamFactory, @CacheDataSource.Flags int flags) {
  this(
      cache,
      upstreamFactory,
      new FileDataSourceFactory(),
      new CacheDataSinkFactory(cache, CacheDataSink.DEFAULT_FRAGMENT_SIZE),
      flags,
      /* eventListener= */ null);
}
 
Example 5
/**
 * @see CacheDataSource#CacheDataSource(Cache, DataSource, int, long)
 */
public CacheDataSourceFactory(Cache cache, DataSource.Factory upstreamFactory,
    @CacheDataSource.Flags int flags, long maxCacheFileSize) {
  this(cache, upstreamFactory, new FileDataSourceFactory(),
      new CacheDataSinkFactory(cache, maxCacheFileSize), flags, null);
}
 
Example 6
/**
 * @see CacheDataSource#CacheDataSource(Cache, DataSource, int, long)
 */
public CacheDataSourceFactory(Cache cache, DataSource.Factory upstreamFactory,
    @CacheDataSource.Flags int flags, long maxCacheFileSize) {
  this(cache, upstreamFactory, new FileDataSourceFactory(),
      new CacheDataSinkFactory(cache, maxCacheFileSize), flags, null);
}
 
Example 7
Source Project: K-Sonic   Source File: CacheDataSourceFactory.java    License: MIT License 4 votes vote down vote up
/**
 * @see CacheDataSource#CacheDataSource(Cache, DataSource, int, long)
 */
public CacheDataSourceFactory(Cache cache, DataSource.Factory upstreamFactory, int flags,
    long maxCacheFileSize) {
  this(cache, upstreamFactory, new FileDataSourceFactory(),
      new CacheDataSinkFactory(cache, maxCacheFileSize), flags, null);
}