I have a C# UWP application using Windows IoT Core on Raspberry Pi 3. Is there a way to control the master volume output level of the pi from C# code?
As far as i know, there is no API in UWP used to change the System's Volume directly. It's all about the ecosystem of the app itself being managed by the system. You may try to find Win32 API to control master volume.
Here is an answer to changing the master volume from C++, also includes SetMute, etc. You can call the api in C#.Maybe it is helpful for you.
Changing master volume level
In addition, WASAPI provides client-specified volume and mute settings uniformly to all of the streams in the session. Users can adjust the volume and mute settings for all of the sessions in the system. But
WASAPI is only available in C++. if you want to do it from a C# UWP App, you can create a RuntimeComponent in C++CX that will provide this feature to your app.
https://learn.microsoft.com/en-us/windows/desktop/coreaudio/audio-sessions
Related
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.
I’m looking for a way to embed a single page style web application into an industrial pc that’s running TwinCAT 3 plc to control an automation system. The hmi on this system is already written in c# using the beckhoff ads dll. What I’m having trouble with is how to embed the server that’s reading and writing data to my plc instance and the web page front end into one application. I’m looking to use c# or python as those are the languages that I have experience in. I would like to be able to log into this webpage by the up address of the Pc and get a page on a phone or laptop that allows elements on the screen to be interacted with like buttons and a joystick style control for creating motion on the machine.
Which OS is the PLC running on? If WinCE, its a bit trickier. You'll need VS2008 to compile against the NET35CF for C#.
With a "full" version of windows, things become simpler - you can use whichever version of .NET will fit on the controller, or whichever version of Python supports the python ADS library.
After that, create your connections into the PLC as per the Beckhoff ADS examples when required by your web page.
Of course you will need to manage the web server accordingly. Some Beckhoff PLCs already use IIS for basic diagnostics, so you would have to set up an appropriate route to your page to avoid conflict.
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.
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
We have an HTC handset running Windows Mobile 6.1. Is there a way to increase/decrease screen brightness for this device programmatically?
The application is being developed in C#, so a .NET wrapper would be preferable, but an unmanaged API would also be acceptable.
Also, how can we turn the screen on/off to save battery while a particular application is running?
You would use the power management APIs to change the backlight settings. Also the WinMo 5 SDKs ship with a sample application called Power Manager that demonstrates how to programmatically change the state of the backlight. It's in C, but is pretty straightforward to port.