Skip to content

Commit

Permalink
✨ Add: custom cache file
Browse files Browse the repository at this point in the history
  • Loading branch information
devaryakjha committed Oct 23, 2023
1 parent 5b09d34 commit 37dd776
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/cubits/download/download_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class DownloadCubit extends AppCubit<DownloadState> {
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));
}
}
6 changes: 3 additions & 3 deletions lib/utils/player/audio_handler_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<DownloadCubit>().getCacheFile(itemId, mediaItem.id);
final audioSource = LockCachingAudioSource(uri);
final cacheFile =
appContext.read<DownloadCubit>().getCacheFile(itemId, mediaItem.id);
final audioSource = LockCachingAudioSource(uri, cacheFile: cacheFile);
_mediaItemExpando[audioSource] = mediaItem;
return audioSource;
}
Expand Down

0 comments on commit 37dd776

Please sign in to comment.