There are different ways for playing sound on the Mac in Objective C.
Let’s look at some of the methods..
1. Play by filename.
NSSound *mySound = [NSSound soundNamed:@"sound"];
if you have no file named “sound” in your application’s main bundle, then it will return nil.
2. Play by pathName
sound = [[NSSound alloc] initWithContentsOfFile:@"/Volumes/Audio/sound.aiff" byReference:YES];
3. Play by URL
NSURL *soundURL = [NSURL fileURLWithString:@"file://~/soundfiles/sound.aiff"]; NSSound *sound = [[NSSound alloc] initWithContentsOfURL:soundURL
Then to play the sound add
if (![sound isPlaying]) [sound play];
To pause the sound
To stop the sound.
To resume the sound
Please leave your valuable comments if this post was useful…..