Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/audioplayers/lib/src/audio_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AudioCache {
/// For example, Flame uses the prefix 'assets/audio/'
/// (you must include the final slash!).
/// The default prefix (if not provided) is 'assets/'
/// Your files will be found at <prefix><fileName> (so the trailing slash is
/// Your files will be found at `<prefix><fileName>` (so the trailing slash is
/// crucial).
String prefix;

Expand Down Expand Up @@ -126,7 +126,10 @@ class AudioCache {
///
/// Returns a [Uri] to access that file.
Future<Uri> load(String fileName) async {
if (!loadedFiles.containsKey(fileName)) {
if (!loadedFiles.containsKey(fileName) ||
// the file can be removed from the cache, this
// can happen automatically when the storage is almost full
(!kIsWeb && !fileSystem.file(loadedFiles[fileName]).existsSync())) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to check also check for if defaultTargetPlatform == Platform.Android, if it's something that only occurs on android.

I would also prefer to use await exists to not block the thread.

Also do you have some reference (preferably of Android) we can add to the docs here?

loadedFiles[fileName] = await fetchToMemory(fileName);
}
return loadedFiles[fileName]!;
Expand Down