save sound into the program?

12padams

Well-known member
Joined
Feb 19, 2010
Messages
48
Programming Experience
Beginner
ok i am making a "game" in visual basic 2008 and I have come across a problem...

I need it to be able to play a sound without saying that the sound is stored at "c:\testsound.wav"

I have it working and playing the sound when i want but it only works on my computer :(

How can i save it into the resources just like you save a picture into resources?

Btw if it helps i am playing the sound using the axwindowsmediaplayer thing and it just plays the sound when the program loads...

so form1load then it plays the sound.

Anyway know how i can make it play the sound on other computers?
 
How can i save it into the resources just like you save a picture into resources?

Um, just like you said. You can add any file to your app's resources.

That said, it's not going to help you much as a resource because WMP requires a file. You say that it only works on your machine but that's not true. It only works on machines that have the WAV file present. If you deploy that WAV file with your app then it will work anywhere. Your choices are:

1. Keep using WMP and a WAV file, which you would deploy with your app.
2. Use the SoundPlayer class or My.Computer.Audio instead and embed your WAV file as a resource.
 
Back
Top