Skip to content

Commit e8c4c76

Browse files
committed
reduce public API. remove methods without completion blocks. fix warnings. bump version numbers.
1 parent 3d51873 commit e8c4c76

File tree

8 files changed

+27
-63
lines changed

8 files changed

+27
-63
lines changed

Example/Example-OSX/AppDelegate.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ - (IBAction)playSystemSoundPressed:(NSButton *)sender
4747
- (IBAction)playAlertSoundPressed:(NSButton *)sender
4848
{
4949
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:@"Funk"
50-
fileExtension:kJSQSystemSoundTypeAIFF];
50+
fileExtension:kJSQSystemSoundTypeAIFF
51+
completion:nil];
5152
}
5253

5354
- (IBAction)playLongSoundPressed:(NSButton *)sender

Example/Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@
555555
);
556556
INFOPLIST_FILE = "Example-OSX/Info.plist";
557557
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
558-
MACOSX_DEPLOYMENT_TARGET = 10.7;
558+
MACOSX_DEPLOYMENT_TARGET = 10.8;
559559
PRODUCT_NAME = "$(TARGET_NAME)";
560560
SDKROOT = macosx;
561561
};
@@ -569,7 +569,7 @@
569569
COMBINE_HIDPI_IMAGES = YES;
570570
INFOPLIST_FILE = "Example-OSX/Info.plist";
571571
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
572-
MACOSX_DEPLOYMENT_TARGET = 10.7;
572+
MACOSX_DEPLOYMENT_TARGET = 10.8;
573573
PRODUCT_NAME = "$(TARGET_NAME)";
574574
SDKROOT = macosx;
575575
};

Example/Example/ViewController.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ @implementation ViewController
2828
- (void)viewDidLoad
2929
{
3030
[super viewDidLoad];
31-
31+
3232
self.soundSwitch.on = [JSQSystemSoundPlayer sharedPlayer].on;
3333
}
3434

