Skip to content

Instantly share code, notes, and snippets.

@centwave
Created July 6, 2013 13:53
Show Gist options
  • Save centwave/5939953 to your computer and use it in GitHub Desktop.
Save centwave/5939953 to your computer and use it in GitHub Desktop.
play a sound for ios
@interface MyClass:NSObject
{
SystemSoundID mySound;
}
@implementation MyClass
- (void) viewDidLoad {
[super viewDidLoad];
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"changeTrack" ofType:@"aif"];
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &mySound);
}
- (void) playMySoundLikeRightNowReally {
AudioServicesPlaySystemSound(mySound);
}
- (void) dealloc {
AudioServicesDisposeSystemSoundID(mySound);
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment