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.
Related
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
Can I set system volume from code behind?
I know that in WP8 no way to do this. Maybe in WP8.1 ms added some api for system volume access?
This is not possible I have tried using the WASAPI drivers from Microsoft.
As an added note quoting from MSFT support James Dailey:
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.
The above suggestion does not work.
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.
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
I know you can't change it, but I'd like to instrument the system volume setting inside my app.
Thanks!
Currently there is no API for getting or setting the system volume. You can set the volume of your own MediaElements, however, this is combined with the system volume to determine the overall playback volume.
See also:
Windows Phone 7 Volume Settings programmatically
Did you try the MediaElement.Volume property?
http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.volume(v=vs.95).aspx
I don't know the exact way to use it, but it seem like there is a possibility with this class.
Sorry if it doesn't help you.