How to play multiple sounds simultaniously using WMP without interference

  • Thread starter Thread starter Zerioto
  • Start date Start date
Z

Zerioto

Guest
Hi, i've been working on a TicTacToe game that i want to have background music and win/loss sounds.

I start playing the background music with:

string mp4path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BackgroundMusic.mp4");
string applause = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "applause.mp4");
string boo = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Boo.mp4");

public Form1()
{
InitializeComponent();
if (!File.Exists(mp4path))
{
File.WriteAllBytes(mp4path, TicTacToe.Properties.Resources.Music);
}
WMP1.URL = mp4path;

if (!File.Exists(applause))
{
File.WriteAllBytes(applause, TicTacToe.Properties.Resources.Applause);
}
if (!File.Exists(boo))
{
File.WriteAllBytes(boo, TicTacToe.Properties.Resources.Boo);
}
WMP2.settings.autoStart = false;
}

which starts playing because of me just assigning a value to WMP1.URL(it defaults with autoStart enabled i guess).
whenever i win or lose the match, i state that:

if (winner == true)//idc who wins or loses i just want to play the sound
{
if (AIBtn.Text == "Enabled")
{
WMP2.URL = boo;
WMP2.Ctlcontrols.play();
}

i DO NOT tell WMP2 to play the background music, i tell it to play boo.mp4.
what happens when i start WMP2 is that the background music starts a new instance of its self while keeping the old instance.
i do not know if it plays the background music on WMP2 or if WMP1 is playing 2 instances of its self.
it also does not play the boo sound at all.

I posted a .rar here:
Gofile - File sharing platform, anonymous and free

To be clear, i want it to play background music on WMP1 and only use WMP2 for an applause/boo on a win/loss.
i've only been doing programming for 3 months so if you do know a solution, could you make it sound as idiot friendly as possible?

Continue reading...
 
Back
Top