Answered by:
Can one intercept the Surface physical volume control?

Question
-
Is it possible to write managed code which can leverage the built-in volume control (the one found on the top left edge of the device)?
Also if one did do this could we also 'decouple' it from its usual role, that is have it not influence music volume?
Basically I'd like an App to be controllable with the up/down volume control and not have to rely on the screen, for certain aspects anyway.
Thanks.
- Moved by Rob Caplan [MSFT]Microsoft employee, Moderator Friday, September 27, 2013 5:51 PM
Friday, September 27, 2013 3:23 AM
Answers
-
You can listen to the CoreWindow.KeyDown and KeyUp events. The hard buttons should generate VK_VOLUME_DOWN (0xAE) and VK_VOLUME_UP (0xAF). These aren't in the VirtualKey enumeration, but you can use the raw values.
You can't block them from their main use, but you can add on as appropriate.
--Rob
- Edited by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, September 28, 2013 1:34 AM
- Marked as answer by Jamles HezModerator Monday, October 7, 2013 1:10 AM
Saturday, September 28, 2013 1:34 AMModerator
All replies
-
The app can listen for hard volume controls. How specifically to do so will depend on the language and UI layer the app is written in. If you can let us know which you are using we can move your post to the appropriate forum.
--Rob
Friday, September 27, 2013 6:23 AMModerator -
The app can listen for hard volume controls. How specifically to do so will depend on the language and UI layer the app is written in. If you can let us know which you are using we can move your post to the appropriate forum.
--Rob
Hi, this would be a C# Store App, XAML based GUI, I'd be interested in doing the same on a Phone 8 device too if pos.
Thx
Friday, September 27, 2013 6:28 AM -
Surely what you want to do is against the rules? I don't know a specific rule it breaches, but it just sounds...wrong.
If an app were to essentially disable the volume controls I'd personally uninstall it immediately, and given how strict the reviewers are (although they are also quite inconsistent) I'd expect it to fail certification on the grounds that it does things that should be under the user's control.
Also, it would be problematic for devices that don't have physical volume controls.
If you want to listen to the hardware controls and then do some UI (e.g. showing your own volume indicator) I suppose that would be OK. Any app reviewers here that can shed light on this?
I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.
Friday, September 27, 2013 6:40 AM -
Surely what you want to do is against the rules? I don't know a specific rule it breaches, but it just sounds...wrong.
If an app were to essentially disable the volume controls I'd personally uninstall it immediately, and given how strict the reviewers are (although they are also quite inconsistent) I'd expect it to fail certification on the grounds that it does things that should be under the user's control.
Also, it would be problematic for devices that don't have physical volume controls.
If you want to listen to the hardware controls and then do some UI (e.g. showing your own volume indicator) I suppose that would be OK. Any app reviewers here that can shed light on this?
I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.
Well if it breaches a rule then I won't consider it - but I've seen nothing published to that effect.
And it could easily be made optional, that's hardly a problem.
My view is that the volume control switch on the side of the Surface tablet is a resource just like any other - just like the compass or the screen or the speaker and I see no reason why it should be restricted in its use.
I was also thinking that Microsoft should have included a set of reusable switches and controls on the side of the surface specifically for applications to leverage. These programmable hardware bits could be really useful and allow us to control some aspects of an app without relying wholly upon the touch screen.
Now in my case I'd like to use the volume control switch to control the volume of external devices - for example one might be running a controller app like Sonos and use the volume control on the Surface as a convenient way to adjust the volume of the device rather than relying purely on a GUI based screen control - after all that's why its there else MediaPlayer etc would need to be up and visible in order for a user to alter the volume.
Same with a phone, this is just an idea and as I say it would be optional - nobody would be forced to do this and when the app ended the volume controller would revert to its usual role.
Like I said - a better way would be for Microsoft to have built in a few such controls/switches that are free for app developers to use - that would have been a good idea I think and technically pretty simple.
Hugh
- Edited by Captain Kernel Friday, September 27, 2013 4:55 PM
Friday, September 27, 2013 4:53 PM -
You can listen to the CoreWindow.KeyDown and KeyUp events. The hard buttons should generate VK_VOLUME_DOWN (0xAE) and VK_VOLUME_UP (0xAF). These aren't in the VirtualKey enumeration, but you can use the raw values.
You can't block them from their main use, but you can add on as appropriate.
--Rob
- Edited by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, September 28, 2013 1:34 AM
- Marked as answer by Jamles HezModerator Monday, October 7, 2013 1:10 AM
Saturday, September 28, 2013 1:34 AMModerator