Share via


AppNotificationBuilder.SetAudioEvent 方法

定义

重载

SetAudioEvent(AppNotificationSoundEvent)

设置应用通知的音频事件。

SetAudioEvent(AppNotificationSoundEvent, AppNotificationAudioLooping)

设置应用通知的音频事件和循环行为。

SetAudioEvent(AppNotificationSoundEvent)

设置应用通知的音频事件。

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

参数

appNotificationSoundEvent
AppNotificationSoundEvent

指定要播放的系统声音的 AppNotificationSoundEvent 枚举的成员。

返回

返回 AppNotificationBuilder 实例,以便可以链接其他方法调用。

属性

示例

以下示例演示如何在应用通知的 XML 有效负载中设置音频事件。

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

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

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

注解

此方法允许通过指定使用标准化系统声音的音频事件类型来提供一致的音频体验。 可以通过调用 SetAudioUri 为应用通知指定自定义声音。

有关使用 AppNotificationBuilder API 创建应用通知 UI 的指导,请参阅 应用通知内容

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构

适用于

SetAudioEvent(AppNotificationSoundEvent, AppNotificationAudioLooping)

设置应用通知的音频事件和循环行为。

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

参数

appNotificationSoundEvent
AppNotificationSoundEvent

指定要播放的系统声音的 AppNotificationSoundEvent 枚举的成员。

loop
AppNotificationAudioLooping

AppNotificationAudioLooping 枚举的成员,指定音频的循环行为。

返回

返回 AppNotificationBuilder 实例,以便可以链接其他方法调用。

属性

示例

以下示例演示如何在应用通知的 XML 有效负载中设置音频事件。

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

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

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

注解

此方法允许通过指定使用标准化系统声音的音频事件类型来提供一致的音频体验。 可以通过调用 SetAudioUri 为应用通知指定自定义声音。

有关使用 AppNotificationBuilder API 创建应用通知 UI 的指导,请参阅 应用通知内容

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构

适用于