WinUI3-MediaPlayer: How can I detect when no audio device exists? #8690
-
Hello, like the title suggets, I want to know how I can detect in WinUI3 if a audio source is installed on the computer where the software is running? I use a MediaPlayer class to play any sound files. Last time we had the case that the software was running on a machine without any audio capabilities. In this case I want to check so before I start the media player. Has anyone an idea how to solve that? I also checked the properties of the MediaPlayer class, but so far no property indicated the state of the audio devices. MediaPlayer.AudioDevice was always null regardless of whether a audio source exists on the computer or not. Best regards. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Maybe you can test if there is a default renderer device, like : |
Beta Was this translation helpful? Give feedback.
-
Thank you. That helped me a lot. Tested it directly and it worked perfectly. |
Beta Was this translation helpful? Give feedback.
Maybe you can test if there is a default renderer device, like :
string sDevice = Windows.Media.Devices.MediaDevice.GetDefaultAudioRenderId(Windows.Media.Devices.AudioDeviceRole.Communications);