title: Play Audio iOS Objective-C
body: <p>I'm trying to get an audio file playing in my iOS app. This is my current code</p>
  
  <pre><code>NSString *soundFilePath = [NSString stringWithFormat:@"%@/test.m4a", [[NSBundle mainBundle] resourcePath]];
  
  NSLog(@"%@",soundFilePath);
  NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
  
  audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
  [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
  [[AVAudioSession sharedInstance] setActive: YES error: nil];
  [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
  
  [audioPlayer setVolume:1.0];
  
  audioPlayer.delegate = self;
  
  [audioPlayer stop];
  [audioPlayer setCurrentTime:0];
  [audioPlayer play];
  </code></pre>
  
  <p>I've being checking a bunch of other posts but they all generally do the same thing. I'm not getting an error, but I don't hear any audio playing on the simulator or device.</p>
  
  <p>This is the path I get for the audio file on the simulator</p>
  
  <pre><code>/Users/username/Library/Application Support/iPhone Simulator/5.1/Applications/long-numbered-thing/BookAdventure.app/test.m4a
  </code></pre>
  
  <p>Any help is appreciated! </p>