Get AVAudioPlayer to play multiple sounds at a time

前端 未结 4 399
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 17:44

I\'m trying to get multiple sounds files to play on an AVAudioPlayer instance, however when one sound plays, the other stops. I can\'t get more than one sound to play at a t

4条回答
  •  情歌与酒
    2020-12-02 18:11

    I have created a helper library that simplifies playing sounds in Swift. It creates multiple instances of AVAudioPlayer to allow playing the same sound multiple times concurrently. You can download it from Github or import with Cocoapods.

    Here is the link: SwiftySound

    The usage is as simple as it can be:

    Sound.play(file: "sound.mp3")
    

提交回复
热议问题