How to mute or adjust volume on windows systems sounds? - c#

I am working on an audio application, and it is vital that we can mute Windows systems sounds (warnings, notifications etc) at critical times
I can set the system volume and access a number of sound related things, but not the Windows systems sounds
I can access microphones, loudspeakers (waveOut) and the mixer. However while in older versions of Windows, the mixer would contain "Systems sounds", but later do not. Opening "Sound Settings" one will find "Systems sounds" under apps.
If I could get that list, and control it, then I can mute the system.
How do I access that ?

Thanks to the link from Anders, I found the CoreAudio function, which lead me to IsSystemSoundsSession which then lead me to:
How can i control the volume of a specific software in the windows Volume Mixer?
Here is a similar thing done, which can be easily used for muting the system sounds

Related

System Sound Level in UWP

I have searched through documentations, but cannot find a way to figure out either the system volume or the volume level at which the app would play
Read through:
Sound
ElementSound
Is there a way to find it in UWP?
I need to report volume changes to viewability
Thanks for your interest. Unfortunately, currently there is no better way to report the volume you said. We can only control the app level's volume such as mediaplayperelement volume setting. We do not have any event to listen for system volume changes. We suggest you could make desktop bridge app and use desktop extension part to get system volume and send it to UWP client with AppService.

Background Voice recording in Windows Phone 8.1

Researched a lot for Solution for recording voice in Background (When another app is running/ when phone is locked, etc).
Searched whole MSDN, stackoverflow for any solution regarding this, Still didn't find it.
Also checked the Api references, they say MediaCapture wont work in background.
But I found two apps, which can record in background. As reverse engineering is not possible with encrypted app, I can't check how did they achieve it.
http://www.windowsphone.com/en-us/store/app/pocket-recorder/eda4e045-733f-e011-854c-00237de2db9e
http://www.windowsphone.com/en-in/store/app/voice-recorder-8-1/511c6375-8bf3-4d19-8248-1650a60ea1ae
I checked whether they use Voip Capabilities, but it is not listed. So there is some other work around, But don't know how!. These apps are paid, so I wish to help community with free solution.
I don't believe you can do this with background tasks. This is because if your app has a lock on the microphone, you won't be able to perform certain functions with your phone (i.e. phone calls)
Yes, Voice Recorder can record voice at the background by stopping every audio files and listening from the phone mic. Even if you switch the screen off, or the screen shut off, the under dog software will still be very active and recording the least sounds it hears and very powerfully clear. Now, I am very surprised to find a software that broke the feats of windows phone, although the software can not allow you to copy the recorded file to sd card or to the phone memory unless a paid version. This is good all the same.

can my windows phone application auto start?

Is there a way for my application to auto-start after some time instead of a notification? Or am I constrained to just notifications?
The difference between Android and Windows Phone (you mentioned Android in your comment) is that Android allows you to do pretty much everything while Windows Phone is a very restricted system. So, unfortunately, the answer is no. (There are ways to launch your app from other places than the app's tile, though. See the end of the answer)
Why am I saying unfortunately? Of course, Windows Phone is a nice and seek operating system that runs wonderful even on low-spec devices like the Lumia 520. But that doesn't mean developers shouldn't get the freedom to interact with the Operating System and do innovative tasks.
But there are reasons Microsoft chose not to allow Autostart (or at least, restrict the area an app can access, not the autostart in particular):
it may irritate customers. Even if you show a message box, many customers just dismiss it without reading it and they wouldn't understand why an app would appear without their interaction
each feature would make the operating system slower and bigger. I don't want to say that an autostart makes the phone unusable, but here's a question: Do you need to run a registry cleaner on you PC from time to time? Yes, you do need to do so You even need to reinstall a PC form time to time. You don't need to do that on a Windows Phone. It just works and will always work (OK, that's maybe a bit too optimistic, but you get it...)
I also don't think an autostart is particularly useful on a mobile. Because each app runs full screen, the system would boot up to your app instead of to the start screen. I don't think the user will always want your app (most of the time, he'll want to look at his start screen or launch another app), so it would just be annoying. On a PC, you can use the auto start for small programs that should run in the background (for example, I've got a progamm that provides Git with my SSH keys that automatically starts up each time).
But as I mentioned above, there are other ways to launch your app. Using url schemes can be surprisingly powerful as you can put a button on a web page that will directly launch your app. Other apps will also be able to launch your app. But as it is not directly what you wanted to know, I won't explain it in detail and instead provide you wiht a gread link to msdn: Auto-launching apps using file and URI associations for Windows Phone 8
For such features you should look into: Windows Embedded 8.1 Handheld instead of the consumer version Windows Phone 8.1.

How to mute windows phone programmatically

I want to start working on an app that have basic functionality to mute phone(no sound from any app, ring tone).
Is that possible, I have doubt because MS can take this as security threat.Please let me know from where to start?
You cannot programmatically control the entire Phone's volume through an API currently. Only the volume level of sounds from your application may be controlled.

Change system volume in Windows Phone 8

Up until now I thought that changing the system volume from your app is impossible, until recently a new app called Quite Hours (http://www.windowsphone.com/en-us/store/app/quiet-hours/f347a36b-80c0-430f-8631-e55046ee5a2a) actually did just that in a very neat way.
Does anyone please know how to do that programmatically? I tried using the MediaElement or the xna MediaPlayer and the backgroundAudioPlayer and nothing worked. Any help would be appreciated!
Thank you!
The developers of the apps mentioned in the OP were able to change system volume under WP8.0. Apparently whatever method they used has now been disabled under WP8.1. The following apps now display disclaimers that they no longer work on Windows Phone 8.1: Quiet Hours and Volume Manager
They direct to the following page to vote to allow this functionality: Windows Phone Dev User Voice
Additionally please read the following thread on the MSDN forum: MSDN change system volume Windows Phone 8. This functionality was likely achieved using WASAPI (which I have personally tried, and failed, it does not work, comment if you want my code to try it.), or the developers of the volume apps might have had access to AudioClientRestricted.h. If one had that h file, one would have access to system volume under WP8.1, so I somehow doubt the developers used the h file designated for OEMs because it would work un 8.1.
Talking with James Dailey (who works # MSFT) indicates it is technically possible using WASAPI ISimpleAudioVolume If you read # the bottom of that page there is a comment indicating you must use IAudioEndpointVolume
Added note from James Dailey # MSFT:
AFAIK there is no good way to manipulate the global audio level on
Windows Phone 8.1 (WP8.1). Theoretically you can change the audio
volume of any app that uses the default audio session “zero”. However,
if the app chooses to initialize it’s audio session with a custom
GUID you will not have access to the session volume for its custom
audio session. Again this is theoretical based on my knowledge of the
inner workings of WASAPI. I’ve never actually tried it on the phone.
To manipulate the audio volume of apps using audio session “zero” you
simply initialize your IAudioClient with an AudioSessionGuid parameter
of “{00000000-0000-0000-0000-000000000000}”. You can then use
ISimpleAudioVolume::SetMasterVolume to set the volume for this audio
session. You will need to use C++ / Cx since we do not support
calling WASAPI from managed code.
There currently is no API available for controlling the system volume. You can however control the volume in the elements of your application (via the classes MediaElement, BackgroundAudioAgent).
You can also control the volume on sound effects of your application using XNA API.
See http://msdn.microsoft.com/en-us/library/bb195052%28v=xnagamestudio.30%29.aspx

Categories