A fancy Obj-C wrapper for Cocoa System Sound Services, for iOS and OS X.
This library is a light-weight component to play sound effects in your app. To determine your audio needs, see Best Practices for iOS Audio.
tl;dr
When your sole audio need is to play alerts and user-interface sound effects, use Core Audio’s System Sound Services.
Your sound files must be:
- No longer than 30 seconds in duration
- In linear PCM or IMA4 (IMA/ADPCM) format
- Packaged in a
.caf
,.aif
, or.wav
file
If this does not fit your needs, then this library is not for you! See AVAudioPlayer, instead.
JSQSystemSoundPlayer *sharedPlayer = [JSQSystemSoundPlayer sharedPlayer];
// Play a built-in sound
[sharedPlayer playSoundWithSoundID:1000 // new mail sound
asAlert:YES
completion:^{
NSLog(@"Sound finished playing. Executing completion block...");
}];
// Play a sound from a file
[sharedPlayer playSoundWithFilename:@"Basso"
fileExtension:kJSQSystemSoundTypeAIF
completion:^{
NSLog(@"Sound finished playing. Executing completion block...");
}];
NSUserDefaults
to globally toggle sound effects in your appSystemSoundID
instances) and purges on memory warningpod 'JSQSystemSoundPlayer'
github "jessesquires/JSQSystemSoundPlayer"
Read the docs. Generated with jazzy. Hosted by GitHub Pages.
$ ./build_docs.sh
$ open index.html -a Safari
Interested in making contributions to this project? Please review the guides below.
Also, consider sponsoring this project or buying my apps! :v:
Created and maintained by @jesse_squires.
JSQSystemSoundPlayer
is released under an MIT License. See LICENSE
for details.
Copyright © 2013-present Jesse Squires.
Please provide attribution, it is greatly appreciated.