我正在使用Swift和Xcode 6开发iOS应用程序。我想使用AVAudioEngine播放音频文件,到目前为止一切都很好。但是如何在不停止的情况下播放它?我的意思是当它播放结束后立即重新开始。
这是我的代码:
/*==================== CONFIGURATES THE AVAUDIOENGINE ===========*/
audioEngine.reset() //Resets any previous configuration on AudioEngine
let audioPlayerNode = AVAudioPlayerNode() //The node that will play the actual sound
audioEngine.attachNode(audioPlayerNode) //Attachs the node to the audioengine
audioEngine.connect(audioPlayerNode, to: audioEngine.outputNode, format: nil) //Connects the applause playback node to the sound output
audioPlayerNode.scheduleFile(applause.applauseFile, atTime: nil, completionHandler: nil)
audioEngine.startAndReturnError(nil)
audioPlayerNode.play() //Plays the sound
在告诉我应该使用AVAudioPlayer之前,请注意,我不能这样做,因为后面我必须使用一些效果并同时重复播放三个音频文件。