How to make my music loop (repeat) [duplicate]
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
精彩评论