Could not load sound.

HI. I use a windows project which is using directX and if I run a game, so it show “Could not load wind asset as a non-content file”
Code:

main.Content.RootDirectory = “Sounds”;
MediaPlayer.Play(main.Content.Load(“wind”));

Of course, that wind in output is set to “copy always”. I used format wav, wma, mp3 and if I use xnb, so it show

 HRESULT: [0x80070002]. System cannot find a file

Thanks for helping :slight_smile:

Your code is bad

in the global variable section
Song songname;

in the load content section

songname = Content.Load(“songfilename”);

MediaPlayer.Play(songname);

ok its setted to copy always but did you set it as content as well?

I agree with the guy above me.

you must make sure that you set it as a content file in the asset property and not anything else for it to be xna compatible.

Yes … everything are set to “copy always” and “content”

My codes work correct. If I use an OpenGl project, so the sounds play without problem, but if I use a DirectX project, so its show me an error (which I already wrote).

the file path. make sure it is pathed correctly within your monogames project!

I am sure, that paths to files are correct. I think, that I have the same problem with these http://monogame.codeplex.com/discussions/457268

The code. you changed the root directory to “sounds”

change it back to default
then in the load content method

go to where you load the sound do this

variable = Content.Load(“Sounds\songname”);
or
variable = Content.Load(“Sounds\songname”);

you see what is happening is it is a fools game to change the rootDirectory from default xna rootdirectory

here’s the original monogames code

Content.RootDirectory = “Content”;

make sure you use the

variable = Content.Load(“FolderName\contentfilename”);

that is how xna should be coded.

from there there is no more assistance.

JESUS IS LORD! JESUS IS THE KING!

Still doesnt work. For example I create a new project. I think, that code is good. My all project: Here

Hi.

Have you tried putting the xnb AND the wma? The XNB in this case is just a kind of header which references a WMA file (if you open the XNB with an hex editor you’ll see what I mean)

Problem solved. Thank you :slight_smile: