【问题标题】:UWP toast custom sound doesn't playUWP toast 自定义声音不播放
【发布时间】:2016-12-23 00:41:47
【问题描述】:

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

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

【问题讨论】:

    标签: c# notifications uwp toast universal


    【解决方案1】:

    请参阅下面的 MSDN 教程。我用一个示例进行了尝试,结果完全符合预期。

    Quickstart: Sending a Toast notification with custom audio

    见下文

    已知问题:如果您使用的是桌面版 1511,自定义 toast 只有通过商店安装您的应用程序时,音频才会起作用。那 意味着您之前无法在 Desktop 上本地测试您的自定义音频 提交到商店——但音频一旦安装就可以正常工作 从商店。我们在周年更新中修复了这个问题,因此 来自本地部署应用的自定义音频将正常工作。

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

    【讨论】:

    • 刚刚更新到版本 1607 (14393.51),但 toast 仍然使用默认声音。
    • 在播放默认声音之前它是静音的。 Si 这是一个好的开始。现在在上面的示例中,您可以看到音频已添加到后端。试试看你的音频是否能播放。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    相关资源
    最近更新 更多