المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Sounds



C# Programming
06-05-2009, 11:20 PM
I want to have a sound for a background and when I click a button another sound to be played, but when I press the button the sound from it interrupts the sound from a background. I know this is because of the SoundPlayer class, but I don' t know how to fix it. How can I have a background sound that won' t be interrupted by another sounds and still plays?


class Sounds : Form
{
SoundPlayer BackgroundSound = new SoundPlayer();
SoundPlayer ButtonClicked = new SoundPlayer();

...

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

BackgroundSound.Sound******** = "C://BackgroundSound.wav";
BackgroundSound.PlayLooping();
}

public void Button1_Click(object sender, EventArgs e)
{
ButtonClicked.Sound******** = "C://ButtonClicked.wav";
ButtonClicked.Play();
}
}


"Good artists copy, great artists steal."