-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBDGSoundEffect.m
More file actions
41 lines (35 loc) · 934 Bytes
/
BDGSoundEffect.m
File metadata and controls
41 lines (35 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// BDGSoundEffect.m
//
// Created by Bob de Graaf on 20-06-14.
// Copyright 2014 GraafICT. All rights reserved.
//
#import "BDGSoundEffect.h"
@implementation BDGSoundEffect
-(id)initWithSoundNamed:(NSString *)filename
{
self = [super init];
if(self) {
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:filename withExtension:nil];
if(fileURL != nil) {
SystemSoundID theSoundID;
OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL, &theSoundID);
if(error == kAudioServicesNoError) {
soundID = theSoundID;
}
else {
NSLog(@"BDGSoundPlayer: Error creating systemSoundID for filename: %@", filename);
}
}
}
return self;
}
-(void)dealloc
{
AudioServicesDisposeSystemSoundID(soundID);
}
-(void)play
{
AudioServicesPlaySystemSound(soundID);
}
@end