Freigeben über


The toast audio options catalog (Windows Runtime apps)

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 is showing. 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.

Toast audio on Windows Phone 8.1

When you specify one of the system-provided 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-provided sounds listed in this topic can be used in a Windows toast notification; the selections are not extensible.

Note  Windows Phone 8.1 allows the use of a local audio resource in addition to the toast audio options discussed here.

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.

 

Note  Looping audio and long-duration toasts are not supported on Windows Phone 8.1.

  • Notification.Looping.Alarm

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm2

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm3

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm4

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm5

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm6

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm7

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm8

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm9

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Alarm10

    Scenario: A countdown stopwatch has reached 0.

  • Notification.Looping.Call

    Scenario: An incoming phone call.

  • Notification.Looping.Call2

    Scenario: An incoming phone call.

  • Notification.Looping.Call3

    Scenario: An incoming phone call.

  • Notification.Looping.Call4

    Scenario: An incoming phone call.

  • Notification.Looping.Call5

    Scenario: An incoming phone call.

  • Notification.Looping.Call6

    Scenario: An incoming phone call.

  • Notification.Looping.Call7

    Scenario: An incoming phone call.

  • Notification.Looping.Call8

    Scenario: An incoming phone call.

  • Notification.Looping.Call9

    Scenario: An incoming phone call.

  • Notification.Looping.Call10

    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);

audio element

Quickstart: Sending a toast notification

Toast notifications sample

Toast XML schema