• Stars
    star
    581
  • Rank 76,875 (Top 2 %)
  • Language
    Objective-C
  • License
    Other
  • Created almost 11 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fancy Obj-C wrapper for Cocoa System Sound Services

JSQSystemSoundPlayer

Build Status Version Status license MIT codecov Platform Carthage compatible

A fancy Obj-C wrapper for Cocoa System Sound Services, for iOS and OS X.

About

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.

screenshot ios ย ย ย  screenshot osx

Usage

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...");
                         }];

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
  • Works with Swift!

Requirements

  • Xcode 9+
  • iOS 9.0+
  • tvOS 9.0+
  • macOS 10.10+

Installation

CocoaPods (recommended)

pod 'JSQSystemSoundPlayer'

Carthage

github "jessesquires/JSQSystemSoundPlayer"

Documentation

Read the docs. Generated with jazzy. Hosted by GitHub Pages.

Generate

$ ./build_docs.sh

Preview

$ open index.html -a Safari

Contributing

Interested in making contributions to this project? Please review the guides below.

Also, consider sponsoring this project or buying my apps! โœŒ๏ธ

Credits

Created and maintained by @jesse_squires.

License

JSQSystemSoundPlayer is released under an MIT License. See LICENSE for details.

Copyright ยฉ 2013-present Jesse Squires.

Please provide attribution, it is greatly appreciated.

More Repositories

1

JSQMessagesViewController

An elegant messages UI library for iOS
Objective-C
11,142
star
2

JSQDataSourcesKit

โš ๏ธ Deprecated โš ๏ธ
Swift
683
star
3

JSQCoreDataKit

A swifter Core Data stack
Swift
615
star
4

PresenterKit

โš ๏ธ Deprecated โš ๏ธ
Swift
551
star
5

Foil

A lightweight property wrapper for UserDefaults done right
Swift
457
star
6

JSQWebViewController

[Deprecated] A lightweight Swift WebKit view controller for iOS
Swift
305
star
7

TIL

Things I've learned and/or things I want to remember. Notes, links, advice, example code, etc.
282
star
8

JSQNotificationObserverKit

[DEPRECATED] Generic notifications and observers for Cocoa and CocoaTouch
Swift
167
star
9

Nine41

Automate overriding the status bars for all running iOS simulators
Swift
160
star
10

JSQFlatButton

[DEPRECATED] A light-weight, flat design UIButton for iOS
Objective-C
120
star
11

DefaultStringConvertible

[DEPRECATED] A default CustomStringConvertible implementation for Swift types
Swift
119
star
12

swift-sorts

A collection of sorting algorithms implemented in Swift
Swift
106
star
13

esoteric-swift

A collection of obscure Swift programs. The less comprehensible, the better โ€” just like normal code.
Swift
96
star
14

app-icons-script

Photoshop script to generate all iOS and macOS app icons
JavaScript
84
star
15

ReactiveCollectionsKit

Data-driven, declarative, reactive, diffable collections (and lists!) for iOS. A modern, fast, and flexible library for UICollectionView done right.
Swift
81
star
16

swift-proposal-analyzer

An analysis of Swift Evolution proposals
Swift
58
star
17

objc-sorts

A collection of sorting algorithms implemented in Objective-C
Objective-C
52
star
18

gh-workflows

A collection of useful generic GitHub Actions workflows
50
star
19

safari-tabs-to-omnifocus

AppleScript to export current Safari tabs to OmniFocus inbox items
49
star
20

jessesquires.com

Turing complete with a stack of 0xdeadbeef
HTML
45
star
21

JSQActivityKit

[DEPRECATED] Swift UIActivities for iOS
Swift
43
star
22

delete-uber

"There is no place for ethics in this business sweetheart." โ€” a list of news articles (with excerpts) on Uber.
33
star
23

.github

Default community health files for all of my open-source projects
29
star
24

GrandSugarDispatch

[DEPRECATED] Syntactic sugar for Grand Central Dispatch (GCD)
Swift
27
star
25

ios-watchdog

Main thread watchdog for iOS
Objective-C
26
star
26

talks

Slides and materials for talks that I've given
Rich Text Format
25
star
27

template-iOS-macOS

Template repository for my iOS and macOS projects
Ruby
24
star
28

xcode-settings-backup

Backup of my Xcode configuration and various settings
Shell
21
star
29

icloud-backup-script

Backup your iCloud Drive documents using rsync
Shell
20
star
30

wwdc-notes

Taking notes on WWDC videos, new APIs, and announcements
13
star
31

drumpf

Safari Extensions are dead ๐Ÿ’€ RIP.
JavaScript
10
star
32

playdate-learning

Learning how to make games for Playdate https://play.date
8
star
33

template-jekyll-site

Template repository for Jekyll websites
HTML
8
star
34

c-sorts

A collection of sorting algorithms implemented in C
C
8
star
35

FreedomFarts

Join the Fart Party! In God, We Fart.
Objective-C
5
star
36

rdar-19368054

Example project showing Swift compiler bug, rdar://19368054
Swift
2
star
37

likeyoungrecords

Website for Like Young Records. RIP.
PHP
2
star
38

a-world-without-police

A world without police
2
star
39

15puzzle.js

A 15 puzzle written in javascript - just a fun coding exercise
JavaScript
1
star
40

jessesquires.github.io

Open source projects homepage
1
star
41

sandbox-gh-workflows

A sandbox repo for testing GitHub Actions workflows
Ruby
1
star