c# - Scheduled Toast Notification Alarm loop -


i'm working toast , create scheduled toast show after specific time. have problem audio, goal make sound in loop unitl user press button, when set loop parameter true, toast didn't work. system windows 10 build 10240.

toastcontent content = new toastcontent() {     duration = toastduration.long,     visual = new toastvisual()     {         titletext = new toasttext()         {             text = "alarm"         },          bodytextline1 = new toasttext()         {             text = "wake up"         }     },     scenario = toastscenario.reminder,     audio = new toastaudio()     {         src = new uri("ms-winsoundevent:notification.looping.alarm"),         loop = true,         silent = false     },     actions = new toastactionscustom()     {         buttons =         {            new toastbuttonsnooze(),            new toastbuttondismiss()         }     } };  scheduledtoastnotification toast = new scheduledtoastnotification(content.getxml(), duetime); toastnotificationmanager.createtoastnotifier().addtoschedule(toast); 

edit loop works when write toast xml. solution

xml file

    <?xml version="1.0" encoding="utf-8" ?> <toast duration="long" scenario="alarm">   <visual>     <binding template="toastgeneric" >       <text> daily .net tips </text>     </binding>    </visual>   <audio src="ms-winsoundevent:notification.looping.alarm" loop="true">   </audio>   <actions>   <action activationtype="system" arguments="snooze" content=""/>   <action activationtype="system" arguments="dismiss" content=""/>   </actions>   </toast> 

c# code

        string xmlstring = file.readalltext(@"toasttemplate\alarmtemplate.xml");         windows.data.xml.dom.xmldocument toastdom = new windows.data.xml.dom.xmldocument();         toastdom.loadxml(xmlstring);          var toastnotifier = toastnotificationmanager.createtoastnotifier();         toastnotifier.show(new toastnotification(toastdom));   

this andrew notifications team on microsoft.

since using scenario = alarm, do not need set duration or loop.

the alarm scenario automatically keep toast on user's screen until take action, setting duration = long useless.

also, alarm scenario automatically loop audio, setting loop = true useless.

here's updated code should (make sure you're setting scenario alarm, noticed had reminder in original code)...

toastcontent content = new toastcontent() {     visual = new toastvisual()     {         titletext = new toasttext()         {             text = "alarm"         },          bodytextline1 = new toasttext()         {             text = "wake up"         }     },     scenario = toastscenario.alarm,     audio = new toastaudio()     {         src = new uri("ms-winsoundevent:notification.looping.alarm")     },     actions = new toastactionscustom()     {         buttons =         {            new toastbuttonsnooze(),            new toastbuttondismiss()         }     } }; 

as why toast breaking via notificationsextensions rather raw xml... looks found bug in notificationsextensions.

i updated notificationsextensions.win10 today address bug, version 10586.0.2 has fix (or version 10240.0.8 if you're still using 10240 versions). details of fix in this code commit if you're curious.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -