AudioStateMonitor AudioStateMonitor AudioStateMonitor AudioStateMonitor AudioStateMonitor Class

Definition

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 : sealed class AudioStateMonitor
struct winrt::Windows::Media::Audio::AudioStateMonitor
public sealed class AudioStateMonitor
Public NotInheritable Class AudioStateMonitor
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10, version 1803 (introduced v10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

Remarks

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.

Properties

SoundLevel SoundLevel SoundLevel SoundLevel SoundLevel

Gets a value indicating the current sound level of the audio streams being monitored by the AudioStateMonitor.

Methods

CreateForCaptureMonitoring() CreateForCaptureMonitoring() CreateForCaptureMonitoring() CreateForCaptureMonitoring() CreateForCaptureMonitoring()

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for all audio capture streams.

CreateForCaptureMonitoring(MediaCategory) CreateForCaptureMonitoring(MediaCategory) CreateForCaptureMonitoring(MediaCategory) CreateForCaptureMonitoring(MediaCategory) CreateForCaptureMonitoring(MediaCategory)

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for audio capture streams with the specified MediaCategory.

CreateForCaptureMonitoring(MediaCategory, AudioDeviceRole) CreateForCaptureMonitoring(MediaCategory, AudioDeviceRole) CreateForCaptureMonitoring(MediaCategory, AudioDeviceRole) CreateForCaptureMonitoring(MediaCategory, AudioDeviceRole) CreateForCaptureMonitoring(MediaCategory, AudioDeviceRole)

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for audio capture streams with the specified MediaCategory and AudioDeviceRole.

CreateForCaptureMonitoringWithCategoryAndDeviceId(MediaCategory, String) CreateForCaptureMonitoringWithCategoryAndDeviceId(MediaCategory, String) CreateForCaptureMonitoringWithCategoryAndDeviceId(MediaCategory, String) CreateForCaptureMonitoringWithCategoryAndDeviceId(MediaCategory, String) CreateForCaptureMonitoringWithCategoryAndDeviceId(MediaCategory, String)

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for audio capture streams with the specified MediaCategory that are using the specified audio device.

CreateForRenderMonitoring() CreateForRenderMonitoring() CreateForRenderMonitoring() CreateForRenderMonitoring() CreateForRenderMonitoring()

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for all audio render streams.

CreateForRenderMonitoring(AudioRenderCategory) CreateForRenderMonitoring(AudioRenderCategory) CreateForRenderMonitoring(AudioRenderCategory) CreateForRenderMonitoring(AudioRenderCategory) CreateForRenderMonitoring(AudioRenderCategory)

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for audio render streams with the specified MediaCategory.

CreateForRenderMonitoring(AudioRenderCategory, AudioDeviceRole) CreateForRenderMonitoring(AudioRenderCategory, AudioDeviceRole) CreateForRenderMonitoring(AudioRenderCategory, AudioDeviceRole) CreateForRenderMonitoring(AudioRenderCategory, AudioDeviceRole) CreateForRenderMonitoring(AudioRenderCategory, AudioDeviceRole)

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for render streams with the specified MediaCategory and AudioDeviceRole.

CreateForRenderMonitoringWithCategoryAndDeviceId(AudioRenderCategory, String) CreateForRenderMonitoringWithCategoryAndDeviceId(AudioRenderCategory, String) CreateForRenderMonitoringWithCategoryAndDeviceId(AudioRenderCategory, String) CreateForRenderMonitoringWithCategoryAndDeviceId(AudioRenderCategory, String) CreateForRenderMonitoringWithCategoryAndDeviceId(AudioRenderCategory, String)

Initializes a new instance of the AudioStateMonitor class that monitors the sound level for audio render streams with the specified MediaCategory that are using the specified audio device.

Events

SoundLevelChanged SoundLevelChanged SoundLevelChanged SoundLevelChanged SoundLevelChanged

Occurs when the system changes the sound level of the audio streams being monitored by the AudioStateMonitor.