Created
September 9, 2010 23:18
-
-
Save nummi/572762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) playSound:(NSString *)fileName { | |
NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"aif"]; | |
NSError* err; | |
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:filePath] error:&err]; | |
player.delegate = self; | |
[player play]; | |
} | |
-(void) playCricket { [self playSound:@"cricket"]; } | |
-(void) playTrombone { [self playSound:@"trombone"]; } | |
-(void) playRimshot { [self playSound:@"rimshot"]; } | |
#pragma mark - | |
#pragma mark AVAudioPlayer Delegate Methods | |
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)aplayer successfully:(BOOL)flag { | |
// Considered sloppy. Would cause issues with GC. | |
// Create mutable array of players and pop off from this delegate method? | |
[aplayer release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment