Closed ivanlares closed 6 years ago
It works when I use the class method.
Sound.play(file: "ding.wav")
But it doesn't work when I use the code below. I tested on multiple devices.
guard let soundUrl = Bundle.main.url(forResource: "ding", withExtension: "wav") else { print("error with ding url") return } guard let mySound = Sound(url: soundUrl) else { print("error with my sound object") return } let didPlay = mySound.play() { completed in print("completed: \(completed)") } // prints true print("didPlay: \(didPlay)")
I took a look at the example code and I realized that we need to make a Sound property when using the completion handler.
Sound
Where as before I simply created an instance in a method.
It works when I use the class method.
But it doesn't work when I use the code below. I tested on multiple devices.