1

I need to playback a single audio file with TheAmazingAudioEngine framework and Swift. I'm completely newbie with this framework and tried the code below, but the audio didn't play. What is wrong? How could I play the audio file?

do {
    var audioController = AEAudioController(audioDescription: AEAudioController.nonInterleavedFloatStereoAudioDescription())
    let file = NSBundle.mainBundle().URLForResource("myaudiofile", withExtension: "wav")!
    let channel = try AEAudioFilePlayer(URL: file)
    audioController?.addChannels([channel])
    channel.playAtTime(0)
} catch {
    print("Failure")
}
Devapploper
  • 6,062
  • 3
  • 20
  • 41
msampaio
  • 3,394
  • 6
  • 33
  • 53

1 Answers1

1

I missed to start the audioController:

do {
    var audioController = AEAudioController(audioDescription: AEAudioController.nonInterleavedFloatStereoAudioDescription())
    let file = NSBundle.mainBundle().URLForResource("myaudiofile", withExtension: "wav")!
    let channel = try AEAudioFilePlayer(URL: file)
    audioController?.addChannels([channel])
    try audioController!.start()
} catch {
    print("Failure")
}
msampaio
  • 3,394
  • 6
  • 33
  • 53