You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Usage
JSQSystemSoundPlayer *sharedPlayer = [JSQSystemSoundPlayer sharedPlayer];
// Play a built-in sound
[sharedPlayer playSoundWithSoundID:1000// new mail soundasAlert:YEScompletion:^{
NSLog(@"Sound finished playing. Executing completion block...");
}];
// Play a sound from a file
[sharedPlayer playSoundWithFilename:@"Basso"fileExtension:kJSQSystemSoundTypeAIFcompletion:^{
NSLog(@"Sound finished playing. Executing completion block...");
}];
Features
Play sound effects and alert sounds with a single line of code
"Play" vibration (if available on device)
Block-based completion handlers
Integration with NSUserDefaults to globally toggle sound effects in your app
Efficient memory management
Caches sounds (SystemSoundID instances) and purges on memory warning