0

I have created a C# desktop application using WPF for sending a toast notification. I am using my own custom audio to play when the toast notification gets displayed. I found some problems where my custom sound is not getting played when the notification window is popped out.

I have used the following code to add custom audio to my notification.

        bool supportsCustomAudio = true;

        if (AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Desktop")
            && !ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2))
        {
            supportsCustomAudio = false;
        }
        if (supportsCustomAudio)
        {
            notificationBuilder.AddAudio(new Uri("ms-appx:///Assets/Audio/customaudio.mp3"));
        }

Am I missing something? Could someone please help me with the issue?

7
  • ms-appx:/// is known not to work in WPF and according to Custom audio on toasts, only ms-appx:/// and ms-resource are supported. So I am skeptical that you could use it in WPF. Commented Jun 28, 2022 at 12:30
  • I have using ms-appx:/// only in my WPF application. Can you please suggest why it is not working? Commented Jun 28, 2022 at 13:23
  • Do you mean you successfully use ms-appx:/// in other part of your WPF app? Commented Jun 28, 2022 at 13:26
  • This is the only part of code where i am using ms-appx:/// to refer my custom audio present in the project directory for the toast notification.. Commented Jun 28, 2022 at 13:29
  • As far as I know, ms-appx:/// does not work in WPF. Commented Jun 28, 2022 at 13:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.