From 37dd776c79c452d8b0e27d68804c815aa3a07fbe Mon Sep 17 00:00:00 2001 From: devaryakjha Date: Tue, 24 Oct 2023 01:59:12 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add:=20custom=20cache=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cubits/download/download_cubit.dart | 3 ++- lib/utils/player/audio_handler_impl.dart | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cubits/download/download_cubit.dart b/lib/cubits/download/download_cubit.dart index 199a869..efc5c6d 100644 --- a/lib/cubits/download/download_cubit.dart +++ b/lib/cubits/download/download_cubit.dart @@ -319,6 +319,7 @@ class DownloadCubit extends AppCubit { File? getCacheFile(String itemId, String itemUrl) { final ext = itemUrl.split('.').last; final fileName = '$itemId.$ext'; - return File(path.join(loadedState.downloadDirectory.path, '', fileName)); + return File( + path.join(loadedState.downloadDirectory.path, 'cache', fileName)); } } diff --git a/lib/utils/player/audio_handler_impl.dart b/lib/utils/player/audio_handler_impl.dart index 5e7bc0c..21ce1e1 100644 --- a/lib/utils/player/audio_handler_impl.dart +++ b/lib/utils/player/audio_handler_impl.dart @@ -186,9 +186,9 @@ final class AudioHandlerImpl extends BaseAudioHandler final downloaded = _isSongDownloaded(itemId); if (!downloaded) { final uri = Uri.parse(mediaItem.id); - // final cacheFile = - // appContext.read().getCacheFile(itemId, mediaItem.id); - final audioSource = LockCachingAudioSource(uri); + final cacheFile = + appContext.read().getCacheFile(itemId, mediaItem.id); + final audioSource = LockCachingAudioSource(uri, cacheFile: cacheFile); _mediaItemExpando[audioSource] = mediaItem; return audioSource; }