Created
September 21, 2014 07:08
-
-
Save MichaelSnowden/238606cb15d5ef9ed3c3 to your computer and use it in GitHub Desktop.
Just a drop-in class for playing short sound clips in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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