0
votes

i want to play custom sound when notification received but instead of custom sound default sound is playing. whta wrong is going on here. even the audio on correct path.

 public void AddNotification(int t, String date,String idPrefix)
{
    ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
    XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);

    DateTime dueTime = DateTime.Now;
    string period = String.Empty;

    switch (t)
    {
        case 0:
            period = "15min";
            dueTime = GetNotificationTime(date, dueTime, 15);
            break;
        case 1:
            period = "30min";
            dueTime = GetNotificationTime(date, dueTime, 30);
            break;
        case 2:
            period = "1hr";
            dueTime = GetNotificationTime(date, dueTime, 60);
            break;
        default: break;
    }

    XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
    toastTextElements[0].AppendChild(toastXml.CreateTextNode("show time"));
    toastTextElements[1].AppendChild(toastXml.CreateTextNode("Watch show in " + period));

    //XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image");

    //((XmlElement)toastImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/CameraSelected.png");
    //((XmlElement)toastImageAttributes[0]).SetAttribute("alt", "Camera Selected");

    IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
    ((XmlElement)toastNode).SetAttribute("launch", "LandingPage.xaml");

    XmlElement audio = toastXml.CreateElement("audio");
    audio.SetAttribute("src", "ms-appx:///Assets/Guitar.aifc");
     toastNode.AppendChild(audio);
    //launch tost immediatly

    ToastNotification toast = new ToastNotification(toastXml);
    ToastNotificationManager.CreateToastNotifier().Show(toast);

}

What wrong i am doing here. can anyone guide me in implementation.

1

1 Answers

0
votes

I figured out the solution

It won't support aifc files. i have converted sound file to wav and now it is working fine