Simple Sound Clip Implementation Help

Discussion in 'iOS Programming' started by sclaxplayer, Apr 2, 2009.

  1. macrumors newbie

    Apr 2, 2009
    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?

Share This Page