How do I repeat a AVAudioPlayer?

IphoneIos4

Iphone Problem Overview


I am just wondering how you repeat a AVAudioPlayer?

Iphone Solutions


Solution 1 - Iphone

Set the Property numberOfLoops to -1 and it would go into infinite loop.

Solution 2 - Iphone

Do you mean 'How do I set an AVAudioPlayer to repeat a sound?' I assume?

if so:

Notice that AVAudioPlayer class has a property called numberOfLoops. If you set this property to a negative integer value, when you play the AVAudioPlayer, it will loop until stopped. You can set the number of loops you'd like to play by making numberOfLoops a positive integer.

Hope that helps!

Solution 3 - Iphone

From the iOS docs:

> numberOfLoops > > The number of times a sound will return to the beginning, upon > reaching the end, to repeat playback. > > @property NSInteger numberOfLoops Discussion A value of 0, which is > the default, means to play the sound once. Set a positive integer > value to specify the number of times to return to the start and play > again. For example, specifying a value of 1 results in a total of two > plays of the sound. Set any negative integer value to loop the sound > indefinitely until you call the stop method. > > Availability Available in iOS 2.2 and later. Declared In > AVAudioPlayer.h

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSeb OHView Question on Stackoverflow
Solution 1 - Iphonemrugen munshiView Answer on Stackoverflow
Solution 2 - IphoneGoinAumView Answer on Stackoverflow
Solution 3 - IphoneSK9View Answer on Stackoverflow