rss
 
comment(s)

archives
J|F|M|A|M|J|J|A|S|O|N|D
(20##) 10 9 8 7 6 5 4 3 2 1 0 <
 
DesktopWeb FormText   WPF : sound effectsSun, 30 Oct 2005 14:18:41 GMT # 

downloaded a bunch of .wav sound effects last night. thats always fun because you get to search for stupid words like 'boink' and 'doing' ... and the search actually returns matches ... and sound like what you would expect them to sound like! found the SoundPlayer class which looks like it is used to play sound effects. we have the MediaElement too, but my feeling is that is too heavy weight for a 2 second sound clip. you give the SoundPlayer a Stream or a file path and then you can Play() asynch, PlaySync(), or PlayLooping(). all i needed was Play() asynch ... but it totally butchers the wav files. serious ... think of somebody scratching a chalkboard ... thats what comes out alot of the time. PlaySync() works great but freezes your thread. quick and dirty, i just extended my SoundHandler to create a thread for each sound effect and call PlaySync() on that thread ... works fine.

also, XAML should incorporate a sound effect syntax for designers to do this. something like :
< SoundPlayer Source="{EmbeddedResource click.wav}" Playback="Asynch" / >
and it could use the existing Style.Triggers to be activated