Hi, I am trying to implement outgoing call ringtone in swift 5.0 where I am using AVAudioPlayer. I have loaded the audio file (mp3), set numberOfLoops to -1 and called prepareToPlay() in init() of my class. Checked PrepareToPlay() method returns true.
When calling play(), it play the ringtone for one sec and stopped (even thought the ringtone duration in one loop is 7secs) but stop() is not called. When I introduce 100ms delay to play the ringtone for first time play, then it is playing continuously until stopped and second time onwards no issue in playing without delay. This is the case for latest iPhone. But when I tested the same code in old iPhone like 6s then getting same issue. In that case I have to introduce more delay as it is old hardware.
In my case, the object of the ringtone player is created and play() is called immediately.
Is this hardware delay (what I suspected) or may be something else expected even prepareToPlay() returns true? Or Am I not handling the AVAudioPlayer object properly?