In #ViewController.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface #ViewController_iPhone : UIViewController
        <AVAudioPlayerDelegate>
{
    AVAudioPlayer *audioPlayer;

Play File


    //---------------------------
    //----- PLAY AUDIO FILE -----
    //---------------------------
    if (audioPlayer)
        [audioPlayer release];

    NSError *error;

    NSString *path;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"MediaFiles"];
    path = [path stringByAppendingPathComponent:@"MyFile.wav"];
    audioPlayer = [[AVAudioPlayer alloc]
                   initWithContentsOfURL:[NSURL URLWithString:path]
                   error:&error];
    audioPlayer.delegate = self;

    if (error)
    {
        NSLog(@"Error: %@",
              [error localizedDescription]);
    }
    else
    {
        [audioPlayer play];
    }
File in your bundle

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                         pathForResource:@"RecordStart"
                                         ofType:@"wav"]];

Stopping Playback


    if (audioPlayer)
    {
        [audioPlayer release];
        audioPlayer = nil;
    }

Callbacks


//********************************************
//********************************************
//********** AUDIO FINISHED PLAYING **********
//********************************************
//********************************************
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player
                      successfully:(BOOL)flag
{
    NSLog(@"Playing Audio Finished");

}

//*****************************************
//*****************************************
//********** AUDIO PLAYING ERROR **********
//*****************************************
//*****************************************
-(void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player
                                error:(NSError *)error
{
    NSLog(@"Playing Audio Decode Error Occurred");

}