音訊audio

指定顯示快顯通知時要播放的音效。Specifies a sound to play when a toast notification is displayed. 這個元素也可讓您將任何快顯通知音訊靜音。This element also allows you to mute any toast notification audio.

元素階層Element hierarchy

<吐 司>
<toast>
<音訊><audio>

語法Syntax

<audio src?    = string
       loop?   = boolean
       silent? = boolean />

答案Key

?   選擇性 (零或一) ?   optional (zero or one)

屬性和項目Attributes and Elements

屬性Attributes

屬性Attribute 描述Description 資料類型Data type 必要Required 預設值Default value
looploop

如果音效應重複,只要顯示快顯通知,則設定為 truefalse 表示只播放一次。Set to true if the sound should repeat as long as the toast is shown; false to play only once. 如果這個屬性設定為true,則也必須設定快顯通知元素中duration屬性。If this attribute is set to true, the duration attribute in the toast element must also be set. 有些特定的聲音是在迴圈時使用。There are specific sounds provided to be used when looping. 請注意,UWP 應用程式不支援迴圈音訊或長時間的快顯通知。Note that UWP apps support neither looping audio nor long-duration toasts.

booleanboolean No falsefalse
沉默silent

True 表示將音效靜音; false 表示允許快顯通知音效播放。True to mute the sound; false to allow the toast notification sound to play.

booleanboolean No falsefalse
srcsrc

要取代預設音效播放的媒體檔案。The media file to play in place of the default sound. 在 Windows 上,此屬性可以有下列其中一個字串值:On Windows, this attribute can have one of the following string values:

  • winsoundevent:通知。預設值ms-winsoundevent:Notification.Default
  • ms winsoundevent:Notificationms-winsoundevent:Notification.IM
  • winsoundevent: Notification. Mailms-winsoundevent:Notification.Mail
  • winsoundevent:通知。提醒ms-winsoundevent:Notification.Reminder
  • winsoundevent:通知。 SMSms-winsoundevent:Notification.SMS
  • winsoundevent: Notification。鬧鐘ms-winsoundevent:Notification.Looping.Alarm
  • winsoundevent: Notification. Alarm2ms-winsoundevent:Notification.Looping.Alarm2
  • winsoundevent: Notification. Alarm3ms-winsoundevent:Notification.Looping.Alarm3
  • winsoundevent: Notification. Alarm4ms-winsoundevent:Notification.Looping.Alarm4
  • winsoundevent: Notification. Alarm5ms-winsoundevent:Notification.Looping.Alarm5
  • winsoundevent: Notification. Alarm6ms-winsoundevent:Notification.Looping.Alarm6
  • winsoundevent: Notification. Alarm7ms-winsoundevent:Notification.Looping.Alarm7
  • winsoundevent: Notification. Alarm8ms-winsoundevent:Notification.Looping.Alarm8
  • winsoundevent: Notification. Alarm9ms-winsoundevent:Notification.Looping.Alarm9
  • winsoundevent: Notification. Alarm10ms-winsoundevent:Notification.Looping.Alarm10
  • winsoundevent: Notification. Callms-winsoundevent:Notification.Looping.Call
  • winsoundevent: Notification. Call2ms-winsoundevent:Notification.Looping.Call2
  • winsoundevent: Notification. Call3ms-winsoundevent:Notification.Looping.Call3
  • winsoundevent: Notification. Call4ms-winsoundevent:Notification.Looping.Call4
  • winsoundevent: Notification. Call5ms-winsoundevent:Notification.Looping.Call5
  • winsoundevent: Notification. Call6ms-winsoundevent:Notification.Looping.Call6
  • winsoundevent: Notification. Call7ms-winsoundevent:Notification.Looping.Call7
  • winsoundevent: Notification. Call8ms-winsoundevent:Notification.Looping.Call8
  • winsoundevent: Notification. Call9ms-winsoundevent:Notification.Looping.Call9
  • winsoundevent: Notification. Call10ms-winsoundevent:Notification.Looping.Call10

如需自訂聲音的詳細資訊,請參閱「備註」一節。See the remarks section for information about custom sounds.

字串string No NoneNone

 

子元素Child Elements

無。None.

父項目Parent Elements

Parent 項目Parent Element 描述Description
吐 司 toast

基底快顯專案,其中至少包含一個 視覺 元素。Base toast element, which contains at least a single visual element.

 

備註Remarks

以桌面平臺為目標的 UWP 應用程式支援 Windows 10 1511 版 (build 10586) 和更新版本的自訂快顯通知音效。UWP apps that target the desktop platform support custom toast notification sounds on Windows 10, version 1511 (build 10586) and later. 在先前的版本中,您可以從 ms-winsoundevent 上表中 src 屬性所列的值清單中選擇。On earlier versions, you can choose from the list of ms-winsoundevent values listed for the src attribute in the table above. 如需有關自訂快顯通知聲音的詳細資訊,請參閱 快顯通知上的自訂音訊For more information about custom toast notification sounds, see Custom audio on toasts.

如果您在應用程式承載中指定自訂檔案路徑,則會根據指定的案例來播放預設的音效 (通知、通話、警示或提醒) 。If you specify a custom file path in the app payload, the default sound (notification, call, alarm, or reminder) will be played based on the specified scenario.

範例Examples

下列程式碼顯示此標記的範例。The following code shows an example of this tag.

<audio src="ms-winsoundevent:Notification.Mail" loop="false"/>
                

下列程式碼顯示用來將快顯通知音訊靜音的標記。The following code shows this tag used to mute toast notification audio.

<audio silent="true"/>
                

需求Requirements

NamespaceNamespace http://schemas.microsoft.com/notifications/2012/toast.xsd