3232NSString * const kJSQSystemSoundTypeAIFF = @" aiff" ;
3333NSString * const kJSQSystemSoundTypeWAV = @" wav" ;
3434
35- @interface JSQSystemSoundPlayer ()
36-
37- @property (strong , nonatomic ) NSMutableDictionary *sounds;
38- @property (strong , nonatomic ) NSMutableDictionary *completionBlocks;
39-
40- - (void )playSoundWithName : (NSString *)filename
41- extension : (NSString *)extension
42- isAlert : (BOOL )isAlert
43- completionBlock : (JSQSystemSoundPlayerCompletionBlock)completionBlock ;
4435
45- - (BOOL )readSoundPlayerOnFromUserDefaults ;
46-
47- - (NSData *)dataWithSoundID : (SystemSoundID)soundID ;
48- - (SystemSoundID)soundIDFromData : (NSData *)data ;
36+ @interface JSQSystemSoundPlayer ()
4937
50- - (SystemSoundID)soundIDForFilename : (NSString *)filenameKey ;
51- - (void )addSoundIDForAudioFileWithName : (NSString *)filename
52- extension : (NSString *)extension ;
38+ @property (strong , nonatomic , readonly ) NSMutableDictionary *sounds;
39+ @property (strong , nonatomic , readonly ) NSMutableDictionary *completionBlocks;
5340
5441- (JSQSystemSoundPlayerCompletionBlock)completionBlockForSoundID : (SystemSoundID)soundID ;
55- - (void )addCompletionBlock : (JSQSystemSoundPlayerCompletionBlock)block
56- toSoundID : (SystemSoundID)soundID ;
57- - (void )removeCompletionBlockForSoundID : (SystemSoundID)soundID ;
58-
59- - (SystemSoundID)createSoundIDWithName : (NSString *)filename
60- extension : (NSString *)extension ;
61-
62- - (void )unloadSoundIDs ;
63- - (void )unloadSoundIDForFileNamed : (NSString *)filename ;
64-
65- - (void )logError : (OSStatus)error withMessage : (NSString *)message ;
6642
67- - (void )didReceiveMemoryWarningNotification : ( NSNotification *) notification ;
43+ - (void )removeCompletionBlockForSoundID : (SystemSoundID) soundID ;
6844
6945@end
7046
@@ -134,6 +110,7 @@ - (void)dealloc
134110 _bundle = nil ;
135111}
136112
113+
137114#pragma mark - Setters
138115
139116- (void )setBundle : (NSBundle *)bundle
@@ -142,6 +119,7 @@ - (void)setBundle:(NSBundle *)bundle
142119 _bundle = bundle;
143120}
144121
122+
145123#pragma mark - Playing sounds
146124
147125- (void )playSoundWithName : (NSString *)filename
@@ -198,6 +176,7 @@ - (BOOL)readSoundPlayerOnFromUserDefaults
198176 return [setting boolValue ];
199177}
200178
179+
201180#pragma mark - Public API
202181
203182- (void )toggleSoundPlayerOn : (BOOL )on
@@ -270,6 +249,7 @@ - (void)preloadSoundWithFilename:(NSString *)filename fileExtension:(NSString *)
270249 }
271250}
272251
252+
273253#pragma mark - Sound data
274254
275255- (NSData *)dataWithSoundID : (SystemSoundID)soundID
@@ -288,11 +268,12 @@ - (SystemSoundID)soundIDFromData:(NSData *)data
288268 return soundID;
289269}
290270
271+
291272#pragma mark - Sound files
292273
293274- (SystemSoundID)soundIDForFilename : (NSString *)filenameKey
294275{
295- NSData *soundData = [self .sounds objectForKey: filenameKey];
276+ NSData *soundData = [_sounds objectForKey: filenameKey];
296277 return [self soundIDFromData: soundData];
297278}
298279
@@ -307,6 +288,7 @@ - (void)addSoundIDForAudioFileWithName:(NSString *)filename
307288 }
308289}
309290
291+
310292#pragma mark - Sound completion blocks
311293
312294- (JSQSystemSoundPlayerCompletionBlock)completionBlockForSoundID : (SystemSoundID)soundID
@@ -329,6 +311,7 @@ - (void)removeCompletionBlockForSoundID:(SystemSoundID)soundID
329311 AudioServicesRemoveSystemSoundCompletion (soundID);
330312}
331313
314+
332315#pragma mark - Managing sounds
333316
334317- (SystemSoundID)createSoundIDWithName : (NSString *)filename
@@ -402,6 +385,7 @@ - (void)logError:(OSStatus)error withMessage:(NSString *)message
402385 NSLog (@" [%@ ] %@ Error: (code %d ) %@ " , [self class ], message, (int )error, errorMessage);
403386}
404387
388+
405389#pragma mark - Notifications
406390
407391- (void )didReceiveMemoryWarningNotification : (NSNotification *)notification
0 commit comments