当前位置: 首页 > news >正文

网站建设公司的网站影视网站怎么做app

网站建设公司的网站,影视网站怎么做app,医院网站必须建设吗,手机网站如何做才能兼容性各种手机ExoPlayer 开启播放缓存功能#xff0c;在下次加载已经播放过的网络资源的时候#xff0c;可以直接从本地缓存加载#xff0c;实现为用户节省流量和提升加载效率的作用。 方法一#xff1a;采用 ExoPlayer 缓存策略 第 1 步#xff1a;实现 Exoplayer 参考 Exoplayer 官…    ExoPlayer 开启播放缓存功能在下次加载已经播放过的网络资源的时候可以直接从本地缓存加载实现为用户节省流量和提升加载效率的作用。 方法一采用 ExoPlayer 缓存策略 第 1 步实现 Exoplayer 参考 Exoplayer 官网 Release notes : 对应关系 2.19.0 (2023-07-05)  -- AndroidX Media3 1.1.0 release. 2.19.1 (2023-08-14)  -- AndroidX Media3 1.1.1 release Exoplayer 从 2.19.0 开始迁移至 AndroidX 的 Media3 框架内2.19.1 是 Exoplayer 作为独立项目发布的最后一个版本所以引入 Exoplayer 2.19.1 有以下两个方式建议采用最新的方式 2。 # 方式1 implementation com.google.android.exoplayer:exoplayer-core:2.19.1 implementation com.google.android.exoplayer:exoplayer-dash:2.19.1 implementation com.google.android.exoplayer:exoplayer-ui:2.19.1# 方式2 implementation androidx.media3:media3-exoplayer:1.1.1 implementation androidx.media3:media3-exoplayer-dash:1.1.1 implementation androidx.media3:media3-ui:1.1.1第 2 步在应用程序类中创建缓存策略 public SimpleCache simpleCache; Overridepublic void onCreate() {super.onCreate();//缓存最大值为100MLeastRecentlyUsedCacheEvictor leastRecentlyUsedCacheEvictor new LeastRecentlyUsedCacheEvictor(100 * 1024 * 1024);if (simpleCache null) {simpleCache new SimpleCache(getCacheDir(), leastRecentlyUsedCacheEvictor, new ExoDatabaseProvider(this));} } 第 3 步加载数据源实现缓存 //本地资源如/sdcard/media/1.mp4或 HTTP 资源 Uri videoUri Uri.parse(YOUR URL); MediaItem mediaItem MediaItem.fromUri(videoUri); DefaultHttpDataSource.Factory httpDataSourceFactory new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true); // 这里的DefaultDataSource同时支持本地和HTTP请求的资源自动实现检测 The DefaultDataSource supports both local and Http sources. It automatically detects which one to use. DefaultDataSource.Factory defaultDataSourceFactory new DefaultDataSourceFactory(requireContext(), httpDataSourceFactory); //实现缓存 CacheDataSource.Factory cacheDataSourceFactory new CacheDataSource.Factory().setCache(MyApplication.getAppInstance().simpleCache).setUpstreamDataSourceFactory(defaultDataSourceFactory).setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);MediaSource mediaSource new ProgressiveMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem); player.setMediaSource(mediaSource, true); 方法二:  通过 Android Video Cache Library 开源库 AndroidVideoCache 的原理是通过代理的策略实现一个中间层将网络视频请求转移到本地实现的代理服务器上这样真正请求的数据就会被代理拿到然后代理一边向本地写入数据一边根据需要的数据看是读网络数据还是读本地缓存数据从而实现数据的复用。 第 1 步实现 VideoCache implementation com.danikula:videocache:2.7.1 第 2 步在应用程序类中存储共享代理 public class MyApplication extends Application {private HttpProxyCacheServer proxy;public static HttpProxyCacheServer getProxy(Context context) {MyApplication app (MyApplication) context.getApplicationContext();return app.proxy null ? (app.proxy app.newProxy()) : app.proxy;}private HttpProxyCacheServer newProxy() {return new HttpProxyCacheServer.Builder(this).maxCacheSize(1024 * 1024 * 1024).build();}} 第 3 步Exoplayer 接入缓存 HttpProxyCacheServer proxy getProxy(activity); //注意应采用来自代理的 url 而不是原始 url 来添加缓存 String proxyUrl proxy.getProxyUrl(VIDEO_URL); PlayerView playerView findViewById(R.id.video_view); ExoPlayer player ExoPlayerFactory.newSimpleInstance(VideoActivity.this,new DefaultRenderersFactory(this),new DefaultTrackSelector()); MediaSource mediaSource buildMediaSource(proxyUrl); player.prepare(mediaSource, true, false); playerView.setPlayer(player);
http://www.pierceye.com/news/788923/

相关文章:

  • DNF做钓鱼网站网站建设方案书编写
  • 提高网站粘性wordpress tag中文
  • 公司已有网站 如何自己做推广wordpress的音乐插件怎么用
  • 权威网站php wordpress 等
  • 建设网站企业公司中通建设计院第四分公司网站
  • 快站免费网站建设哪家好南宁市住房建设局网站
  • 学生做的网站成品roseonly企业网站优化
  • 台前网站建设电话百度账号注册申请
  • 政和县建设局网站公告征婚网站咋做
  • 做网站需要用到的语言注册公司需要多少钱保证金
  • 如何给别人做网站赚钱互联网广告营销方案
  • 上海专业做网站公司地址软文代写
  • 家居网站源码宁波专业建设网站建站公司
  • 成都网站建设 Vr功能 卓 公司网站后台管理系统怎么用
  • 微站网建站系统南昌科技网站建设
  • 商家网站建设模板快速备份wordpress
  • 网站建设推广价格肯德基网站建设
  • 网站开发课程百度云平湖公司做网站
  • 手机网站建设品牌什么是企业云网站建设
  • 烟台网站建设推荐企汇互联见效付款58同城网站模板
  • 琪恋网站建设深圳3d网站建设
  • 做ic用什么网站软文代写平台
  • 厦门网站建设 九来网站建设公司如何发展
  • 广州 网站的设计公司耒阳市古雍网站建设店
  • 保定网站推广费用网站搜索 收录优化
  • 三河市建设厅公示网站个人flash网站
  • 建设网站工具上海网站制作团队
  • 化妆品网站系统规划wordpress 站群软件
  • 深圳低价做网站广告免费设计在线生成
  • 网站服务体系网站开发补充合同范本