This topic lists the Windows-provided audio options available for use in a toast notification. The specified sound plays when the notification is displayed, as an indication to the user that a message requires their attention. These audio options are used by app developers when they define a toast notification's XML payload. For more information, see Quickstart: Sending a toast notification.
When you specify one of these sounds in the audio element of the toast notification's XML payload, you must add the "ms-winsoundevent:" prefix. For example:
<audio src="ms-winsoundevent:Notification.Mail" loop="false"/>
Note Only the system sounds listed in this topic can be used in a toast notification; the selections are not extensible.
Non-looping sounds
The following sounds play once and do not repeat. Set the loop attribute to false.
- Notification.Default
The sound that plays in the following situations:
- When it is explicitly specified
- When no other audio option is specified
- When the specified audio option is invalid
- When no other audio option fits your scenario
- Notification.IM
Scenario: A new instant messenger notification has arrived.
- Notification.Mail
Scenario: A new e-mail has arrived.
- Notification.Reminder
Scenario: An calendar item is due.
- Notification.SMS
Scenario: A new text message has arrived.
Looping sounds
The following sounds can optionally be looped until the notification is addressed.
Note Looping audio requires that you set the duration attribute in the audio element's parent toast element to "long". For more information, see the Remarks section.
- Notification.Looping.Alarm
Scenario: A countdown stopwatch has reached 0.
- Notification.Looping.Alarm2
Scenario: A countdown stopwatch has reached 0.
- Notification.Looping.Call
Scenario: An incoming phone call.
- Notification.Looping.Call2
Scenario: An incoming phone call.
If looping audio is specified in the toast template but the source is invalid or not specified, the Notification.Looping.Call sound will be used.
No sound
To send a toast notification that does not play a sound upon arrival, you must set the silent attribute in the audio element to "true" as shown here. The audio element is required and cannot be simply omitted.
<audio silent="true"/>
Examples
The following example shows how to set a sound for a toast notification that informs a user about an arriving instant message.
var template = Windows.UI.Notifications.ToastTemplateType.toastImageAndText01; var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(template); var toastAudioElements = toastXml.getElementsByTagName("audio"); toastAudioElements[0].setAttribute("src", "ms-winsoundevent:Notification.IM"); toastAudioElements[0].setAttribute("loop", "false");
The following example shows how to set a looping sound for a toast notification that informs a user about an incoming call.
var template = Windows.UI.Notifications.ToastTemplateType.toastText02 var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(template); var toastNode = toastXml.selectSingleNode("/toast"); toastNode.setAttribute("duration", "long"); var audio = toastXml.createElement("audio"); audio.setAttribute("src", "ms-winsoundevent:Notification.Looping.Call"); audio.setAttribute("loop", "true"); toastNode.appendChild(audio);
The following example shows how to declare that a toast notification should not play a sound.
var template = Windows.UI.Notifications.ToastTemplateType.toastImageAndText01; var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(template); var toastAudioElements = toastXml.getElementsByTagName("audio"); toastAudioElements[0].setAttribute("silent", true);
Related topics
Build date: 10/26/2012