Playing Sound Files in C++ using Visual Studio

preview_player
Показать описание
****Addition to video: several people have reported that they need this line of code (note the addition of TEXT) vs. the line shown in the video:
*****************************************************************

for more details on the PlaySound function, see the documentation
Рекомендации по теме
Комментарии
Автор

if youre trying to use this in a game, replace SND_SYNC with SND_ASYNC so that it doesn't pause your game to play the sound

siraxlrose
Автор

I'm definitely using this for my "Implement something not taught in class" requirement for my C++ project. Thank you so much!

matthewshepard
Автор

Thank you so much! I wasted DAYS searching through stack overflow, until I found this video! You saved my project from the waste bin ;-)

LIGHTBULBCODING
Автор

fyi you have to use audacity to convert the files, you cant just rename the files to .wav if you originally have a .mp3 or smthn

bollz
Автор

Thank you for this, straight to the point, thorough and easy to follow.

professorracc.
Автор

Thanks your video helped me solve a completely unrelated problem while coding OpenGL with Vs Code😅 I was not able to link a library.

eric
Автор

What to do if solution failed to build because of C4129 warning, C2143 error and LNK1120 build error? (i put ;)

lolbat.
Автор

what can I do if the code worked properly but instead of playing the wav file, plays a system sound? the wav file is in the same place as the project code, the line I put it like this: PlaySound(TEXT("DanceoftheGoblins.wav"), NULL, SND_FILENAME); I have also tried with SYNC but it didn't work T-T

kerenrodriguez
Автор

It returns 1, meaning the song should have been opened, but I only hear a Windows error pinging sound.

derpyherpy
Автор

Why it doesn't work in release mode?

MrT-obri
Автор

using visual studio 2022. cannot figure out how to add Winmm.lib. Properties look totally different. Help

rhke
Автор

IF there's a red underline under the name of the file, do something like this: _T("Your_Sound.wav"), use _T() to cover the string of your sound! TRY THIS OUT!

yuchang
Автор

Hi! great video. I did all the steps and get the boolean to return true but i dont hear the sound im trying to play.

what could be preventing my wav file from playing?

diegiandress
Автор

it runs but without sound
"I uses wav file"

youssefanuar
Автор

do you know a way to change the frequency of the sound?

netanel
Автор

Thanks. I also did it for the console (had to add an "L" before the name of the file, but its ok. However, I am hanging over my nerves because I have been unable to add sound to a Windows GUI application. The app builds fine, but unable to play the sound... will try harder.

violettaplatar
Автор

I am using .wav format but some sounds are working and some are not. They give out sound of windows default asterisk sound please help me.

Thank you.

muhammadumairqaisar
Автор

Hey so i tried this out but my music file that i wanted to put in was an MP3 file and it doesnt run.
Does it have to be something specific or any file will do.

kawaiken
Автор

what about adding the library in vs code?

fab_
Автор

Thank you so much!


But Is there a way to make sound play simultaneously, while next code is being executed?
Because the rest of my code is frozen until music stops playing.

ΛΞΟ