Click here to Skip to main content
15,668,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I made a program that plays relaxing MP3 music for one to fall asleep and in the end it lowers the Windows' systems sound level gradually to 0, how to make it while it's playing the MP3 file, all other applications in Windows including Windows itself not play sound for example no notifications sounds or Nexus clock speaking the time every round hour for example for the user to sleep with the relaxing music and no distracting sounds for him while he's falling asleep.

What I have tried:

I want something like:
foreach(Process p in lstWindowsProcesses)
if(p!=thisProcesss) p.Mute();

And when the program is not open anymore:
foreach(Process p in lstWindowsProcesses)

Or maybe store their previous state in volume and restore it when the program exits or there's a power outage and the computer is turned on again.
Updated 22-Dec-21 2:11am
Gerry Schmitz 22-Dec-21 9:39am    
I'd call it a security issue if it works. My field work app gives verbal warnings.
FierceLion 22-Dec-21 9:40am    
Yes, when the user presses: "Start relaxing music for sleeping" he would be warned and the program would explain that all other processes would be muted so no notification wakes him up for example...
j snooze 23-Dec-21 17:22pm    
you may want to take a look at this
FierceLion 25-Dec-21 9:42am    
Thanks, it linked then to here:

And in the main answer there's a code to include in my app with this in it to make it work:

// dump all audio sessions
foreach (AudioSession session in AudioUtilities.GetAllSessions())
if (session.Process != null)
// only the one associated with a defined process

How do I make here please something like:
if(Session.Process!=thisProcess) {/*mute process*/}

Is it this one:


EDIT: I have everything working except I need a way as I can't find it: session.Process.Mute(); something like this that I can't find.

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