locked
custom notification sound is not playing windows universal app 8.1

    Question

  • i want to play custom sound when notification received but instead of custom sound default sound is playing.

     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/bPlay-Guitar.aifc");
         toastNode.AppendChild(audio);
        //launch tost immediatly
    
        ToastNotification toast = new ToastNotification(toastXml);
        ToastNotificationManager.CreateToastNotifier().Show(toast);
    
    }

    Dattatray

    Friday, March 20, 2015 9:43 AM

Answers

  • I figured out the issue, aifc file  wont work  i have to convert it to wav

    Dattatray


    Friday, March 20, 2015 11:17 AM

All replies

  • I figured out the issue, aifc file  wont work  i have to convert it to wav

    Dattatray


    Friday, March 20, 2015 11:17 AM
  • I figured out the issue, aifc file  wont work  i have to convert it to wav

    Dattatray



    Glad that you've solved this issue and share your solution here:)

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 23, 2015 10:42 AM
    Moderator