I'm trying to play L1.wav which is in my resources folder. Previously I have pulled images from the resources file using the line btc.Properties.Resources.noImg which worked perfectly but if I try and do the same for the wav file I get a '...does not contain a definition for L1. Its there, works fine if I double click it. How do I get it to work?
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = btc.Properties.Resources.L1;
player.play();
Thanks.
The SoundLocation property requires a string that contains a file path or a URL. The resource you added is however returned as a Stream if it was a .wav file. You should have gotten a compile error message, saying that it can't convert an UnmanagedMemoryStream to a string.
This code worked well on my machine:
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.test;
player.Play();
What btc means in your source code is quite mysterious and possibly the real source of the compiler error message you quoted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With