I want a wav file to play in the background of a form when it is opened. How do I do this?
Asked
Active
Viewed 267 times
-1
-
Use Form Load Event, and in the event method you might try to play your Wav File. – Rangesh Jun 14 '14 at 15:30
-
Look at those duplicate questions and see if their answers are useful to you: http://stackoverflow.com/questions/15025626/playing-a-mp3-file-in-a-winform-application, http://stackoverflow.com/questions/9645386/playing-mp3-file-using-c-sharp, http://stackoverflow.com/questions/1304223/playing-sounds-in-winforms-using-c-sharp – Alejandro Jun 14 '14 at 15:32
-
None of them questions are duplicate to mine.. – user3732999 Jun 14 '14 at 15:41
1 Answers
0
Add the following code to the event when you want to play the file:
var player = new System.Media.SoundPlayer();
player.SoundLocation = @"D:\.....\some file.wav";
player.Load();
player.Play();

kevin
- 2,196
- 1
- 20
- 24
-
Yep already had that code, I just had it in the wrong place of the code, . Thanks – user3732999 Jun 14 '14 at 15:41