Skip to content

Instantly share code, notes, and snippets.

@littlebobert
Last active February 2, 2017 15:12
Show Gist options
  • Save littlebobert/6e01a073c86e9860c771bdb56b93945c to your computer and use it in GitHub Desktop.
Save littlebobert/6e01a073c86e9860c771bdb56b93945c to your computer and use it in GitHub Desktop.
guard let path = Bundle.main.path(forResource: "MLK", ofType: "mp3") else {
return
}
let url = URL(fileURLWithPath: path)
player = AVAudioPlayerNode()
audioEngine.attach(player)
do {
let audioFile = try AVAudioFile(forReading: url)
audioEngine.connect(player, to: audioEngine.mainMixerNode, format: nil)
player.scheduleFile(audioFile, at: nil, completionHandler: nil)
try audioEngine.start()
player.play()
} catch let error {
print(error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment