-1

我有一个音频播放器,它不会播放声音,有人知道为什么吗?我已经导入了 AVFoundationFramework.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;
}
4

1 回答 1

0

添加委托:

 [audioPlayer setDelegate:self];

并确保您的音量设置正确。

于 2013-01-16T22:32:04.490 回答