AppNotificationBuilder.SetAudioEvent Method

Definition

Overloads

SetAudioEvent(AppNotificationSoundEvent)

Sets the audio event for an app notification.

SetAudioEvent(AppNotificationSoundEvent, AppNotificationAudioLooping)

Sets the audio event and looping behavior for an app notification.

SetAudioEvent(AppNotificationSoundEvent)

Sets the audio event for an app notification.

public:
 virtual AppNotificationBuilder ^ SetAudioEvent(AppNotificationSoundEvent appNotificationSoundEvent) = SetAudioEvent;
/// [Windows.Foundation.Metadata.Overload("SetAudioEvent")]
AppNotificationBuilder SetAudioEvent(AppNotificationSoundEvent const& appNotificationSoundEvent);
[Windows.Foundation.Metadata.Overload("SetAudioEvent")]
public AppNotificationBuilder SetAudioEvent(AppNotificationSoundEvent appNotificationSoundEvent);
function setAudioEvent(appNotificationSoundEvent)
Public Function SetAudioEvent (appNotificationSoundEvent As AppNotificationSoundEvent) As AppNotificationBuilder

Parameters

appNotificationSoundEvent
AppNotificationSoundEvent

A member of the AppNotificationSoundEvent enumeration specifying a system sound to play.

Returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

Attributes

Examples

The following example demonstrates setting an audio event in the XML payload for an app notification.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetAudioEvent(AppNotificationSoundEvent.Alarm)
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <audio src='ms-winsoundevent:Notification.Looping.Alarm'/>
</toast>

Remarks

This method allows you to provide an consistent audio experience by specifying an audio event type, which uses standardized system sounds. You can specify a custom sound for an app notification by calling SetAudioUri.

For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to

SetAudioEvent(AppNotificationSoundEvent, AppNotificationAudioLooping)

Sets the audio event and looping behavior for an app notification.

public:
 virtual AppNotificationBuilder ^ SetAudioEvent(AppNotificationSoundEvent appNotificationSoundEvent, AppNotificationAudioLooping loop) = SetAudioEvent;
/// [Windows.Foundation.Metadata.Overload("SetAudioEvent2")]
AppNotificationBuilder SetAudioEvent(AppNotificationSoundEvent const& appNotificationSoundEvent, AppNotificationAudioLooping const& loop);
[Windows.Foundation.Metadata.Overload("SetAudioEvent2")]
public AppNotificationBuilder SetAudioEvent(AppNotificationSoundEvent appNotificationSoundEvent, AppNotificationAudioLooping loop);
function setAudioEvent(appNotificationSoundEvent, loop)
Public Function SetAudioEvent (appNotificationSoundEvent As AppNotificationSoundEvent, loop As AppNotificationAudioLooping) As AppNotificationBuilder

Parameters

appNotificationSoundEvent
AppNotificationSoundEvent

A member of the AppNotificationSoundEvent enumeration specifying a system sound to play.

loop
AppNotificationAudioLooping

A member of the AppNotificationAudioLooping enumeration specifying the looping behavior for the audio.

Returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

Attributes

Examples

The following example demonstrates setting an audio event in the XML payload for an app notification.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetAudioEvent(AppNotificationSoundEvent.Alarm, AppNotificationAudioLooping.Loop)
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <audio src='ms-winsoundevent:Notification.Looping.Alarm' loop='true'/>
</toast>

Remarks

This method allows you to provide an consistent audio experience by specifying an audio event type, which uses standardized system sounds. You can specify a custom sound for an app notification by calling SetAudioUri.

For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to