@@ -37,7 +37,7 @@ - (void)viewDidLoad
3737
- (IBAction)playSystemSoundPressed:(UIButton *)sender
3838
{
3939
JSQSystemSoundPlayer *sharedPlayer = [JSQSystemSoundPlayer sharedPlayer];
40-
40+
4141
[sharedPlayer playSoundWithFilename:@"Basso"
4242
fileExtension:kJSQSystemSoundTypeAIF
4343
completion:^{
@@ -48,7 +48,8 @@ - (IBAction)playSystemSoundPressed:(UIButton *)sender
4848
- (IBAction)playAlertSoundPressed:(UIButton *)sender
4949
{
5050
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:@"Funk"
51-
fileExtension:kJSQSystemSoundTypeAIFF];
51+
fileExtension:kJSQSystemSoundTypeAIFF
52+
completion:nil];
5253
}
5354

5455
- (IBAction)playVibratePressed:(UIButton *)sender
@@ -69,7 +70,7 @@ - (IBAction)playLongSoundPressed:(UIButton *)sender
6970
- (IBAction)stopPressed:(UIButton *)sender
7071
{
7172
[[JSQSystemSoundPlayer sharedPlayer] stopAllSounds];
72-
73+
7374
// Stop playing specific sound
7475
// [[JSQSystemSoundPlayer sharedPlayer] stopSoundWithFilename:@"BalladPiano"];
7576
}

JSQSystemSoundPlayer.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'JSQSystemSoundPlayer'
3-
s.version = '3.0.0'
3+
s.version = '4.0.0'
44
s.license = 'MIT'
55

66
s.summary = 'A fancy Obj-C wrapper for Cocoa System Sound Services'

JSQSystemSoundPlayer/JSQSystemSoundPlayer/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.0.0</string>
18+
<string>4.0.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

JSQSystemSoundPlayer/JSQSystemSoundPlayer/JSQSystemSoundPlayer.h

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,6 @@ typedef void(^JSQSystemSoundPlayerCompletionBlock)(void);
9090
*/
9191
- (void)toggleSoundPlayerOn:(BOOL)on;
9292

93-
/**
94-
* Plays a system sound object corresponding to an audio file with the given filename and extension.
95-
* The system sound player will lazily initialize and load the file before playing it, and then cache its corresponding `SystemSoundID`.
96-
* If this file has previously been played, it will be loaded from cache and played immediately.
97-
*
98-
* @param filename A string containing the base name of the audio file to play.
99-
* @param fileExtension A string containing the extension of the audio file to play.
100-
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
101-
*
102-
* @warning If the system sound object cannot be created, this method does nothing.
103-
*/
104-
- (void)playSoundWithFilename:(NSString *)filename fileExtension:(NSString *)fileExtension;
105-
10693
/**
10794
* Plays a system sound object corresponding to an audio file with the given filename and extension,
10895
* and excutes completionBlock when the sound has stopped playing.
@@ -114,30 +101,14 @@ typedef void(^JSQSystemSoundPlayerCompletionBlock)(void);
114101
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
115102
*
116103
* @param completionBlock A block called after the sound has stopped playing.
117-
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution.
104+
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution. This value may be `nil`.
118105
*
119106
* @warning If the system sound object cannot be created, this method does nothing.
120107
*/
121108
- (void)playSoundWithFilename:(NSString *)filename
122109
fileExtension:(NSString *)fileExtension
123110
completion:(JSQSystemSoundPlayerCompletionBlock)completionBlock;
124111

125-
/**
126-
* Plays a system sound object *as an alert* corresponding to an audio file with the given filename and extension.
127-
* The system sound player will lazily initialize and load the file before playing it, and then cache its corresponding `SystemSoundID`.
128-
* If this file has previously been played, it will be loaded from cache and played immediately.
129-
*
130-
* @param filename A string containing the base name of the audio file to play.
131-
* @param fileExtension A string containing the extension of the audio file to play.
132-
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
133-
*
134-
* @warning If the system sound object cannot be created, this method does nothing.
135-
*
136-
* @warning This method performs the same functions as `playSoundWithName: extension:`, with the excepion that,
137-
* depending on the particular iOS device, this method may invoke vibration.
138-
*/
139-
- (void)playAlertSoundWithFilename:(NSString *)filename fileExtension:(NSString *)fileExtension;
140-
141112
/**
142113
* Plays a system sound object *as an alert* corresponding to an audio file with the given filename and extension,
143114
* and and excutes completionBlock when the sound has stopped playing.
@@ -149,7 +120,7 @@ typedef void(^JSQSystemSoundPlayerCompletionBlock)(void);
149120
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
150121
*
151122
* @param completionBlock A block called after the sound has stopped playing.
152-
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution.
123+
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution. This value may be `nil`.
153124
*
154125
* @warning If the system sound object cannot be created, this method does nothing.
155126
*

JSQSystemSoundPlayer/JSQSystemSoundPlayer/JSQSystemSoundPlayer.m

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ - (void)playSoundWithName:(NSString *)filename
149149
{
150150
NSParameterAssert(filename != nil);
151151
NSParameterAssert(extension != nil);
152-
152+
153153
if (!self.on) {
154154
return;
155155
}
@@ -211,13 +211,6 @@ - (void)toggleSoundPlayerOn:(BOOL)on
211211
}
212212
}
213213

214-
- (void)playSoundWithFilename:(NSString *)filename fileExtension:(NSString *)extension
215-
{
216-
[self playSoundWithFilename:filename
217-
fileExtension:extension
218-
completion:nil];
219-
}
220-
221214
- (void)playSoundWithFilename:(NSString *)filename
222215
fileExtension:(NSString *)extension
223216
completion:(JSQSystemSoundPlayerCompletionBlock)completionBlock
@@ -238,13 +231,6 @@ - (void)playAlertSoundWithFilename:(NSString *)filename
238231
completionBlock:completionBlock];
239232
}
240233

241-
- (void)playAlertSoundWithFilename:(NSString *)filename fileExtension:(NSString *)extension
242-
{
243-
[self playAlertSoundWithFilename:filename
244-
fileExtension:extension
245-
completion:nil];
246-
}
247-
248234
#if TARGET_OS_IPHONE
249235
- (void)playVibrateSound
250236
{

JSQSystemSoundPlayer/JSQSystemSoundPlayerTests/JSQSystemSoundPlayerTests.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ - (void)testPlayingSounds
165165
@"Player should play sound and not throw");
166166

167167
XCTAssertNoThrow([self.sharedPlayer playSoundWithFilename:kSoundFunk
168-
fileExtension:kJSQSystemSoundTypeAIFF],
168+
fileExtension:kJSQSystemSoundTypeAIFF
169+
completion:nil],
169170
@"Player should play sound and not throw");
170171

171172
XCTAssertNoThrow([self.sharedPlayer playAlertSoundWithFilename:kSoundBasso
172-
fileExtension:kJSQSystemSoundTypeAIF],
173+
fileExtension:kJSQSystemSoundTypeAIF
174+
completion:nil],
173175
@"Player should play alert and not throw");
174176

175177
XCTAssertNoThrow([self.sharedPlayer playAlertSoundWithFilename:kSoundFunk
@@ -178,20 +180,22 @@ - (void)testPlayingSounds
178180
@"Player should play alert and not throw with nil block");
179181

180182
XCTAssertThrows([self.sharedPlayer playAlertSoundWithFilename:nil
181-
fileExtension:nil],
182-
@"Player should throw on nil params");
183+
fileExtension:nil
184+
completion:nil],
185+
@"Player should throw on nil params");
183186

184187
XCTAssertNoThrow([self.sharedPlayer playAlertSoundWithFilename:kSoundBalladPiano
185-
fileExtension:kJSQSystemSoundTypeAIFF],
188+
fileExtension:kJSQSystemSoundTypeAIFF
189+
completion:nil],
186190
@"Player should fail gracefully and not throw on incorrect extension");
187191

188192
XCTAssertNoThrow([self.sharedPlayer playVibrateSound], @"Player should vibrate and not throw");
189193
}
190194

191195
- (void)testStoppingSounds
192196
{
193-
[self.sharedPlayer playSoundWithFilename:kSoundBasso fileExtension:kJSQSystemSoundTypeAIF];
194-
[self.sharedPlayer playSoundWithFilename:kSoundBalladPiano fileExtension:kJSQSystemSoundTypeCAF];
197+
[self.sharedPlayer playSoundWithFilename:kSoundBasso fileExtension:kJSQSystemSoundTypeAIF completion:nil];
198+
[self.sharedPlayer playSoundWithFilename:kSoundBalladPiano fileExtension:kJSQSystemSoundTypeCAF completion:nil];
195199

196200
XCTAssertTrue([self.sharedPlayer.sounds count] == 2, @"Player should have 2 sounds cached");
197201

@@ -222,7 +226,8 @@ - (void)testMemoryWarning
222226
XCTAssertTrue([self.sharedPlayer.completionBlocks count] == 1, @"Completion blocks dictionary should contain 1 object");
223227

224228
[self.sharedPlayer playAlertSoundWithFilename:kSoundFunk
225-
fileExtension:kJSQSystemSoundTypeAIFF];
229+
fileExtension:kJSQSystemSoundTypeAIFF
230+
completion:nil];
226231

227232
XCTAssertTrue([self.sharedPlayer.sounds count] == 2, @"Sounds dictionary should contain 2 objects");
228233

0 commit comments

Comments
 (0)