It is difficult to provide an answer without additional context, for example, more code :-)
I suspect that your AVAudioPlayer
, if used as a local variable, may be collected by the garbage collector (GC) when the method returns (is it FinishedLaunching
?).
If so, then moving the local player
variable into the field ensures that the link is stored in the AVAudioPlayer
instance and should allow it to play without interruption (or failure).
If I am mistaken, please edit your question and provide us with more context, and we can help you in the future.
source share