import AVFoundation

class NoisePlayer {
    var player: AVAudioPlayer?
    
    func playSound(_ sound: Sound) {
        guard let url = Bundle.main.url(forResource: sound.fileName, withExtension: nil) else {
            print("Sound file not found: \(sound.fileName)")
            return
        }
        do {
            player = try AVAudioPlayer(contentsOf: url)
            player?.numberOfLoops = -1 // Loop indefinitely
            player?.play()
        } catch {
            print("Error playing sound: \(error)")
        }
    }
    
    func stopSound() {
        player?.stop()
    }
}
