locked
Toast XML template

    Question

  • Hello guys.

    According to the toast quickstarts available in http://msdn.microsoft.com/en-us/library/windows/apps/hh465448.aspx, the XML generated by the templates should contain an audio element:

    var toastAudioElements = toastXml.getElementsByTagName("audio");
    toastAudioElements[0].setAttribute("src", "ms-winsoundevent:Notification.IM");
    toastAudioElements[0].setAttribute("loop", "false");
    

    However, that is not happening and I had to create a new audio element in order to change the default notification sound:

    var audio = template.getElementsByTagName("audio")[0];
    if (!audio) {
     audio = template.createElement("audio");
     elementoTopo.appendChild(audio);
    }

    The question: is this a bug which will be released in the next release? Or must I always create a new audio element whenever I need to change the default notification sound?

    thanks


    Luis Abreu

    Thursday, April 26, 2012 12:06 PM

Answers

All replies

  • See the toast sample for up to date syntax:

    http://code.msdn.microsoft.com/windowsapps/Toast-notifications-sample-52eeba29/view/SourceCode

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, April 26, 2012 2:58 PM
    Moderator
  • HEllo again Jeff.

    The problem wasn't really getting the correct XML because the schema docs are up to date. The problem was that I didn't expect to have to add the audio element since I expected it to be return in the template. Since it's optional, then I was probably expecting too much...

    Regarding the sample, I've seen it before. It uses several helper C# classes for hiding the XML from the developer. In fact, it uses a completely different approach from the docs since it will build the XML without any help from the toast notification manager. does this mean that we'll be seeing some improvements in the next release in this are? (ok, I know that you cannot confirm or deny anything about future releases :P)


    Luis Abreu

    Friday, April 27, 2012 7:47 AM
  • The documentation is a little behind but yes you have to create it.  Some of the documentation shows this, some doesn't but it will soon all get cleaned up!

    -Jeff


    Jeff Sanders (MSFT)

    Friday, April 27, 2012 11:45 AM
    Moderator