private void prepareAudioFile(File file, long startPositionMs) { Uri fileUri = Uri.fromFile(file); DataSource.Factory dataSourceFactory = new FileDataSourceFactory(); DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING); MediaSource source = new ExtractorMediaSource( fileUri, dataSourceFactory, extractorsFactory, null, null); exoPlayer.seekTo(startPositionMs); exoPlayer.prepare(source, false, true); }
/** * @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); }
protected DataSource.Factory buildFileDataSourceFactory(boolean useBandwidthMeter) { return new FileDataSourceFactory(useBandwidthMeter ? BANDWIDTH_METER : null); }
/** * @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); }
@Override protected ExtractorMediaSource.Factory create() throws Throwable { final ExtractorMediaSource.Factory factory = new ExtractorMediaSource.Factory(new FileDataSourceFactory()); factory.setMinLoadableRetryCount(ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE); return factory; }