State Monitor Class
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Allows a UWP app to determine if any of the app's audio streams are currently being muted or having their volume reduced by the system.
public ref class AudioStateMonitor sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 393216)] /// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)] class AudioStateMonitor final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 393216)] [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)] public sealed class AudioStateMonitor
Public NotInheritable Class AudioStateMonitor
Object IInspectable AudioStateMonitor
Windows 10, version 1803 (introduced in 10.0.17134.0)
Windows.Foundation.UniversalApiContract (introduced in v6.0)
Windows dynamically mutes or lowers the level of audio streams in response to system events. For example, the volume of a podcast app's audio render stream may be lowered while an alarm is ringing. Or an audio recording app may have their capture stream muted when the app moves to the background. This class allows apps to respond to changes in the level of their audio streams. For example, a podcast app may choose to pause playback when the sound level is lowered by the system and then resume playback when the volume level returns to normal. Or, an audio recording app may choose to stop recording while its capture stream is muted.
Create an AudioStateMonitor by calling one of its factory methods that determines which streams are monitored based on their MediaCategory, AudioDeviceRole, the ID of the associated audio device, and whether the stream is capturing or rendering audio.
Use the SoundLevel property to determine the current sound level of the monitored streams. You can check the value of this property, to determine if a category of audio streams will be muted or have its volume lowered, before initiating audio capture or playback. You can register a handler for the SoundLevelChanged event to receive notifications when the sound level for a category of audio streams changes, and then check the SoundLevel property to determine the new current audio level.
For more information on using AudioStateMonitor in a UWP app, see Detect and respond to audio state changes.
Gets a value indicating the current sound level of the audio streams being monitored by the AudioStateMonitor.
Initializes a new instance of the AudioStateMonitor class that monitors the sound level for all audio capture streams.
Initializes a new instance of the AudioStateMonitor class that monitors the sound level for all audio render streams.
Occurs when the system changes the sound level of the audio streams being monitored by the AudioStateMonitor.
Submit and view feedback for