Skip to content

Commit

Permalink
reduce public API. remove methods without completion blocks. fix warn…
Browse files Browse the repository at this point in the history
…ings. bump version numbers.
  • Loading branch information
jessesquires committed May 17, 2015
1 parent 3d51873 commit e8c4c76
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 63 deletions.
3 changes: 2 additions & 1 deletion Example/Example-OSX/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ - (IBAction)playSystemSoundPressed:(NSButton *)sender
- (IBAction)playAlertSoundPressed:(NSButton *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:@"Funk"
fileExtension:kJSQSystemSoundTypeAIFF];
fileExtension:kJSQSystemSoundTypeAIFF
completion:nil];
}

- (IBAction)playLongSoundPressed:(NSButton *)sender
Expand Down
4 changes: 2 additions & 2 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
);
INFOPLIST_FILE = "Example-OSX/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.7;
MACOSX_DEPLOYMENT_TARGET = 10.8;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand All @@ -569,7 +569,7 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Example-OSX/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.7;
MACOSX_DEPLOYMENT_TARGET = 10.8;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand Down
9 changes: 5 additions & 4 deletions Example/Example/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ @implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];

self.soundSwitch.on = [JSQSystemSoundPlayer sharedPlayer].on;
}

Expand All @@ -37,7 +37,7 @@ - (void)viewDidLoad
- (IBAction)playSystemSoundPressed:(UIButton *)sender
{
JSQSystemSoundPlayer *sharedPlayer = [JSQSystemSoundPlayer sharedPlayer];

[sharedPlayer playSoundWithFilename:@"Basso"
fileExtension:kJSQSystemSoundTypeAIF
completion:^{
Expand All @@ -48,7 +48,8 @@ - (IBAction)playSystemSoundPressed:(UIButton *)sender
- (IBAction)playAlertSoundPressed:(UIButton *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:@"Funk"
fileExtension:kJSQSystemSoundTypeAIFF];
fileExtension:kJSQSystemSoundTypeAIFF
completion:nil];
}

- (IBAction)playVibratePressed:(UIButton *)sender
Expand All @@ -69,7 +70,7 @@ - (IBAction)playLongSoundPressed:(UIButton *)sender
- (IBAction)stopPressed:(UIButton *)sender
{
[[JSQSystemSoundPlayer sharedPlayer] stopAllSounds];

// Stop playing specific sound
// [[JSQSystemSoundPlayer sharedPlayer] stopSoundWithFilename:@"BalladPiano"];
}
Expand Down
2 changes: 1 addition & 1 deletion JSQSystemSoundPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'JSQSystemSoundPlayer'
s.version = '3.0.0'
s.version = '4.0.0'
s.license = 'MIT'

s.summary = 'A fancy Obj-C wrapper for Cocoa System Sound Services'
Expand Down
2 changes: 1 addition & 1 deletion JSQSystemSoundPlayer/JSQSystemSoundPlayer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>4.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
33 changes: 2 additions & 31 deletions JSQSystemSoundPlayer/JSQSystemSoundPlayer/JSQSystemSoundPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ typedef void(^JSQSystemSoundPlayerCompletionBlock)(void);
*/
- (void)toggleSoundPlayerOn:(BOOL)on;

/**
* Plays a system sound object corresponding to an audio file with the given filename and extension.
* The system sound player will lazily initialize and load the file before playing it, and then cache its corresponding `SystemSoundID`.
* If this file has previously been played, it will be loaded from cache and played immediately.
*
* @param filename A string containing the base name of the audio file to play.
* @param fileExtension A string containing the extension of the audio file to play.
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
*
* @warning If the system sound object cannot be created, this method does nothing.
*/
- (void)playSoundWithFilename:(NSString *)filename fileExtension:(NSString *)fileExtension;

/**
* Plays a system sound object corresponding to an audio file with the given filename and extension,
* and excutes completionBlock when the sound has stopped playing.
Expand All @@ -114,30 +101,14 @@ typedef void(^JSQSystemSoundPlayerCompletionBlock)(void);
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
*
* @param completionBlock A block called after the sound has stopped playing.
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution.
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution. This value may be `nil`.
*
* @warning If the system sound object cannot be created, this method does nothing.
*/
- (void)playSoundWithFilename:(NSString *)filename
fileExtension:(NSString *)fileExtension
completion:(JSQSystemSoundPlayerCompletionBlock)completionBlock;

/**
* Plays a system sound object *as an alert* corresponding to an audio file with the given filename and extension.
* The system sound player will lazily initialize and load the file before playing it, and then cache its corresponding `SystemSoundID`.
* If this file has previously been played, it will be loaded from cache and played immediately.
*
* @param filename A string containing the base name of the audio file to play.
* @param fileExtension A string containing the extension of the audio file to play.
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
*
* @warning If the system sound object cannot be created, this method does nothing.
*
* @warning This method performs the same functions as `playSoundWithName: extension:`, with the excepion that,
* depending on the particular iOS device, this method may invoke vibration.
*/
- (void)playAlertSoundWithFilename:(NSString *)filename fileExtension:(NSString *)fileExtension;

/**
* Plays a system sound object *as an alert* corresponding to an audio file with the given filename and extension,
* and and excutes completionBlock when the sound has stopped playing.
Expand All @@ -149,7 +120,7 @@ typedef void(^JSQSystemSoundPlayerCompletionBlock)(void);
* This parameter must be one of `kJSQSystemSoundTypeCAF`, `kJSQSystemSoundTypeAIF`, `kJSQSystemSoundTypeAIFF`, or `kJSQSystemSoundTypeWAV`.
*
* @param completionBlock A block called after the sound has stopped playing.
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution.
* This block is retained by `JSQSystemSoundPlayer`, temporarily cached, and released after its execution. This value may be `nil`.
*
* @warning If the system sound object cannot be created, this method does nothing.
*
Expand Down
16 changes: 1 addition & 15 deletions JSQSystemSoundPlayer/JSQSystemSoundPlayer/JSQSystemSoundPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ - (void)playSoundWithName:(NSString *)filename
{
NSParameterAssert(filename != nil);
NSParameterAssert(extension != nil);

if (!self.on) {
return;
}
Expand Down Expand Up @@ -211,13 +211,6 @@ - (void)toggleSoundPlayerOn:(BOOL)on
}
}

- (void)playSoundWithFilename:(NSString *)filename fileExtension:(NSString *)extension
{
[self playSoundWithFilename:filename
fileExtension:extension
completion:nil];
}

- (void)playSoundWithFilename:(NSString *)filename
fileExtension:(NSString *)extension
completion:(JSQSystemSoundPlayerCompletionBlock)completionBlock
Expand All @@ -238,13 +231,6 @@ - (void)playAlertSoundWithFilename:(NSString *)filename
completionBlock:completionBlock];
}

- (void)playAlertSoundWithFilename:(NSString *)filename fileExtension:(NSString *)extension
{
[self playAlertSoundWithFilename:filename
fileExtension:extension
completion:nil];
}

#if TARGET_OS_IPHONE
- (void)playVibrateSound
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ - (void)testPlayingSounds
@"Player should play sound and not throw");

XCTAssertNoThrow([self.sharedPlayer playSoundWithFilename:kSoundFunk
fileExtension:kJSQSystemSoundTypeAIFF],
fileExtension:kJSQSystemSoundTypeAIFF
completion:nil],
@"Player should play sound and not throw");

XCTAssertNoThrow([self.sharedPlayer playAlertSoundWithFilename:kSoundBasso
fileExtension:kJSQSystemSoundTypeAIF],
fileExtension:kJSQSystemSoundTypeAIF
completion:nil],
@"Player should play alert and not throw");

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

XCTAssertThrows([self.sharedPlayer playAlertSoundWithFilename:nil
fileExtension:nil],
@"Player should throw on nil params");
fileExtension:nil
completion:nil],
@"Player should throw on nil params");

XCTAssertNoThrow([self.sharedPlayer playAlertSoundWithFilename:kSoundBalladPiano
fileExtension:kJSQSystemSoundTypeAIFF],
fileExtension:kJSQSystemSoundTypeAIFF
completion:nil],
@"Player should fail gracefully and not throw on incorrect extension");

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

- (void)testStoppingSounds
{
[self.sharedPlayer playSoundWithFilename:kSoundBasso fileExtension:kJSQSystemSoundTypeAIF];
[self.sharedPlayer playSoundWithFilename:kSoundBalladPiano fileExtension:kJSQSystemSoundTypeCAF];
[self.sharedPlayer playSoundWithFilename:kSoundBasso fileExtension:kJSQSystemSoundTypeAIF completion:nil];
[self.sharedPlayer playSoundWithFilename:kSoundBalladPiano fileExtension:kJSQSystemSoundTypeCAF completion:nil];

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

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

[self.sharedPlayer playAlertSoundWithFilename:kSoundFunk
fileExtension:kJSQSystemSoundTypeAIFF];
fileExtension:kJSQSystemSoundTypeAIFF
completion:nil];

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

Expand Down

0 comments on commit e8c4c76

Please sign in to comment.