• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileDataSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.exoplayer2.upstream.FileDataSource的典型用法代码示例。如果您正苦于以下问题:Java FileDataSource类的具体用法?Java FileDataSource怎么用?Java FileDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileDataSource类属于com.google.android.exoplayer2.upstream包,在下文中一共展示了FileDataSource类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildCacheDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
/**
 * Returns a new {@link CacheDataSource} instance. If {@code offline} is true, it can only read
 * data from the cache.
 */
public CacheDataSource buildCacheDataSource(boolean offline) {
  DataSource cacheReadDataSource = cacheReadDataSourceFactory != null
      ? cacheReadDataSourceFactory.createDataSource() : new FileDataSource();
  if (offline) {
    return new CacheDataSource(cache, DummyDataSource.INSTANCE,
        cacheReadDataSource, null, CacheDataSource.FLAG_BLOCK_ON_CACHE, null);
  } else {
    DataSink cacheWriteDataSink = cacheWriteDataSinkFactory != null
        ? cacheWriteDataSinkFactory.createDataSink()
        : new CacheDataSink(cache, CacheDataSource.DEFAULT_MAX_CACHE_FILE_SIZE);
    DataSource upstream = upstreamDataSourceFactory.createDataSource();
    upstream = priorityTaskManager == null ? upstream
        : new PriorityDataSource(upstream, priorityTaskManager, C.PRIORITY_DOWNLOAD);
    return new CacheDataSource(cache, upstream, cacheReadDataSource,
        cacheWriteDataSink, CacheDataSource.FLAG_BLOCK_ON_CACHE, null);
  }
}
 
开发者ID:y20k,项目名称:transistor,代码行数:22,代码来源:DownloaderConstructorHelper.java


示例2: buildCacheDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
private static CacheDataSource buildCacheDataSource(Context context, DataSource upstreamSource,
    boolean useAesEncryption) throws CacheException {
  File cacheDir = context.getExternalCacheDir();
  Cache cache = new SimpleCache(new File(cacheDir, EXO_CACHE_DIR), new NoOpCacheEvictor());
  emptyCache(cache);

  // Source and cipher
  final String secretKey = "testKey:12345678";
  DataSource file = new FileDataSource();
  DataSource cacheReadDataSource = useAesEncryption
      ? new AesCipherDataSource(Util.getUtf8Bytes(secretKey), file) : file;

  // Sink and cipher
  CacheDataSink cacheSink = new CacheDataSink(cache, EXO_CACHE_MAX_FILESIZE);
  byte[] scratch = new byte[3897];
  DataSink cacheWriteDataSink = useAesEncryption
      ? new AesCipherDataSink(Util.getUtf8Bytes(secretKey), cacheSink, scratch) : cacheSink;

  return new CacheDataSource(cache,
      upstreamSource,
      cacheReadDataSource,
      cacheWriteDataSink,
      CacheDataSource.FLAG_BLOCK_ON_CACHE,
      null); // eventListener
}
 
开发者ID:y20k,项目名称:transistor,代码行数:26,代码来源:CacheDataSourceTest2.java


