I've looked at the "Playing A Short Sound" tutorial many times, making sure all my code is correct. My code compiles, but I hear no sound. I think something may have changed with the new SDK..
anyways, here is my code, please help.
MainView.H
Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@class SoundEffect;
@interface MainView : UIView {
IBOutlet UIImageView *thunderImage;
SoundEffect *soundEffect;
}
@end
MainView.M
Code:
#import "MainView.h"
#import "SoundEffect.h"
@implementation MainView
-(void) awakeFromNib {
NSBundle *mainBundle = [NSBundle mainBundle];
soundEffect = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"cat" ofType:@"wav"]];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[soundEffect play];
}
SoundEffect.H
Code:
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
@interface SoundEffect : NSObject {
SystemSoundID soundID;
}
- (id) initWithContentsOfFile:(NSString *)path;
-(void)play;
@end
SoundEffect.M
Code:
#import "SoundEffect.h"
@implementation SoundEffect
- (id) initWithContentsOfFile:(NSString *)path;
{
self = [super init];
if (self != nil) {
NSURL *filePath = [NSURL fileURLWithPath: path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
}
return self;
}
-(void)play {
AudioServicesPlaySystemSound(soundID);
}
@end
Any help would be greatly appreciated. Thank you