locked
Custom toast notification sound not playing on Windows Phone 8.1 RRS feed

  • Question

  • Hi everyone,

    I am trying to play a custom sound when I send a toast notification. I followed the documentation on MSDN, so my code that inserts the audio attribute looks like this:

    IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
    XmlElement audio = toastXml.CreateElement("audio");
    audio.SetAttribute("src", "ms-appx:///Assets/sounds/sound.wav");


    The sound is 4 seconds long and the copy to output directory properts is set to copy always. Unfortunately I have no idea what the issue might be here. Searching the web and msdn forums always leads to a Windows Phone 8 manual which (imo) doesn't apply for non-silverlight Windows Phone 8.1 apps.

    I'd be happy for any suggestions.

    Cheers,

    Fred

    • Edited by Freddixx Friday, September 12, 2014 12:33 AM
    Friday, September 12, 2014 12:32 AM

Answers

  • You're right the documentation is quite ambiquous there and I was only going by the documentation I linked to. So I looked up the definition of the ms-appx-URI. Given that the push message isn't received by a currently running application I believe that you might need to include the "authority-name" in your URI in order for it to be resolved correctly. At least it is worth a try. More information on that can be found here: http://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx
    Friday, September 12, 2014 2:01 PM

All replies

  • Going by the description of the audio element it only supports the built-in system sounds (you can however choose which one of those is to be played), see: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/br230842.aspx

    I agree that this is quite a step back from what was available in MPNS with 8.0 GDR3.

    • Proposed as answer by Oliver Ulm Friday, September 12, 2014 5:05 AM
    • Unproposed as answer by Oliver Ulm Friday, September 12, 2014 1:53 PM
    Friday, September 12, 2014 5:05 AM
  • Thanks for the quick reply, Oliver. The documentation is a bit confusing. This Page clearly states:

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

    That suggests that there is indeed a possibility to play a custom audio sound. Also a little sentence over here says:

    "The sound file is specified by using the "ms-winsoundevent:" prefix, or, on Windows Phone 8.1, a path that uses the "ms-appx:///" or "ms-appdata:///" prefix. This example creates an audio element and selects the toast element that will be its parent."

    Again, the ability to provide a local path conveys the feeling that you can specify a local audio source.

    So are you perfectly sure that this is not possible?


    • Edited by Freddixx Friday, September 12, 2014 1:46 PM Formatting
    Friday, September 12, 2014 1:27 PM
  • You're right the documentation is quite ambiquous there and I was only going by the documentation I linked to. So I looked up the definition of the ms-appx-URI. Given that the push message isn't received by a currently running application I believe that you might need to include the "authority-name" in your URI in order for it to be resolved correctly. At least it is worth a try. More information on that can be found here: http://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx
    Friday, September 12, 2014 2:01 PM
  • Well, I will try that and get back to you. But I already also tried it with a push channel with an app running in the foregound.
    Friday, September 12, 2014 4:50 PM