none
Notification custom Sound not playing

    Question

  • I have tested my App without any custom sound and the default sound plays perfectly

     var prayerName = App_Code.helperMethods.getPrayerNameforNotification(i);
                ToastAudio tA = new ToastAudio();
                tA.Src = new Uri("ms-appx:///Assets/Sounds/AnyDay.mp3");
                
    
                ToastContent con = new ToastContent()
                {
                    Visual = new ToastVisual()
                    {
                        TitleText = new ToastText() { Text = "Namaz Pro" },
                        BodyTextLine1 = new ToastText() { Text = prayerName + " in " + App_Code.StoreRetrieveSettingsAssist.getLocation() },
                        BodyTextLine2 = new ToastText() { Text = App_Code.helperMethods.userSpecifiedTimeFormat(myPT, DateTime.Today) },
                    },
    
                    Launch = DateTime.Today.ToString("ddMMyyyy") + i.ToString(),
    
                    Scenario = ToastScenario.Alarm,
    
                    Duration = ToastDuration.Short,
    
                    Audio = tA,
    
    
    
                };
    
               
    
                return con;

    I have three projects in my Solution :

    1> App_Code  

    2> BackgroundTasks (References App_Code)

    3> XYZ Pro(References App_Code)  {MAIN APP}

    My custom sound is "AnyDay.mp3"(for the curious ones its by Elvis) placed inside main project as : XYZ Pro/Assets/Sounds/AnyDay.mp3

    However the sound doesn't play at all and Notification acts as if it is silent. 

    Tuesday, February 9, 2016 9:25 AM

Answers

  • @Rahul Jha,

    Can I understand that your app code cannot get the mp3 file from your main project? Please try copy your mp3 file to the target machine and use some WinRT api to get it and play it. Then I think it will playing without problem.

    Best regards,

    Barry


    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.


    Friday, February 19, 2016 4:49 AM
    Moderator

All replies

  • Hi

    Check following code, It worked for me by playing custom audio.

                ToastAudio tA = new ToastAudio();
                tA.Src = new Uri("ms-appx:///Assets/Sounds/AnyDay.mp3");

                ToastContent con = new ToastContent()
                {
                    Visual = new ToastVisual()
                    {
                        TitleText = new ToastText() { Text = "Namaz Pro" },
                        BodyTextLine1 = new ToastText() { Text="Audio toast notification"}

                    },
                    Scenario = ToastScenario.Alarm,

                    Duration = ToastDuration.Short,

                    Audio = tA,
                };

                ToastNotification toast = new ToastNotification(con.GetXml());
                ToastNotificationManager.CreateToastNotifier().Show(toast);

    Tuesday, February 9, 2016 10:51 AM
  • The problem is my SOlution is spread across projects. My App_Code project is not my main app
    • Edited by Rahul Jha Tuesday, February 9, 2016 6:13 PM
    Tuesday, February 9, 2016 6:09 PM
  • @Rahul Jha,

    Can I understand that your app code cannot get the mp3 file from your main project? Please try copy your mp3 file to the target machine and use some WinRT api to get it and play it. Then I think it will playing without problem.

    Best regards,

    Barry


    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.


    Friday, February 19, 2016 4:49 AM
    Moderator