soffes / SAMSoundEffect

Play a sound effect
MIT License
135 stars 7 forks source link

SAMSoundEffect

Carthage compatible

A simple way to play a sound effect on iOS.

Installation

CocoaPods is recommended. Add the following to your Podfile:

pod 'SAMSoundEffect'

You can also just download and put the the two files in your project. You'll need to add AVFoundation to your target as well.

Usage

Simple as:

[SAMSoundEffect playSoundEffectNamed:@"shutter"];

You can also do:

SAMSoundEffect *sound = [SAMSoundEffect soundEffectNamed:@"shutter"];
[sound play];

You can interrupt it too:

[sound stop];

You'll probably want to add this in your application:didFinishLaunchingWithOptions: so they don't stop audio from other applications.

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];