在Windows Phone 8.1中,吐司通知的声音在某个时间停止

时间:2015-08-11 15:07:40

标签: c# windows-phone-8.1

我正在编写一个使用Toast通知的Windows Phone 8.1应用程序,它必须在循环中多次显示。它显示的是值,但只播放一次声音。这是代码:

while (increments <10)
{
   ToastTemplateType toastType = ToastTemplateType.ToastText02;

   XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastType);

   XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");
                    toastTextElement[0].AppendChild(toastXml.CreateTextNode("Time since button pressed: "));
   toastTextElement[1].AppendChild(toastXml.CreateTextNode( increments+" seconds"));

   IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
   ((XmlElement)toastNode).SetAttribute("duration", "long");

   XmlElement audio = toastXml.CreateElement("audio");
   audio.SetAttribute("src", "ms-appx:///Assets/N.mp3");
   toastNode.AppendChild(audio);

   ToastNotification toast = new ToastNotification(toastXml);
   ToastNotificationManager.CreateToastNotifier().Show(toast);
   increments++;
   tempCounter++;
}

0 个答案:

没有答案