我已经尝试了这里提供的所有不同选项,甚至使用NSData来加载音频文件。我尝试了mp3,m4a和caf文件,但什么都没有有效果。
没有错误消息,没有任何提示。
这是一个使用XCODE 5,iOS7的新应用程序。
这是我正在使用的内容。
没有错误消息,没有任何提示。
这是一个使用XCODE 5,iOS7的新应用程序。
这是我正在使用的内容。
- (void)playOnce:(NSString *)aSound
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
[audioSession setActive:YES error:nil];
// Gets the file system path to the sound to play.
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:aSound ofType:@"m4a"];
// Converts the sound's file path to an NSURL object
NSURL *soundURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer * newAudio=[[AVAudioPlayer alloc] initWithContentsOfURL: soundURL error:nil];
[newAudio prepareToPlay];
// set it up and play
[newAudio setNumberOfLoops:0];
[newAudio setVolume: 1];
[newAudio setDelegate: self];
[newAudio play];
}
非常感谢您的帮助。我已经被这些问题困扰很久了。
提前感谢您的帮助。