Trying to play the .wav file, which is located in the "Resources" folder, it is there, but the visual studio, it is not!

I am trying to play L1.wav which is in my resources folder. I used to pull images from a resource file using the line btc.Properties.Resources.noImg, which worked fine, but if I try to do the same for the wav file, I get "... does not contain a definition for L1. Its there, great works if i double click on it.How can I make it work?

System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = btc.Properties.Resources.L1;
player.play();

Thank.

+5
source share
4 answers

SoundLocation , URL-. , .wav . , , UnmanagedMemoryStream .

:

        System.Media.SoundPlayer player = new System.Media.SoundPlayer();
        player.Stream = Properties.Resources.test;
        player.Play();

btc , , , , .

+5

-

System.Media.SoundPlayer player = System.Media.SoundPlayer(@" file.wav);            player.Play();

0
Stream audio = <assembly>.Properties.Resources.ResourceManager.GetStream("notify.wav");
        SoundPlayer player = new SoundPlayer(audio);
        player.Play();

...

0
(new SoundPlayer(Properties.Resources.L1)).Play();

.

0

All Articles