C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-02-2009, 07:46 AM   #1
Registered User
 
Join Date: Nov 2009
Posts: 3
Smile How to play an audio file in c program?

Please can any one tell me how to open an audio file in C Program?
I came across a function "fopen", but i think its for opening text file. If i m wrong with that, can anyone tell me how to open audio file using "fopen".
yugal0007 is offline   Reply With Quote
Old 11-03-2009, 03:08 AM   #2
Registered User
 
Join Date: Jan 2009
Posts: 30
There are three ways that I know of to play an audio file:

MCI
waveOut
DirectSound

I haven't really used them that much, so I can't help you at all with how to use them. Google their names to find out about them.
DeadPlanet is offline   Reply With Quote
Old 11-03-2009, 03:13 AM   #3
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks i will try it.
yugal0007 is offline   Reply With Quote
Old 11-03-2009, 03:15 AM   #4
&TH of undefined behavior
 
Fordy's Avatar
 
Join Date: Aug 2001
Posts: 5,218
If you just want it to open in the app that the user has installed for that file type (Winamp, Windows Media Player, etc) try ShellExecute

Cprogramming.com FAQ > Run a program from within a program
__________________
"If A is success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
Albert Einstein (1879 - 1955)


Board Rules
Fordy is offline   Reply With Quote
Old 11-04-2009, 09:01 PM   #5
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,450
simplest way is with PlaySound() from Winmm.lib


Code:
char szFullPath[MAX_PATH]="c://sounds//somesound.wav";

PlaySound(szFullPath, NULL, SND_FILENAME);
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Structure Eror prominababy C Programming 3 01-06-2009 09:35 AM
Can we have vector of vector? ketu1 C++ Programming 24 01-03-2008 05:02 AM
gcc link external library spank C Programming 6 08-08-2007 03:44 PM
fopen(); GanglyLamb C Programming 8 11-03-2002 12:39 PM
My program, anyhelp @licomb C Programming 14 08-14-2001 10:04 PM


All times are GMT -6. The time now is 08:04 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22