Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 323
user3188746 Avatar asked Oct 20 '22 16:10

user3188746


People also ask

Is Windows Phone 8 still supported?

Customers can upgrade eligible Windows Phone 8.1 devices to Windows 10 Mobile, but should note that support for all versions of Windows 10 Mobile will end after December 2019.


1 Answers

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.

like image 141
mkabatek Avatar answered Oct 30 '22 02:10

mkabatek