Code Monkey home page Code Monkey logo

jsqsystemsoundplayer's Introduction

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'
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.

jsqsystemsoundplayer's People

Contributors

asmallteapot avatar bitdeli-chef avatar jessesquires avatar rodionovd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.