我有一个音频播放器,它不播放声音,有人知道为什么? 我已导入AVFoundation Framework.h
这是代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"begin" ofType:@"mp3"]];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[audioPlayer play];
audioPlayer.numberOfLoops=-1;
}
答案 0 :(得分:0)
添加委托:
[audioPlayer setDelegate:self];
并确保您的音量设置正确。