Monday, 18 April 2011

Play a sound with AudioToolbox framework

The following Code is from Dr.David Fisher from Rose Hulman College. He has iOS video Lectures on itunes. Great great Lectures!

//Create a System sound struct soundID
//Get a path to our sound resource
//Connect the system sound ID to that resource
//Play the sound!


SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound file name" ofType:@"soundfiletype"];
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
    AudioServicesPlaySystemSound (soundID);

No comments:

Post a Comment