From 22b066a2afbd8a6c153f81f394ce695b2ca651d3 Mon Sep 17 00:00:00 2001 From: guoshuyu <359369982@qq.com> Date: Fri, 7 May 2021 10:42:52 +0800 Subject: [PATCH] update fix #3241 --- .../tv/danmaku/ijk/media/exo2/ExoSourceManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java b/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java index b0b0ec1..94edda9 100644 --- a/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java +++ b/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java @@ -31,21 +31,17 @@ import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.RawResourceDataSource; import com.google.android.exoplayer2.upstream.cache.Cache; import com.google.android.exoplayer2.upstream.cache.CacheDataSource; -import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory; import com.google.android.exoplayer2.upstream.cache.CacheKeyFactory; import com.google.android.exoplayer2.upstream.cache.CacheSpan; import com.google.android.exoplayer2.upstream.cache.ContentMetadata; import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor; import com.google.android.exoplayer2.upstream.cache.SimpleCache; -import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; import java.io.File; -import java.util.Collections; import java.util.Map; import java.util.NavigableSet; -import static com.google.android.exoplayer2.util.Assertions.checkNotNull; /** * Created by guoshuyu on 2018/5/18. @@ -150,7 +146,9 @@ public class ExoSourceManager { getHttpDataSourceFactory(mAppContext, preview, uerAgent))).createMediaSource(mediaItem); break; case C.TYPE_HLS: - mediaSource = new HlsMediaSource.Factory(getDataSourceFactoryCache(mAppContext, cacheEnable, preview, cacheDir, uerAgent)).createMediaSource(mediaItem); + mediaSource = new HlsMediaSource.Factory(getDataSourceFactoryCache(mAppContext, cacheEnable, preview, cacheDir, uerAgent)) + .setAllowChunklessPreparation(true) + .createMediaSource(mediaItem); break; case TYPE_RTMP: RtmpDataSourceFactory rtmpDataSourceFactory = new RtmpDataSourceFactory(null); @@ -338,7 +336,9 @@ public class ExoSourceManager { Cache cache = getCacheSingleInstance(context, cacheDir); if (cache != null) { isCached = resolveCacheState(cache, mDataSource); - return new CacheDataSourceFactory(cache, getDataSourceFactory(context, preview, uerAgent), CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR); + CacheDataSource.Factory factory = new CacheDataSource.Factory(); + return factory. + setCache(cache).setCacheReadDataSourceFactory(getDataSourceFactory(context, preview, uerAgent)).setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR); } } return getDataSourceFactory(context, preview, uerAgent); -- GitLab