0

嗨我有一个设置,记录音频(与AVAudioSessionCategoryPlayAndRecord类别),现在我想回放和MP3文件像往常一样AVAudioPlayer实例,但没有任何声音可以听到。用PlayAndRecord类别播放AVAudioPlayer的MP3文件?

AVAudioPlayer不会抛出任何错误,也不会在其委托回调中抛出任何错误。

有没有类似的经验?如何克服这一点?

+0

我可以解决OpelAL播放问题,但如果有更高层次的解决方案,我会非常感激。 – Geri

+0

请检查你的音量:) – iEinstein

+0

似乎它没有太多的关于录音会议......别的东西...... – Geri

回答

0

请使用 -

NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
      filePath = [NSString stringWithFormat:@"%@/%@.mp3", docDirPath , @"Welcome"]; 
    NSError *error; 
      NSURL *fileURL = [NSURL fileURLWithPath:filePath]; 
      avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&error]; 

      if (avPlayer == nil) 
      { 
       NSLog(@"AudioPlayer did not load properly: %@", [error description]); 
      } 
      else 
       { 
       [avPlayer play]; 
      avPlayer.delegate=self; 
       } 

并告诉我,如果工作或没有。