PDA

View Full Version : Simple Sound Clip Implementation Help




sclaxplayer
Apr 2, 2009, 12:30 PM
I recently have been experimenting with the use of sounds in my programming and I have been using the AVFoundation Library. I have it right now in a way that I implemented my own MainView class and when a button is pushed it would call the function PushButtton. Here is my entire MainView.m implementation. and the audio clip is named Foreward.m4a

#import "AVFoundation/AVAudioPlayer.h"

@implementation MainView
- (IBAction)PushButton {

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"Foreward" ofType: @"m4a"];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundFilePath] error: nil];
newPlayer.delegate = self;
[newPlayer play];

}

I can't get this Foreward.m4a to play. When i run this my iPhone sim to freeze up and terminates due to an uncaught exception. Any suggestions?