improve recent cache in exoplayer
This commit is contained in:
parent
5cdf8a90af
commit
d17f3877bd
1 changed files with 10 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
|
|||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
|
||||
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
|
||||
import com.google.android.exoplayer2.source.MediaSource;
|
||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||
|
|
@ -45,11 +46,12 @@ public class MultiPlayer implements Playback {
|
|||
|
||||
private OkHttpClient httpClient;
|
||||
private SimpleExoPlayer exoPlayer;
|
||||
|
||||
private ConcatenatingMediaSource mediaSource;
|
||||
private Playback.PlaybackCallbacks callbacks;
|
||||
private DataSource.Factory dataSource;
|
||||
|
||||
private SimpleCache simpleCache;
|
||||
private DataSource.Factory dataSource;
|
||||
|
||||
private PlaybackCallbacks callbacks;
|
||||
|
||||
private boolean isReady = false;
|
||||
private boolean isPlaying = false;
|
||||
|
|
@ -106,11 +108,12 @@ public class MultiPlayer implements Playback {
|
|||
exoPlayer = new SimpleExoPlayer.Builder(context).build();
|
||||
mediaSource = new ConcatenatingMediaSource();
|
||||
|
||||
if (dataSource != null) return;
|
||||
if (simpleCache != null) simpleCache.release();
|
||||
LeastRecentlyUsedCacheEvictor recentlyUsedCache = new LeastRecentlyUsedCacheEvictor(Long.MAX_VALUE);
|
||||
ExoDatabaseProvider databaseProvider = new ExoDatabaseProvider(context);
|
||||
|
||||
simpleCache = new SimpleCache(new File(Environment.getExternalStorageDirectory() + "/Gelli/cache"), recentlyUsedCache, databaseProvider);
|
||||
dataSource = buildDataSourceFactory();
|
||||
if (simpleCache != null) return;
|
||||
LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(Long.MAX_VALUE);
|
||||
simpleCache = new SimpleCache(new File(Environment.getExternalStorageDirectory() + "/Gelli/cache"), evictor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue