Slow start for AVAudioPlayer the first time a sound is played

后端 未结 9 1351
孤城傲影
孤城傲影 2020-12-02 09:23

I\'m trying to eliminate startup lag when playing a (very short -- less than 2 seconds) audio file via AVAudioPlayer on the iPhone.

First, the code:

         


        
9条回答
  •  爱一瞬间的悲伤
    2020-12-02 09:50

    I don't know for sure, but I suspect the NSData object is being lazy and loading the contents of the file on demand. You can try "cheating" by calling [audioData getBytes:someBuffer length:1]; at some early point to get it to load that file before it's needed.

提交回复
热议问题