jfversluis / Plugin.Maui.Audio

Plugin.Maui.Audio provides the ability to play audio inside a .NET MAUI application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specifying the filePath for recording creates both the specified file and temporary file.

codychaplin opened this issue · comments

commented

When using StartAsync(string filePath) to record audio, once you stop the recording, it creates the specified file correctly, but it still creates the randomly generated .tmp file. I have only tested on Android so I'm not sure about other platforms. This is a problem because while each new recording overwrites the specified file, the tmp files all have unique names so the cache folder just keeps growing.

This was using v2.1.0 on an Android 14 emulator and .NET 8.

But if you have the path you can clean it up afterwards yourself? And since its in the temp/cache folder, the OS should clean that up as necessary?

commented

True, I just wasn't sure if it was intentional or not. I am only using this on Android, so I don't know about other platforms, but my app involves taking notes via recordings so after testing for a bit, the app's cache folder was quickly up to 150ish MB, I don't know if Android deletes those files automatically after some time but I did add the below code which does the trick.

string[] filesToDelete = Directory.GetFiles(FileSystem.Current.CacheDirectory, "*.tmp");
foreach (var file in filesToDelete)
    File.Delete(file);

Amazing work on this plugin though, much appreciated!

No worries, appreciate any and all input that keeps us honest! 😉

For now this is intended behavior. I did add a note to the readme about it. If more people trip over this let's revisit!

Wouldn't Fix 103 have taken care of this? #108