ElementSoundPlayer Class

Definition

Represents a player for XAML control sounds.

C#
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ElementSoundPlayer
Inheritance
Object ElementSoundPlayer
Attributes

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Examples

Tip

For more info, design guidance, and code examples, see Sound.

If you have the WinUI 2 Gallery app installed, click here to open the app and see the ElementSoundPlayer in action.

Remarks

For more info, see Sound in UWP apps.

Version history

Windows version SDK version Value added
1803 17134 SpatialAudioMode

Properties

SpatialAudioMode

Gets or sets a value that indicates whether spatial audio is on, off, or handled automatically.

State

Gets or sets a value that specifies whether the system plays control sounds.

Volume

Gets or sets the volume of the sounds played by the Play method.

Methods

Play(ElementSoundKind)

Plays the specified sound.

Applies to

Product Versions
WinRT Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100