I'm using an AVAudioPlayer to manage some sounds but the isPlaying method seems to be crashing.
done when I initiate the page:
self.soundClass = [AVAudioPlayer alloc];
how I play the sound:
-(void)playSound:(NSString *)fileName:(NSString *)fileExt {
if ( [self.soundClass isPlaying] ){
[self.soundClass pause];
}
else if (newSoundFile == currentSoundFile) {
[self.soundClass play];
}
else {
NSLog(@"PlaySound with two variable passed function");
[[NSBundle mainBundle] pathForResource: fileName ofType:fileExt]], &systemSoundID);
[self.soundClass initWithContentsOfURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource: fileName ofType:fileExt]] error:nil];
[self.soundClass prepareToPlay];
[self.soundClass play];
}
self.currentSoundFile = fileName;
}
My soundClass is pretty empty right now:
soundclass.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import<AVFoundation/AVFoundation.h>
@interface SoundClass : AVAudioPlayer <AVAudioPlayerDelegate> {
}
@end
SoundClass.m
#import "SoundClass.h"
@implementation SoundClass
-(void)dealloc {
[super dealloc];
}
@end
Do you see anything here I might be doing wrong? It crashes right at if ( isPlaying )