play audio file

PHOTO EMBED

Fri Feb 09 2024 21:39:39 GMT+0000 (Coordinated Universal Time)

Saved by @anlorincz #swift

import AVFoundation
var bombSoundEffect: AVAudioPlayer?

func playSound(note: String) {
        let path = Bundle.main.path(forResource: note+".wav", ofType:nil)!
        let url = URL(fileURLWithPath: path)

        do {
            bombSoundEffect = try AVAudioPlayer(contentsOf: url)
            bombSoundEffect?.play()
        } catch {
            // couldn't load file :(
        }
    }
content_copyCOPY