Created
October 26, 2014 06:28
-
-
Save toast38coza/56f40c05d14e23e56588 to your computer and use it in GitHub Desktop.
Play Audio with 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
// requires linked AVFoundation.framework | |
// don't forget to import AVFoundation at the top of your controller | |
var player:AVAudioPlayer = AVAudioPlayer() | |
var error: NSError? = nil | |
var p1sounds = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("filenamegoeshere", ofType: "mp3")!) | |
player = AVAudioPlayer(contentsOfURL: p1sounds, error: &error) | |
player.play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment