All Projects → soffes → Samsoundeffect

soffes / Samsoundeffect

Licence: mit
Play a sound effect

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];
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].