package com.offline.music.playermp3.media3;

import android.content.Context;

import androidx.annotation.OptIn;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.database.StandaloneDatabaseProvider;
import androidx.media3.datasource.cache.NoOpCacheEvictor;
import androidx.media3.datasource.cache.SimpleCache;

import com.offline.music.playermp3.MusicApplication;

import java.io.File;

/**
 * 下载缓存
 */
public class MyDownloadCacheManager {

    private static SimpleCache downloadCache;

    @OptIn(markerClass = UnstableApi.class)
    public static SimpleCache getMyCache(StandaloneDatabaseProvider databaseProvider){
        if(downloadCache == null){
            Context myApplication = MusicApplication.myApplication;
            File musicApp = new File(myApplication.getCacheDir(), "Music_App");
            downloadCache = new SimpleCache(musicApp, new NoOpCacheEvictor(), databaseProvider);
        }
        return downloadCache;

    }



}
