开发者

How to make my music loop (repeat) [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

repeat playing automatically

How can I loop a sound (my background mus开发者_开发技巧ic)

here is my code:

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

How can I make it ongoing and if I loop it will it still be playing in the next (or another) view?


Try the AVAudioPlayer and set the numberOfLoops property to -1 (infinite).


Setting numberOfLoops to a negative value will cause the player to loop until you call stop:

AVAudioPlayer Class Reference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