/* * ATMSoundFX.m * ATMHud * * Created by Marcel Müller on 2011-03-01. * Copyright (c) 2010-2011, Marcel Müller (atomcraft) * All rights reserved. * * https://github.com/atomton/ATMHud */ #import "ATMSoundFX.h" @implementation ATMSoundFX + (id)soundEffectWithContentsOfFile:(NSString *)aPath { if (aPath) { return [[ATMSoundFX alloc] initWithContentsOfFile:aPath]; } return nil; } - (id)initWithContentsOfFile:(NSString *)path { self = [super init]; if (self != nil) { NSURL *aFileURL = [NSURL fileURLWithPath:path isDirectory:NO]; if (aFileURL != nil) { SystemSoundID aSoundID; OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)aFileURL, &aSoundID); if (error == kAudioServicesNoError) { _soundID = aSoundID; } else { self = nil; } } else { self = nil; } } return self; } -(void)dealloc { AudioServicesDisposeSystemSoundID(_soundID); // [super dealloc]; } -(void)play { AudioServicesPlaySystemSound(_soundID); } @end