Last active
February 2, 2017 15:12
-
-
Save littlebobert/6e01a073c86e9860c771bdb56b93945c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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