我有一个音频播放器,但无法播放声音,有人知道为什么吗?
而且我已经导入了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;
}
最佳答案
添加代表:
[audioPlayer setDelegate:self];
并确保正确设置音量。
关于iphone - 无法启动音频播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14361603/