locked
Toast Notification audio not playing

    Question

  • Hi

    I am trying to create a toast notification which plays the alarm sound in loop. Though the notification displays properly but no sound plays with the notification. My code is:

    var template = Windows.UI.Notifications.ToastTemplateType.toastText04;
                                        var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(template);
                                        var toastTextElements = toastXml.getElementsByTagName("text");
                                        toastTextElements[0].appendChild(toastXml.createTextNode(alaName.toUpperCase()));
                                        toastTextElements[1].appendChild(toastXml.createTextNode(alaType));
                                        toastTextElements[2].appendChild(toastXml.createTextNode(alaDate));


                                        var toastNode = toastXml.selectSingleNode("/toast");
                                        toastNode.setAttribute("duration", "long");

                                        var audio = toastXml.createElement("audio");
                                        audio.setAttribute("src", "ms-winsoundevent:Notification.Looping.Alarm");
                                        audio.setAttribute("loop", "true");
                                        audio.setAttribute("silent", "false");
                                        toastNode.appendChild(audio);

                                        var toast = Windows.UI.Notifications.ToastNotification(toastXml);
                                        var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.createToastNotifier();
                                        var scheduledToast = new Windows.UI.Notifications.ScheduledToastNotification(toastXml, alarmDateTime);
                                        scheduledToast.id = toastId + i;

        toastNotifier.addToSchedule(scheduledToast);

    Please help me if I am doing anything wrong in here.

    Thanks

    - Ravi

    Friday, June 15, 2012 3:38 PM

Answers

  • Yes they are turned on already. I am still running the consumer preview and haven't yet installed the release preview. Is by any chance this issue is related to consumer preview?
    • Marked as answer by ravipiplani Wednesday, June 27, 2012 9:13 PM
    Monday, June 18, 2012 2:55 PM
  • I upgraded to release preview and now I can hear the sound. :) So I think this issue was related to consumer preview.
    • Marked as answer by ravipiplani Wednesday, June 27, 2012 9:13 PM
    Wednesday, June 27, 2012 9:13 PM

All replies

  • Hi Ravi,

    What have you done so far to troubleshoot your problem?

    Did you run the Toast Notifications sample with defaults and to the toast make sounds (scenario 4)?

    Do any sounds work on your machine?

    -Jeff


    Jeff Sanders (MSFT)

    Monday, June 18, 2012 2:24 PM
    Moderator
  • Yes Jeff. I tested with the default options too but no luck. And yeah I can listen to songs on my machine. :)
    Monday, June 18, 2012 2:33 PM
  • So it appears your sound driver is OK.  Did you check to see if "notifications sound" has been turned off?

    In start screen, type: notifications sound

    Then click on settings and you will see a link to 'Turn notification sounds on or off'

    -Jeff


    Jeff Sanders (MSFT)

    Monday, June 18, 2012 2:36 PM
    Moderator
  • Yes they are turned on already. I am still running the consumer preview and haven't yet installed the release preview. Is by any chance this issue is related to consumer preview?
    • Marked as answer by ravipiplani Wednesday, June 27, 2012 9:13 PM
    Monday, June 18, 2012 2:55 PM
  • Ravi,

    Let's defer this investigation until you have a chance to upgrade.  If you do still have problem please post back after upgrading.

    -Jeff


    Jeff Sanders (MSFT)

    Monday, June 18, 2012 3:07 PM
    Moderator
  • Alright. I will keep this post updated.

    Thanks

    -Ravi

    Monday, June 18, 2012 3:16 PM
  • I upgraded to release preview and now I can hear the sound. :) So I think this issue was related to consumer preview.
    • Marked as answer by ravipiplani Wednesday, June 27, 2012 9:13 PM
    Wednesday, June 27, 2012 9:13 PM