代码拉取完成,页面将自动刷新
缓存 : CacheDataSinkFactory,CacheDataSourceFactory http : DefaultDataSourceFactory,DefaultHttpDataSourceFactory Priority : PriorityDataSourceFactory
compile 'com.google.android.exoplayer:extension-okhttp:2.7.2' compile 'com.google.android.exoplayer:extension-rtmp:2.7.2'
3.自定义数据源工厂类:
exoPlayerManager = new GestureVideoPlayer(this,videoPlayerView,new DataSource(this)); exoPlayerManager = new GestureVideoPlayer(this,(R.id.exo_play_context_id,new DataSource(this));
public class DataSource implements DataSourceListener {
public static final String TAG = "DataSource";
private Context context;
public DataSource (Context context){
this.context=context;
}
@Override
public com.google.android.exoplayer2.upstream.DataSource.Factory getDataSourceFactory() {
OkHttpClient okHttpClient = new OkHttpClient();
OkHttpDataSourceFactory OkHttpDataSourceFactory= new OkHttpDataSourceFactory(okHttpClient, Util.getUserAgent(context, context.getApplicationContext().getPackageName()),new DefaultBandwidthMeter() );
//使用OkHttpClient 数据源工厂
//return OkHttpDataSourceFactory; ;
//默认数据源工厂
// return new JDefaultDataSourceFactory(context);
// Rtmp数据源工厂 对 Rtmp 协议支持
// return new RtmpDataSourceFactory();
//缓存使用和组合使用
LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(1000000000);
SimpleCache simpleCache = new SimpleCache(new File(context.getCacheDir(), "media"), evictor);
//缓存数据源使用,内部使用DefaultDataSourceFactory数据源工厂类
// return new CacheDataSinkFactory(simpleCache,10000);
// 配合okHttp数据源工厂类
return new CacheDataSourceFactory(simpleCache, OkHttpDataSourceFactory);
//使用配合默认数据源红工厂类
// return new CacheDataSourceFactory(simpleCache, new JDefaultDataSourceFactory(context));
//使用提供缓存数据源工厂类
// return new CacheDataSourceFactory(context,1000,1000);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。