procedural audio with swift

172

guard let soundFileURL = Bundle.main.url(forResource: "TestSound",
                                         withExtension:"wav") else {
                                            print("URL not found")
                                            return
}

do {
    audioPlayer = try AVAudioPlayer(contentsOf: soundFileURL)
} catch let error {
    print("Failed to load the sound: \(error)")
}

audioPlayer?.prepareToPlay()

Comments

Submit
0 Comments