GithubHelp home page GithubHelp logo

ozzie00 / jsqsystemsoundplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jessesquires/jsqsystemsoundplayer

0.0 3.0 0.0 972 KB

A fancy Obj-C wrapper for iOS System Sound Services

Home Page: http://cocoadocs.org/docsets/JSQSystemSoundPlayer

License: Other

jsqsystemsoundplayer's Introduction

JSQSystemSoundPlayer

Build Status Version Status license MIT

A fancy Obj-C wrapper for iOS System Sound Services.

This class is a light-weight, drop-in component to play sound effects, or other short sounds in your iOS app. To determine your audio needs, see Best Practices for iOS Audio. Or, read the tl;dr version:

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 control is not for you! See AVAudioPlayer, instead.

JSQSystemSoundPlayer Screenshot

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
  • Sweet and efficient memory management
  • Caches sounds (SystemSoundID objects) and purges on memory warning

Requirements

  • iOS 6.0+
  • ARC

Installation

pod 'JSQSystemSoundPlayer'

Otherwise, drag the JSQSystemSoundPlayer/ folder to your project, and add AudioToolbox.framework.

Getting Started

[[JSQSystemSoundPlayer sharedPlayer] playSoundWithName:@"mySoundFile"
                                             extension:kJSQSystemSoundTypeAIF
                                            completion:^{
                                                // completion block code
                                            }];

And that's all!

String constants for file extensions provided for you:

  • kJSQSystemSoundTypeCAF
  • kJSQSystemSoundTypeAIF
  • kJSQSystemSoundTypeAIFF
  • kJSQSystemSoundTypeWAV

Need a setting in your app's preferences to toggle sound effects on/off? JSQSystemSoundPlayer can do that, too! There's no need to ever check the saved settings ([JSQSystemSoundPlayer sharedPlayer].on) before you play a sound effect. Just play a sound like in the example above. JSQSystemSoundPlayer respects whatever setting has been previously saved.

[[JSQSystemSoundPlayer sharedPlayer] toggleSoundPlayerOn:YES];

Also see the included demo project: SoundPlayerDemo.xcodeproj

For a good time:

while (1) {
    [[JSQSystemSoundPlayer sharedPlayer] playVibrateSound];
}

Documentation

Read the fucking docs, available here via @CocoaDocs.

Contribute

Please follow these sweet contribution guidelines.

Donate

Support the development of this free, open-source library!

Donations made via Square Cash

Send $1 Just saying thanks!

Send $5 This control is great!

Send $10 This totally saved me time!

Credits

Created by @jesse_squires, a programming-motherfucker.

Many thanks to the contributors of this project.

Apps using this library

License

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

Copyright © 2013 Jesse Squires.

Please provide attribution, it is greatly appreciated.

jsqsystemsoundplayer's People

Contributors

bitdeli-chef avatar jessesquires avatar

Watchers

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