Windows Phone 8.1 Toast 通知不播放自定义声音 [英] Windows Phone 8.1 Toast Notification not playing custom sound

查看:46
本文介绍了Windows Phone 8.1 Toast 通知不播放自定义声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常需要你的帮助.我是一名 Windows 应用程序开发人员,我需要我的应用程序在收到 Toast 通知时播放警报声.我尝试了许多不同的加载,一切正常(甚至在音频标签中应用 silent='true'),当然,除了自定义声音.

I am in dire need of your help. I am a Windows app developer and I need my app to play an alarm sound when a toast notification is received. I have tried many different loadouts and everything works fine (Even applying silent='true' in the audio tag), except, ofcourse, for the custom sound.

我尝试了我的开发服务器,并尝试使用从应用程序发送的本地 Toast,但似乎没有任何效果.

I have tried my dev server and I have tried with a local toast sent from the app, and nothing seems to work.

我当前的 XML 加载如下(我从 MSDN 的一个例子中得到它):

My current XML loadout is as follows (I got it from an example in MSDN):

string audio = "ms-winsoundevent:Notification.Mail";
string toastXmlString = "<toast duration='long'>"
                   + "<visual version='1'>"
                   + "<binding template='ToastText02'>"
                   + "<text id='1'>Sound:</text>"
                   + "<text id='2'>" + audio + "</text>"
                   + "</binding>"
                   + "</visual>"
                   + "<audio src='" + audio + "' />"
                   + "</toast>";

我曾经设法播放的唯一声音是默认的 Windows 声音.没有ms-winsoundevent"声音,没有ms-appx"或ms-appdata"声音,什么都没有.

The only sound I ever managed to play was the default windows sound. No 'ms-winsoundevent' sounds, no 'ms-appx' or 'ms-appdata' sounds, nothing.

我检查了标头和 XML 加载并将它们与 MSDN 文档进行了比较.我尝试了不同的格式(mp3 和 wav)和不同的音频剪辑长度(18 秒、5 秒、10 秒等...)

I have checked the headers and XML loadout and compared them to the MSDN documentation. I have tried different formats (mp3 and wav) and different audio clip lengths (18secs, 5secs, 10secs, etc...)

我的经验告诉我,如果 XML 加载或标题出现问题,toast 要么不会到达,要么文本不会显示.然而,除了声音之外,一切正常.

My experience tells me that if there was a problem with the XML loadout or the headers the toast would either not arrive or the text would not show. Other than the sound however, everything works fine.

预先感谢您提供的所有帮助.

Thanks in advance for all the help you may offer.

推荐答案

我不知道你是否已经解决了你的问题,但问题在于 duration="long" 属性.

I don't know if you have already sorted out your problem, however the issue lies in the duration="long" attribute.

根据 MSDN:

请注意,Windows Phone 8.1 不支持循环音频和长时间的 Toast.所以你必须使用 duration="short" 才能播放自定义声音.

Note that neither looping audio nor long-duration toasts are not supported on Windows Phone 8.1. so you have to use duration="short" in order to be able to play the custom sound.

它是sound标签文档中隐藏的NOTE,没有明确说明,最糟糕的是通知将正确显示,将应用静音属性但不会播放声音.此外,声音文件应少于 10 秒,但 short toast 通知仅显示 5-6 秒,loop 将不会按规定工作.

It is a hidden NOTE in the sound tag documentation and is not states clearly and the worst part is the notification will be displayed properly, the silence attribute will be applied but the sound will not be played. Also sound files should be less than 10 seconds but short toast notification is displayed for 5-6 seconds only and the loop will not work as stated.

希望对你有帮助:)

这篇关于Windows Phone 8.1 Toast 通知不播放自定义声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