AVFoundation How to loop an audio for a specific duration?

236 Views Asked by At

I want to loop a specific audio for a given duration.

For example;

10 sec. audio file. intended loop duration: 7 min.

During this loop, I have to observe the remaining time of total of the loop iterations.

I tried the AVQueuePlayer and AVAudioLooper, but there is no elegant option to track the total duration/time of the loop iterations.

I am open to new ideas.

1

There are 1 best solutions below

3
udbhateja On

Try using AVAudioPlayer. AVAudioPlayer have property named numberOfLoops for looping.

audioPlayer.numberOfLoops = 5