How can we detect system volume in WIndows 8? - c#

If I have an app that plays sounds. It seems like a good idea to indicate why the user isn't hearing the sounds. Is there a way to detect system volume or MUTE?

Yes.
MediaControl.SoundLevel for Windows 8
SystemMediaTransportControls.SoundLevel for Windows 8.1 and later
Music and media capture apps should monitor the SoundLevel to determine whether the audio streams on the app have been Muted.

I think you can use Windows.Media namespace. Also these is SoundLevel enum.
Also
ISimpleAudioVolume interface

Related

How to detect media playing with C#?

I would like to know how to detect if current windows is playing any kind of media (video, music, etc) similar to what energy settings do to decide if the computer can enter sleep/hibernate mode?
I'm trying to detect how long the computer is idle. I'm currently using the GetLastInputInfo from user32.dll but it just take in consideration the user input, but not if there is any media playing which should not consider the computer idle.
I tried to find C# APIs or native invocations but can't find the information. I'm using latest version of .NET Framework.
Generally speaking, programs don't declare that they are playing media - instead they call SetThreadExecutionState to tell Windows that the computer should not sleep.
That said - Windows 10 recently added support for programs to declare to the OS that they are currently playing media so that they're integrated with Windows' media controls (like how on iOS any program playing video or audio can be controlled from the Control Center).
Here's what appears on my screen when I nudge my volume control:
...however Chrome is being buggy here because I'm not actually playing any media in Chrome but it's telling Windows that it is.
I don't know what Windows API is used to set this - or which API is used to check it - but it isn't very widely used - even Windows' built-in Windows Media Player 12 doesn't use it.

How to pick up the microphone in background in Windows phone programmatically?

Are there any code samples (C#) how to pick up and handle microphone sounds under Win Phone 7+ ?
You can't, windows phone as a number of APIs that can't be used on background agents, microphone is one of them.

How to detect if background music is playing in WP8?

If anyone has developed WP apps before you know that you can't pass certification if your app stops music that is currently playing without the users consent.
I did see this question here which might have worked for WP7 apps but it apparently doesn't work for WP8. I assume it doesn't work because the WP8 OS doesn't support XNA (It is only backward compatible, and if you developed the app using 7.1).
Has anyone come across the solution for detecting background music in WP8.
I believe checking for MediaPlayer.GameHasControl is what you're looking for. Use that property and other members of MediaPlayer to satisfy application certification guidelines 6.5.1 Here's an end-to-end example of how # http://henry-chong.com/2012/02/pro-tip-including-background-music-for-your-windows-phone-app/
BTW, 6.5.x application certification requirements don't apply if your app is a Music+Video app. That's one way to address 6.5.1 :)
I believe that Microsoft.Xna.Framework.Media.MediaPlayer.State is still supported in Windows Phone 8 (MSDN source):
You can reference and use the following XNA Framework assemblies in
apps that target Windows Phone OS 8.0:
...
Microsoft.Xna.Framework.Media.dll
...

Control speaker volumes with c#

is there any easy way to control the individual speaker volumes in Windows 7 with c#?
I just want to set the volumes to a "preset", because windows likes to reset them randomly...
Start here,
Use IAudioMeterInformation in the CoreAudio APIs in Vista and Win 7.
Managed wrappers are available in NAudio (get at the AudioMeterInformation from the MMDevice).
check this too Get Master Sound Volume in c#

How to programmatically determine system device sound settings?

I have to write a simple Silverlight app for WP7. If the phone is muted in system, the program must not play sounds, but if the phone is not muted the program must play sounds.
How to programmatically determine if Windows Phone is muted or not?
There is no need to do that, the system does not play any sounds when the phone is muted. The system setting overrides all other settings both in Silverlight and XNA (and in integrated Silverlight + XNA).

Categories

Resources