Hey guys,
How would you play any type of music in objective-c (not iphone sdk), and how would you stop the music?
Thanks, Kevin
Hey guys,
How would you play any type of music in objective-c (not iphone sdk), and how would you stop the music?
Thanks, Kevin
Hi Kevin!
Here is some sample code that shows you how to play a sound file in Mac OS X (10.5+).
It uses the AudioQueue API.
Take a look at the aqplay code.
-(void) playAlarmSound
{
// Get the filename of the sound file
NSString *path = [NSString stringWithFormat:@"%@%@",
[[NSBundle mainBundle] resourcePath],
@"/alarm.wav"];
// Declare a sound id
SystemSoundID soundID;
// get a URL for the sound file
NSURL *filepath = [NSURL fileURLWithPath:path isDirectory:NO];
// Use audio services to create sound
AudioServicesCreateSystemSoundID((CFURLRef) filepath, &soundID);
// Use audio services to play the sound
AudioServicesPlaySystemSound(soundID);
}