For some reason, when I get this error, the flag is still set to YES. I managed to find a workaround by checking currentTime vs. duration and restarting the player immediately if currentTime is not 0.0 (end of sound). All my tests are conducted on a simulator, since I do not have a license to test on my phone. Hope this helps. See Edits for a few quirks.
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { if ([_player currentTime] != [_player duration] && [_player currentTime] != 0.0f) { [_player play]; return; } ...
EDIT: Unfortunately, I still found errors finding the very beginning or the very end of the sound (or in a very small increment). I found that if you create special cases that handle these two instances, you are usually covered. You must stop the player, set the current time to 0.0, and then start the player again if you want to start or manually call the finish delegate if you want to finish (if you implemented it).
If I find a better solution or get more feedback running on a real device, I will update.
Mean Dinosaur Jul 07 2018-11-11T00: 00Z
source share