I want to put a background song in my project C#

Asked

Viewed 506 times

0

Guys, this is the code I created, but when I press the button, the form simply hangs and nothing else works, I can only close it by Task Manager, but in the project no error is shown...

 public Form1()
            {
                InitializeComponent();
                _SoundPlayer = new SoundPlayer("music1.wav");
            }

            private void dualStateButton_CheckedChanged(object sender, EventArgs e)
            {
                if (dualStateButton.Checked)
                {
                    dualStateButton.Text = "Stop";
                    _SoundPlayer.Play();

                }
                else
                {
                    dualStateButton.Text = "Play";
                    _SoundPlayer.Stop();
                }
  • Already checked the file path . wav ?

  • Puts a Try catch in the methods to try to catch the error.

  • There is nothing wrong with the code presented, as long as the file has been included in the project and is being copied next to the compilation. But if it is not presented the error that was not found.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.