.net – how to get and set audio volume level for a Universal Windows application

audioiotnetuwpvb.net

The title says it all, I would like to get and set audio volume level for a Universal Windows (iot) application.

It can be either the sound level associated with my particular application – which would be ideal; or it can be the system sound level – if necessary / possible.

I am using visual studio 2015

I've been searching for examples / samples but have come up dry.

Any help would be appreciated.

(of note this is not a duplicate question – I want to get and set audio volume level for a Universal Windows application – this can not be done via a COM object in uwp – nor do uwp apps use VBScript or JScript)

Best Answer

There's no need to make a WinRT component. Instead you can use P/Invoke to access the win32 audio interfaces.

Take a look at my code (Gist) for how to do this in C#.