Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Without being in a place that the user might visit, some sort of cache or something ...

What I have tried:

C#
// after downloading test1.mp3 programmatically from a website
            ConvertMp3ToWav(@"D:\test1.mp3", @"D:\test1.wav");

            SoundPlayer my_wave_file = new SoundPlayer(@"D:\test1.wav");
            my_wave_file.PlaySync();

//delete the 2 files after using them finishes
Posted
Updated 21-Jan-22 11:12am
v2

1 solution

If you don't want files, then don't create them. AFAIK one can download to memory, convert, and play using streams. I haven't needed such conversion yet, but I guess you are already using NAudio, so I'd suggest you check its documentation about converting streams.
 
Share this answer
 
Comments
FierceLion 21-Jan-22 17:53pm    
As I'm a hobbyist only it's easier for me to work with files unless someone tells me how to deal with streams and it's not that difficult, I was expecting to put the files in the folder of the program and delete them or something or in a special folder in Windows and delete them.
Luc Pattyn 21-Jan-22 18:00pm    
If they must be files, I'd suggest you use the folder returned by Path.GetTempPath (doc)

Putting data files (perm or temp) in or under the EXE folder will fail as soon as the EXE folder is in or under one of the system folders such as "Program Files". (access denied).

You can delete the .mp3 once conversion is done.
You will need a way to figure when playing has finished so you can also delete the .wav file.
FierceLion 21-Jan-22 18:18pm    
Works like magic, thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900