(C++) How to play Sound (Code::Blocks)

Make sure you #include Windows.h, before you #include MMSystem.h.
In linker I added “winmm”.
PlaySound(TEXT(“yourMusicFile.wav”), NULL, SND_SYNC);

All music in this video is covered under the “Creative Commons 0” License.
http://bit.ly/1eE5NB9

I know people are still going to want to know what the song is, so here.
http://bit.ly/1RVVgpy

Comments

Christian Gewert says:

When you include Windows.h it is NOT necessary to include MMSystem.h also! The API Documentation clearly says :
Header: Mmsystem.h (include Windows.h). Your program should work fine if you simply dismiss including MMSystem.h

Saahil R says:

what should i add in linker settings if I’m using ubuntu? please reply rn

RoBeX says:

I did everything you did but when i press build and run it just plays the standard windows sound (beep 🙂 ) and not the “Sound.wav”.

Quemu says:

GOD!@

Animesh Timsina says:

How to play music in background? so that music plays while the rest of the codes are being processed…….

Gerg Fluton says:

thanks man I sold this to some retard kid for $30

Gerg Fluton says:

thanks man I sold this to some retard kid for $30

LLukik says:

1. Udefined reference to PlaySoundA@12
2. ld returned 1 exit status
help 😀

Oğuz Atay says:

i couldnt see the codes. they are small as hell

Keith Bacalso says:

Pls tell me the steps on how to do it the video is so small in text I couldn’t see properly the codes or what you were clicking 🙁

Yilmer Tapias says:

buen video 🙂 thanks man XD

loukmane mohammed says:

man, you are genius !!!

Thijo CD says:

Finally something that works! Thanks man 😛

Arkadiusz Bryłkowski says:

U’RE THE BEST MEN! 😀 Always wanted to put Super Mario Bros sountrack xD

Blackscreen Music says:

I have rly cool C melody in my channel!

Blake Hampton says:

I am using VM ware that runs a Linux emulator. I am using coding blocks on this emulator for school. Will this still work?

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!