Skip to content

Instantly share code, notes, and snippets.

@MichaelSnowden
Created September 21, 2014 07:08
Show Gist options
  • Save MichaelSnowden/238606cb15d5ef9ed3c3 to your computer and use it in GitHub Desktop.
Save MichaelSnowden/238606cb15d5ef9ed3c3 to your computer and use it in GitHub Desktop.
Just a drop-in class for playing short sound clips in Swift
class Sound {
var audioEffect : SystemSoundID = 0
init(name : String, type: String) {
let path = NSBundle.mainBundle().pathForResource(name, ofType: type)!
let pathURL = NSURL(fileURLWithPath: path)
AudioServicesCreateSystemSoundID(pathURL as CFURLRef, &audioEffect)
}
func play() {
AudioServicesPlaySystemSound(audioEffect)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment