Search code examples
c#notificationsuwptoastuniversal

UWP toast custom sound doesn't play


I have this toast to show up and everything is fine except audio. I was trying to put toast.mp3 in different locations like projects main folder, Assets etc. and even used path like D:/MyProjectPath/Assets/toast.mp3 and still notification is silent. I am a beginner so maybe I miss something... And of course I've looked for solution but nothing has been helpful.Here is my code:

string xml = $@"<toast scenario=""reminder"">
        <visual>
        <binding template=""ToastGeneric"">
            <text>{name}</text>
            <text>{quantity} {unit}</text>
            <text>{beforeorafter}</text>

        </binding>
        </visual>
        <actions>
        <input id=""snoozeTime"" type=""selection"" defaultInput=""10"">
            <selection id=""5"" content=""5 minutes""/>
            <selection id=""10"" content=""10 minutes""/>
            <selection id=""15"" content=""15 minutes""/>
        </input>
        <action activationType=""system"" arguments=""snooze"" hint-inputId=""snoozeTime"" content=""""/>
        <action activationType=""system"" arguments=""dismiss"" content=""""/>
        </actions>
        <audio src = ""ms-appx:///Assets/toast.mp3"" loop = ""true""></audio>
        </toast>";

Solution

  • See below Tutorial on MSDN. I tried this with a sample and it worked exactly as intended.

    Quickstart: Sending a Toast notification with custom audio

    Also see below

    Known Issue: If you’re using Desktop Version 1511, the custom toast audio will only work if your app is installed via the Store. That means you cannot locally test your custom audio on Desktop before submitting to the Store – but the audio will work fine once installed from the Store. We fixed this in the Anniversary Update, so that custom audio from your locally deployed app will work correctly.

    So that might be your problem. This is fixed in Anniversary update.