UWP toast 自定义声音无法播放

UWP toast custom sound doesn't play

我要祝酒词出现,一切都很好,除了音频。我试图将 toast.mp3 放在不同的位置,如项目主文件夹、资产等,甚至使用像 D:/MyProjectPath/Assets/toast.mp3 这样的路径,但通知仍然是无声的。我是初学者,所以也许我错过了一些东西......当然我一直在寻找解决方案,但什么都没有 helpful.Here 是我的代码:

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>";

请参阅下面的 MSDN 教程。我用一个样本试了一下,它完全按预期工作。

Quickstart: Sending a Toast notification with custom audio

另见下文

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.

所以这可能是你的问题。这已在周年更新中修复。