AppNotificationBuilder.SetAudioEvent 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
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列舉的成員,指定要播放的系統音效。
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 架構的參考資訊,請參閱 代理程式更新內容架構。