Change location of ExoPlayer cache
This commit is contained in:
parent
c0c02c42b9
commit
7e89e2ebf4
1 changed files with 5 additions and 8 deletions
|
|
@ -7,7 +7,6 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.dkanada.gramophone.App;
|
|
||||||
import com.dkanada.gramophone.R;
|
import com.dkanada.gramophone.R;
|
||||||
import com.dkanada.gramophone.model.Song;
|
import com.dkanada.gramophone.model.Song;
|
||||||
import com.dkanada.gramophone.service.playback.Playback;
|
import com.dkanada.gramophone.service.playback.Playback;
|
||||||
|
|
@ -32,8 +31,8 @@ import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
|
||||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
|
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
|
||||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
|
|
@ -52,8 +51,8 @@ public class MultiPlayer implements Playback {
|
||||||
private SimpleExoPlayer exoPlayer;
|
private SimpleExoPlayer exoPlayer;
|
||||||
private ConcatenatingMediaSource mediaSource;
|
private ConcatenatingMediaSource mediaSource;
|
||||||
|
|
||||||
private SimpleCache simpleCache;
|
private final SimpleCache simpleCache;
|
||||||
private DataSource.Factory dataSource;
|
private final DataSource.Factory dataSource;
|
||||||
|
|
||||||
private PlaybackCallbacks callbacks;
|
private PlaybackCallbacks callbacks;
|
||||||
|
|
||||||
|
|
@ -134,7 +133,6 @@ public class MultiPlayer implements Playback {
|
||||||
|
|
||||||
httpClient = new OkHttpClient.Builder().dispatcher(dispatcher).build();
|
httpClient = new OkHttpClient.Builder().dispatcher(dispatcher).build();
|
||||||
|
|
||||||
if (exoPlayer != null) exoPlayer.release();
|
|
||||||
exoPlayer = new SimpleExoPlayer.Builder(context).build();
|
exoPlayer = new SimpleExoPlayer.Builder(context).build();
|
||||||
mediaSource = new ConcatenatingMediaSource();
|
mediaSource = new ConcatenatingMediaSource();
|
||||||
|
|
||||||
|
|
@ -142,13 +140,12 @@ public class MultiPlayer implements Playback {
|
||||||
exoPlayer.prepare(mediaSource);
|
exoPlayer.prepare(mediaSource);
|
||||||
exoPlayer.setRepeatMode(Player.REPEAT_MODE_OFF);
|
exoPlayer.setRepeatMode(Player.REPEAT_MODE_OFF);
|
||||||
|
|
||||||
if (simpleCache != null) simpleCache.release();
|
|
||||||
long cacheSize = PreferenceUtil.getInstance(context).getMediaCacheSize();
|
long cacheSize = PreferenceUtil.getInstance(context).getMediaCacheSize();
|
||||||
LeastRecentlyUsedCacheEvictor recentlyUsedCache = new LeastRecentlyUsedCacheEvictor(cacheSize);
|
LeastRecentlyUsedCacheEvictor recentlyUsedCache = new LeastRecentlyUsedCacheEvictor(cacheSize);
|
||||||
ExoDatabaseProvider databaseProvider = new ExoDatabaseProvider(context);
|
ExoDatabaseProvider databaseProvider = new ExoDatabaseProvider(context);
|
||||||
|
|
||||||
File file = new File(App.getInstance().getApplicationInfo().dataDir + "/Gelli/exoplayer");
|
File cacheDirectory = new File(context.getCacheDir(), "exoplayer");
|
||||||
simpleCache = new SimpleCache(file, recentlyUsedCache, databaseProvider);
|
simpleCache = new SimpleCache(cacheDirectory, recentlyUsedCache, databaseProvider);
|
||||||
dataSource = buildDataSourceFactory();
|
dataSource = buildDataSourceFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue