Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

guyddor

macrumors member
Original poster
Jan 7, 2009
32
0
Hi,

I need to right code to play a short sound.
I have been already added the AudioToolBox framework to my project and a short sound audio file.
 

Kingbombs

macrumors member
Jun 24, 2009
98
0
Look at the apple doc's
Then make an attempt at trying to do it yourself, and use google when you get errors
then when you are stuck post on here what you have tried.
You will learn it 100 times quicker and better that way (rather than pasting in code that you don't understand)
 

Rynnakat

macrumors newbie
Aug 24, 2009
1
0
I am having the same problem. I have been watching tutorials online. Can anyone see an issue with this code?
Code:
- (IBAction)Playsound:(id)sender
{
	CFBundleRef mainBundle = CFBundleGetMainBundle();
	CFURLRef soundFileURLRef;
	soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound", CFSTR("mp3"), NULL);
	if (soundFileURLRef) {
		CFStringRef url = CFURLGetString(soundFileURLRef);
	}
	UInt32 soundID;
	AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
	AudioServicesPlaySystemSound(soundID);

Luv,
Miss Kat
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.