How to repeat AVAudioPlayer?

I am just wondering how you repeat AVAudioPlayer?

+44
iphone ios4
Jul 24 2018-11-11T00:
source share
3 answers

Set the PropertyOfLoops parameter to -1 and it will go into an infinite loop.

+132
Jul 24 '11 at 9:17
source share

You mean "How to set AVAudioPlayer to repeat the sound?" I guess?

if so:

Note that the AVAudioPlayer class has a numberOfLoops property. If you set this property to a negative integer value when you play AVAudioPlayer , it will loop until it stops. You can set the number of loops you want to play by making numberOfLoops positive integer.

Hope this helps!

+12
Jul 24 2018-11-11T00:
source share

From iOS docs:

numberOfLoops

The number of times the sound returns to the beginning, after to the end, to repeat playback.

@property NSInteger numberOfLoops Discussion A value of 0, which is the default, means that the sound plays once. Set a positive integer value to indicate the number of times to return to the beginning and play again. For example, when setting a value of 1 it turns out a total of two sound plays. Set any negative integer value to encode the sound indefinitely until you name the stop method .

Availability Available in iOS 2.2 and later. Announced in AVAudioPlayer.h

+9
Jun 24 '12 at 12:11
source share



All Articles