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.