Play two sounds simultaneusly

前端 未结 6 1151
时光取名叫无心
时光取名叫无心 2020-11-27 05:09

Is there a way to play two sounds at the same time?

I know that SoundPlayer isn\'t able to do this. I can\'t use SoundEffect as I believe i

6条回答
  •  盖世英雄少女心
    2020-11-27 05:58

    The accepted answer didn't work for me.

    Here is what worked:

    Make sure you add references to PresentationCore and WindowsBase dlls.

         private void Form1_Load(object sender, EventArgs e)
         {
    
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"C:\Users\me\source\repos\TacticalIslandSurvival\sounds\blazer rail.wav");
                player.PlayLooping();
         }
    
            private void button1_MouseEnter(object sender, EventArgs e)
            {            
                var p1 = new System.Windows.Media.MediaPlayer();
                p1.Open(new System.Uri(@"C:\Users\me\source\repos\TacticalIslandSurvival\sounds\click.wav"));
                p1.Play();
    
            }
    

提交回复
热议问题