开发者

Playing same sound many times C# WPF

开发者 https://www.devze.com 2023-04-11 11:24 出处:网络
I\'m trying to play the same overlapping sound whenever a button is pressed. I tried with MediaElement and SoundPlayer, but the music stops and starts again. I need to create a new instance, but creat

I'm trying to play the same overlapping sound whenever a button is pressed. I tried with MediaElement and SoundPlayer, but the music stops and starts again. I need to create a new instance, but creating new MediaElement() and adding to the Stage didn´t work too开发者_JS百科 :-/

Thanks for your help


Check here: http://www.interact-sw.co.uk/iangblog/2008/01/25/wpf-concurrent-audio

Create multiple MediaPlayers in the CodeBehind.


I had no succeed with MediaPlayers, but it works:

MediaElement mp = new MediaElement();
soundPanel.Children.Add(mp);
mp.Source = new Uri(key_sound, UriKind.RelativeOrAbsolute);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号