如何让我的音乐循环(重复)

MCK*_*pur 1 objective-c ios

可能重复:
自动重复播放

我怎样才能循环播放声音(我的背景音乐)

这是我的代码:

NSString *path = [[NSBundle mainBundle] pathForResource:@"MathMusic" ofType:@"aif"];
    AVAudioPlayer* theAudio= [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    theAudio.delegate = self;
[theAudio play];
Run Code Online (Sandbox Code Playgroud)

如何让它继续进行,如果我循环它还会在下一个(或另一个)视图中播放?

Ric*_*ell 7

尝试AVAudioPlayer并将numberOfLoops属性设置为-1(无限).