Play audio when timer ends

Hi, I’m trying to get an audiofile to play after a certain amount of time / other inputs, for an instructional app. Is there any way to trigger the PlaySound from javascript? I’ve also found a little on the StreamingAudio api that was to be added, but can’t find any documentation…

Hey Stefan,

For this, you should use UserEvent.

You could create an UserEvent inside the component which will need to raise the event. There are 2 ways you can raise events - in UX when a user clicks something or (just like you need) directly from JavaScript using .raise() method whenever you fancy.

For a PlaySound use case, here’s a small code example. Inside component MyComponent I created UserEvent and added some JavaScript that will raise this event after a delay. In UX I added OnUserEvent trigger inside of the class instance et voila!

    <Panel ux:Class="MyComponent">
        setTimeout(function() {
        }, 3000);
        <UserEvent ux:Name="myEvent" />
        <OnUserEvent EventName="myEvent">
            <DebugAction Message="PlaySound would happen here" />
            <!-- <PlaySound ... /> -->

Hope this helps!

Hey Arturs,
Thanks, it helped a lot!