Created
October 3, 2009 09:33
-
-
Save jcbozonier/200539 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void PlaySound(string fileName) | |
| { | |
| IntPtr handle = IntPtr.Zero; | |
| _Element.Dispatcher.Invoke(((Action)(() => | |
| { | |
| handle = ((HwndSource) PresentationSource.FromVisual(_Element)).Handle; | |
| }))); | |
| var device = new Device(DSoundHelper.DefaultPlaybackDevice); | |
| device.SetCooperativeLevel(handle, CooperativeLevel.Normal); | |
| using (var buffer = new VorbisBuffer(fileName, device, false, VorbisCaps.None)) | |
| { | |
| buffer.Play(false); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment