0

I'm new to C# and I'm making a mini-game. Playing sound effects is no problem, I can just use the System.Media.SoundPlayer class object to play a wav file streaming from, for example Properties.Resources.attack.wav, this is good but the background music will stop after I play the sound effect. Yes, I know there's Windows Media Player, but that uses URI, which I can't seem to add the resources directory there. I don't want to use local directory like @"D:\MyGame\backgroundmusic.wav" because I want to send it to a friend and can still hear the music. Is there any class or external sdk's that allow sound to be played simultaneously with other sounds FROM Properties.Resources? If none, what is the URI of the Resources folder inside a solution? Any help or advice would be awesome! Thank you.

edit: I already opened those links and tried them all several times. My main question is "How to play sound FROM the Resources Folder of the solution without other sounds interrupting it"

This is the concept:

private void Form_Load(object sender, EventArgs e)
    {
        var player = new System.Windows.Media.MediaPlayer();
        player.Open(Properties.Resources.sfx_background); 
        player.Play();
    }
 private void attack()
    {
        SoundPlayer p1 = new SoundPlayer();
        p1.Stream = Properties.Resources.sfx_sword;
        p1.Play();
    }

Where p1 plays synchronous with player, in which player gets the sound file from the Resources of the solution, not from a local storage of a computer.

Rex Endozo
  • 53
  • 1
  • 2
  • 10
  • Possible duplicate of [Playing multiple wav files in C#](https://stackoverflow.com/questions/15513599/playing-multiple-wav-files-in-c-sharp) – pstrjds Jul 29 '17 at 06:40
  • I am voting to close this as a duplicate of either [this](https://stackoverflow.com/questions/15513599/playing-multiple-wav-files-in-c-sharp) or [this](https://stackoverflow.com/questions/6240002/play-two-sounds-simultaneusly) as I feel your main question is "How do I play two sounds at once?" and then you have a second question "How do I get the URI of an embedded resource?" which may potentially be a duplicate of this [question](https://stackoverflow.com/questions/27757/how-can-i-discover-the-path-of-an-embedded-resource). Those links should help you in finding an answer. – pstrjds Jul 29 '17 at 06:43

0 Answers0