示例3: createCacheDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
private CacheDataSource createCacheDataSource(boolean setReadException,
    boolean simulateUnknownLength, @CacheDataSource.Flags int flags,
    CacheDataSink cacheWriteDataSink) {
  FakeDataSource upstream = new FakeDataSource();
  FakeData fakeData = upstream.getDataSet().newDefaultData()
      .setSimulateUnknownLength(simulateUnknownLength).appendReadData(TEST_DATA);
  if (setReadException) {
    fakeData.appendReadError(new IOException("Shouldn't read from upstream"));
  }
  return new CacheDataSource(cache, upstream, new FileDataSource(), cacheWriteDataSink,
      flags, null);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:13,代码来源:CacheDataSourceTest.java


示例4: createDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
@Override
public DataSource createDataSource() {
    LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
    SimpleCache simpleCache =
            new SimpleCache(new File(context.getCacheDir(), "media"), evictor);
    return new CacheDataSource(simpleCache, defaultDatasourceFactory.createDataSource(),
            new FileDataSource(), new CacheDataSink(simpleCache, maxFileSize),
            CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR,
            null);
}
 
开发者ID:ccrama,项目名称:Slide,代码行数:11,代码来源:MediaVideoView.java


示例5: createDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
@Override
public DataSource createDataSource() {
    return new CacheDataSource(simpleCache, defaultDatasourceFactory.createDataSource(),
            new FileDataSource(), new CacheDataSink(simpleCache, CacheDataSource.DEFAULT_MAX_CACHE_FILE_SIZE),
            0, listener);
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:7,代码来源:DefaultCacheDataSourceFactory.java


示例6: initPlayer

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
private void initPlayer(String url) {
        // 1.创建一个默认TrackSelector,测量播放过程中的带宽。 如果不需要,可以为null。
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        //从MediaSource中选出media提供给可用的Render S来渲染,在创建播放器时被注入
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);
        // 2.创建一个默认的LoadControl
        //Create a default LoadControl 控制MediaSource缓存media
        DefaultLoadControl loadControl = new DefaultLoadControl();
//        BufferingLoadControl bufferingLoadControl = new BufferingLoadControl();
        //生成加载媒体数据的DataSource实例。
//        dataSourceFactory = new DefaultDataSourceFactory(this,
//                Util.getUserAgent(this, "aitrip"), bandwidthMeter);
        //自定义解密工厂
        aitripFactory = new AitripDataSourceFactory(this,
                Util.getUserAgent(this, "aitrip"), bandwidthMeter);
        extractorsFactory = new DefaultExtractorsFactory();
//        factory = new DiyExtractorsFactory();
        FileDataSource fileDataSource = new FileDataSource();
        //test mp3
//        url = "https://storage.googleapis.com/exoplayer-test-media-0/play.mp3";
        // MediaSource代表要播放的媒体。
        videoSource = new ExtractorMediaSource(Uri.parse(url),
                aitripFactory, extractorsFactory, null, null);
        // 3.创建播放器
        player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

        //SimpleExoPlayerView simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player);
        //设置监听器
        player.addListener(eventListener);
        //装载多个资源
        MediaSource[] mediaSources = new MediaSource[1];
//        mediaSources[0] = buildMediaSource(Uri.parse(huai), "");
//        mediaSources[1] = buildMediaSource(Uri.parse(deng), "");
        mediaSources[0] = buildMediaSource(Uri.parse(deng), "");
//        mediaSources[2] = buildMediaSource(playerUri, "");
//        mediaSources[3] = buildMediaSource(Uri.parse(deng), "");
        ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource(mediaSources);

        //设置资源
        player.prepare(mediaSource);
        window = new Timeline.Window();
    }
 
开发者ID:ChangWeiBa,项目名称:AesExoPlayer,代码行数:46,代码来源:TestPlayerActivity.java


示例7: CacheDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
/**
 * Constructs an instance with default {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. The sink is configured to fragment data such that no single
 * cache file is greater than maxCacheFileSize bytes.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS}, or 0.
 * @param maxCacheFileSize The maximum size of a cache file, in bytes. If the cached data size
 *     exceeds this value, then the data will be fragmented into multiple cache files. The
 *     finer-grained this is the finer-grained the eviction policy can be.
 */
public CacheDataSource(Cache cache, DataSource upstream, @Flags int flags,
    long maxCacheFileSize) {
  this(cache, upstream, new FileDataSource(), new CacheDataSink(cache, maxCacheFileSize),
      flags, null);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:19,代码来源:CacheDataSource.java


示例8: CacheDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
/**
 * Constructs an instance with default {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. The sink is configured to fragment data such that no single
 * cache file is greater than maxCacheFileSize bytes.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE} and {@link
 *     #FLAG_IGNORE_CACHE_ON_ERROR} or 0.
 * @param maxCacheFileSize The maximum size of a cache file, in bytes. If the cached data size
 *     exceeds this value, then the data will be fragmented into multiple cache files. The
 *     finer-grained this is the finer-grained the eviction policy can be.
 */
public CacheDataSource(Cache cache, DataSource upstream, @Flags int flags,
    long maxCacheFileSize) {
  this(cache, upstream, new FileDataSource(), new CacheDataSink(cache, maxCacheFileSize),
      flags, null);
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:19,代码来源:CacheDataSource.java


示例9: CacheDataSource

import com.google.android.exoplayer2.upstream.FileDataSource; //导入依赖的package包/类
/**
 * Constructs an instance with default {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. The sink is configured to fragment data such that no single
 * cache file is greater than maxCacheFileSize bytes.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_CACHE_UNBOUNDED_REQUESTS} or 0.
 * @param maxCacheFileSize The maximum size of a cache file, in bytes. If the cached data size
 *     exceeds this value, then the data will be fragmented into multiple cache files. The
 *     finer-grained this is the finer-grained the eviction policy can be.
 */
public CacheDataSource(Cache cache, DataSource upstream, @Flags int flags,
    long maxCacheFileSize) {
  this(cache, upstream, new FileDataSource(), new CacheDataSink(cache, maxCacheFileSize),
      flags, null);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:19,代码来源:CacheDataSource.java



注:本文中的com.google.android.exoplayer2.upstream.FileDataSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PingProvider类代码示例发布时间:2022-05-22
下一篇:
Java X509CredentialsAuthenticationHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap