Reputation: 1
My project is to build a simple game and for now I only made the Main Menu Form1
with 5 buttons. The buttons have a MouseClick
and MouseEnter
on them, and I have a background music track using a WMP method (using WMPLib and axWMPLib).
My problem is when I'm taking the bin/debug
putting it on a rar
file and giving it to my friends, they say they don't hear the sound. I made the project trough WMP version 11, so I asked them if their WMP version is 11 and they said yes. I have no idea why I hear the sounds on my computer and they don't.
I tried to give them the folders:
bin\Release
bin\Debug
x86\Release
x86\Debug
but they still said that they can't hear any sound from all of them.
EDIT
All my sounds are in a folder called "Sounds". I found some details and found out that you need to embeding those WMP sounds to "Resources".
So how can I do that, and how I call them when Form1
loads up. And no, this following code doesn't work:
BackGround.URL = Properties.Resources.Invincible;
It says I can't convert System.IO.UnmanagedMemoryStream
to String
.
Upvotes: 0
Views: 536
Reputation: 16621
Sincerely I don't recommend you to use WMP, so give a look to the SoundPlayer class. However I think the problem is that you don't give the correct location to your files. So what you can do is to locate your files in your application folder, get its location and create the location of the music files.
So try:
string musicName = Application.StartupPath + "music.mp3";
Or if you have a Sounds folder in the application path use:
string musicName = Application.StartupPath + "\\Sounds\\music.mp3";
Else if you insert your music file in the application resources this:
BackGround.URL = Properties.Resources.Invincible;
didn't work because BackGround.URL
is of type string while Properties.Resources.Invincible
is the music file stream.
I don't know if using WMP you can set the stream from where it can play the file. Although the SoundPlayer
class I linked previously contains a property from where you can set the input stream. You can do it in this way:
SoundPlayer mySoundPlayer = new SoundPlayer();
mySoundPlayer.Stream = Properties.Resources.Invincible;
mySoundPlayer.Load();
mySounPlayer.Play(); //plays the Properties.Resources.Invincible sound
Upvotes: 1