yannxou / SAMSoundEffect

Play a sound effect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SAMSoundEffect

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];

About

Play a sound effect

License:MIT License