When a user taps the button, it plays the music, and then it stops background music playing. But what I want is background music to keep playing even after the user had tapped the button
Here is code for playing the music
@State var bombSoundEffect: AVAudioPlayer?
Button("Button") {
let path = Bundle.main.path(forResource: "example.mp3", ofType:nil)!
let url = URL(fileURLWithPath: path)
do {
self.bombSoundEffect = try AVAudioPlayer(contentsOf: url)
self.bombSoundEffect?.play()
} catch {
// couldn't load file :(
}
}
How can I make background music keep playing even after user taps this button?