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

The following examples show how to use com.google.android.exoplayer2.upstream.FileDataSourceFactory. 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: ExoPlayerHelper.java    From ExoPlayer-Wrapper with 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 File: ExoPlayer2Helper.java    From mimi-reader with 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
Source File: CacheDataSourceFactory.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/** @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
Source File: CacheDataSourceFactory.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/** @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
Source File: CacheDataSourceFactory.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @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
Source File: CacheDataSourceFactory.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @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 File: CacheDataSourceFactory.java    From K-Sonic with 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);
}