This should be a simple question, but I just can't seem to figure it out.
I'm trying to create my own class which will provide a simpler way of playing short sounds using the AudioToolbox framework as provided by Apple. When I import these files into my project and attempt to utilize them, they just don't seem to work. I was hoping someone would shed some light on what I may be doing wrong here.
simplesound.h
#import <Foundation/Foundation.h>
@interface simplesound : NSObject {
IBOutlet UILabel *statusLabel;
}
@property(nonatomic, retain) UILabel *statusLabel;
- (void)playSimple:(NSString *)url;
@end
simplesound.m
#import "simplesound.h"
@implementation simplesound
@synthesize statusLabel;
- (void)playSimple:(NSString *)url {
if (url = @"vibrate") {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
statusLabel.text = @"VIBRATED!";
} else {
NSString *paths = [[NSBundle mainBundle] resourcePath];
NSString *audioF1ile = [paths stringByAppendingPathComponent:url];
NSURL *audioURL = [NSURL fileURLWithPath:audioFile isDirectory:NO];
SystemSoundID mySSID;
OSStatus error = AudioServicesCreateSystemSoundID ((CFURLRef)audioURL,&mySSID);
AudioServicesAddSystemSoundCompletion(mySSID,NULL,NULL,simpleSoundDone,NULL);
if (error) {
statusLabel.text = [NSString stringWithFormat:@"Error: %d",error];
} else {
AudioServicesPlaySystemSound(mySSID);
}
}
static void simpleSoundDone (SystemSoundID mySSID, void *args) {
AudioServicesDisposeSystemSoundID (mySSID);
}
}
- (void)dealloc {
[url release];
}
@end
Does anyone see what I'm trying to accomplish here? Does anyone know how to remedy this code that is supposedly wrong?